- Alright everyone, I’m really sorry; this is probably a basic as hell question but I’ve searched high and low for almost an hour trying to an answer, any help at all but all I could find was ‘collider triggers’, and that’s not what I want.
- What I’m asking is…
How does one activate a trigger animation??
For example, I have two trigger animations for a 2D platformer (based/ made in 3D); they are ‘Jump’ and ‘Slide’. These will both play their own ‘Blend Tree’ animations, from ‘Running’ (boolean) to the corresponding trigger animation (‘Jump’ or ‘Slide’).
Like, I have “bool Running = Input.GetKey(“right”);” and want to do something like "trigger Jump = Input.GetKey(“space”) but I don’t know how Dx Please help… - I want to know how to write these up in C# as I’m farly new to scripting/ game development but I really want to get into this as a full time job, a career. Its a way for me to release my creative side in a way I can enjoy for hours on end, whether making the game or playing the completed project.
Please help, please help… Any and all assistance will be much appreciated. Thanks in advance
So triggers are interesting as they may not work exactly how you like them. You can set a trigger via:
Animator animator = GetComponent();
animator.SetTrigger(“triggerName”);
And that will set the trigger for the animation. If you’re in a state that has no transition to fire that trigger though, that trigger will wait until there is a place where it can be fired and then it will initiate the trigger.
Let me give you an example. Say you are running and you want to slide. You trigger the slide animation and it will work. But say you’re jumping in the air and hit the slide button. If you don’t have a state transition from in the air jumping to sliding then the trigger will be set and just wait. So once you hit the ground, even though you hit slide a while ago, it will then initate the slide animation, because it was just able to use the trigger that you had set. So just be cautious with your use and understand the implications.