|
Hello, My character jumps using spacebar. When I HOLD spacebar down, he jumps over and over and over. I want him to perform the jump each time spacebar is pressed; but not when spacebar is held down. The script I'm using is below: using System.Collections; public class Walker : MonoBehaviour { } Any help is greatly appreciated. Thank you so much!
(comments are locked)
|
|
You can use the Input.GetKeyDown and Input.GetKeyUp. Set a bool to true when it's down, and when GetKeyUp is captured and the bool is true, jump (and set the bool back to false). Thank you for the help. I'm having problems adding a bool because it never recognizes the variable I set. I tried using public, private, etc but none of them worked. do I need to label it differently?
Jun 21 '12 at 07:56 PM
shawnkilian
A private field (= a variable that belongs to the class, declared outside any methods) should always retain its state between function calls.
Jun 21 '12 at 08:00 PM
Drakestar
(comments are locked)
|
