- Home /
How do you make a sprint script actually change your speed?
I know how to make the script run an animation but i dont know how to change my actual speed. I want the script to increase my characters speed when I hit the shift button.
I dont see how this is badly explained. I want to know what I need to put in the script to make my character move faster than normal and thats it. I will be making the script from scratch.
Answer by GerryM · Sep 20, 2012 at 04:09 PM
Assuming you use a character controller, you can set the speed in the script's variables.
If you move your character with your own script, change the translation or force value, i.e. use higher values for speed in:
transform.Translate(Vector3.forward * Time.deltaTime * speed);
Otherwise you can change the overall speed in the Project Settings/Time via Time Scale.
maybe im not understanding your answer but it seems to me what you are telling me is how to move my character in general. I want somethng that will change my speed when I press the shift button.
So you mean like running when you press shift? You could check for the pressed shift key with if(Input.Get$$anonymous$$eyDown("shift")) and set the speed variable to the higher (or else lower) value.
Your answer
Follow this Question
Related Questions
Increase speed of footsteps when sprinting? 2 Answers
Energy Pickup 1 Answer
Sprint animation play ONLY when speed = 13 1 Answer
Decreasing footstep length when key pressed 1 Answer
Why Isn't This Sprint Working? 1 Answer