- Home /
Animation script
My aim is it to press a key and the player takes out a gun. If you press the key again, he puts it back. I've already got the animation, but I tried many scripts, but they didnn't work. Pls help me! 1. Question: Should the transitions be bools, triggers floats or ints? 2. Question: How can I write my C# script? If you press the key, the whole animation should be played and the gun should stay out. If you press the key again, another animation should be played.
Comment
Answer by UnityCoach · Mar 16, 2017 at 01:02 PM
You can use triggers or bools.
// this is a mere test, but it should get you started // put this within the update // not optimal though
if (Input.GetKeyDown("space"))
GetComponent<Animator>().SetTrigger("DrawGun");
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
separate script to reload. 0 Answers
Animation and Position 2 Answers
How to check if Animator is playing 3 Answers
Gun Recoil C# 1 Answer