Question by
MarioSuitedUp · Jul 26, 2017 at 07:30 PM ·
scripting beginnercharacter controllercharacter movement
How can I move my player up until the jusmp button is let go?
How can I make my player object go up when a key is held, then it falls down when it's let go in 2D.
Comment
Answer by UnityCoach · Aug 02, 2017 at 07:55 AM
To handle the jump state, you can do this:
[SerializedField] Keycode jumpKey;
public bool jumping {get ; private set;}
void Update ()
{
if (Input.GetKeyDown (jumpKey))
jumping = true;
else if (Input.GetKeyUp (jumpKey))
jumping = false;
}
Then, you can use Transform component, AnimationCurve, Animator, RigidBody2D, there are many ways you can make a character jump.
Your answer

Follow this Question
Related Questions
Error CS0103 0 Answers
infamous first light run code help 1 Answer
increasing float speed does nothing 1 Answer
I can't rotate and move in the opposite direction with character Controller 0 Answers