Add Element to Sequence Accepted Tags in Code
Posted: Thu Feb 08, 2018 3:44 am
Hey Toni,
I'm trying to figure out how to add accepted tags elements via c# code. I've got the other components set properly but its just the accepted tags that I can't seem to get to work. It says the length is read only an adding a 1 to the first element for size isn't an option? It's 3 am maybe I'm missing something ><?
Q1. How do I set this array value? Like size to 1 and first element to Player.
Q2. Can I check if a trigger has a sequence trigger by comparing to null?
Code is below, error is towards the bottom. Code currently works only on the first element of the collection and then stops at the error. Thanks!
foreach (GameObject trigger in graveSceneTriggers)
{
if (trigger.GetComponent<SequenceTrigger>() == null) // if this trigger didnt retain its sequence trigger (Q2)
{
// Build new sequence trigger with proper number label
trigger.AddComponent<SequenceTrigger>();
SequenceTrigger ST = trigger.GetComponent<SequenceTrigger>();
ST.trigger = DialogueTriggerEvent.OnTriggerEnter;
ST.once = true;
ST.sequence = "AnimatorBool(GraveVinesGrow, true, GraveStory_Vines_0" + vineValue + ")@.2; \n" +
"AnimatorBool(GraveVinesWiggle, true, GraveStory_Vines_0" + vineValue + ")@1; \n" +
"AnimatorBool(GraveVinesGrow, false, GraveStory_Vines_0" + vineValue + ")@1.1;";
ST.condition.acceptedTags[0] = "Player"; // error is happening here (Q1)
}
vineValue++;
}
vineValue = 1;
I'm trying to figure out how to add accepted tags elements via c# code. I've got the other components set properly but its just the accepted tags that I can't seem to get to work. It says the length is read only an adding a 1 to the first element for size isn't an option? It's 3 am maybe I'm missing something ><?
Q1. How do I set this array value? Like size to 1 and first element to Player.
Q2. Can I check if a trigger has a sequence trigger by comparing to null?
Code is below, error is towards the bottom. Code currently works only on the first element of the collection and then stops at the error. Thanks!
foreach (GameObject trigger in graveSceneTriggers)
{
if (trigger.GetComponent<SequenceTrigger>() == null) // if this trigger didnt retain its sequence trigger (Q2)
{
// Build new sequence trigger with proper number label
trigger.AddComponent<SequenceTrigger>();
SequenceTrigger ST = trigger.GetComponent<SequenceTrigger>();
ST.trigger = DialogueTriggerEvent.OnTriggerEnter;
ST.once = true;
ST.sequence = "AnimatorBool(GraveVinesGrow, true, GraveStory_Vines_0" + vineValue + ")@.2; \n" +
"AnimatorBool(GraveVinesWiggle, true, GraveStory_Vines_0" + vineValue + ")@1; \n" +
"AnimatorBool(GraveVinesGrow, false, GraveStory_Vines_0" + vineValue + ")@1.1;";
ST.condition.acceptedTags[0] = "Player"; // error is happening here (Q1)
}
vineValue++;
}
vineValue = 1;