- Home /
How Can I Change My Player Speed If A Variable Is Set To Zero
I am not too sure if I had worded my question appropriately, but essentially, I have an energy bar that drains when I am holding either the left or the right shift keys. When either shift key is being held, my player is running rather than walking/trotting.
What I am looking to have happen is when the energy bar value reaches zero; the shift keys are not active until the player's energy regenerates.
If I cannot disable a key, like I am thinking, is there a way I can temporarily change the running speed of my player.
Answer by BPR · Mar 22, 2013 at 09:36 PM
Hi, you only have to add a second condition to your running request, for example: if (Input.getKey(...) && EnergyBarLevel > 0){ //Run }
Regards,
BPR
I am only assu$$anonymous$$g this would go on my player controller, and not on the energy bar script? should i make the variables pertaining to the energy bar global variables in that case?
Sorry if that sounds like a rookie question there, but i dont know a ton about program$$anonymous$$g.
Thanks again BPR, i really appreciate it.
-JStaples
Your answer
Follow this Question
Related Questions
How do I create a simply disable script for enemy AI once it completes its waypoints? 2 Answers
How to create an AI follow script in Java? 2 Answers
AI Path and respawn help!!! 0 Answers
2D sidescroller ranged character shooting problem. 0 Answers
What should I do? Disable the AI or have the AI simply be recylced and reused? 1 Answer