I'm trying to make my character sprint when I press the left shift button. I already have an animation for walking and sprinting but I don't know where to add the keypress/toggle.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Well, I've got my left shift to activate my animation (set as a trigger) and the walking speed to increase to running, but the run takes holding down keypresses while the animation is just a toggle. So either I'd have to set the sprint to toggle instead of holding down shift (which I can't figure out how to do) or somehow make the animation script detect when I stop holding down the shift key.
Here's my script code
Whether I use GetyKeyDown or just GetKey, neither detects releasing and holding down the shift key, both act as a toggle. Any ideas?
Welcome to the community, @BiZark.
Your script doesn't mention AC, but with that method I would expect you'd want to control a Boolean animator parameter, rather than a Trigger, since a Trigger can only fire once. You can have this Bool value toggle between true/false each time an input is pressed.
However, a character that relies on AC for motion shouldn't need such a script. If you're Movement method is set to Direct, you can toggle running by pressing an input named "RunToggle".
See the Settings Manager's "Available inputs" panel for a complete list of inputs you can make use of.
The RunToggle is good, but how would I activate an animation without the use of my own script? And what would the code look like for a Bool?
Thanks!
If the AC player is running, they'll play their "run" animation automatically, provided you've supplied one. How exactly this is done depends on your character's chosen "Animation engine". What is yours set to? Let's see some screenshots of your Player's Inspector and Animator Controller for context.
Something like: