Sorry, apparently this question is asked a lot but I couldn’t figure it out from other answers. Here is my code:
if (Input.GetButtonDown (Space) && obj.transform.position.y == 0.5F)
{
while(obj.transform.position.y <= jumpheight)
{
obj.transform.position.y += jumpspeed;
}
}
What is wrong here ?
Change Input.GetButtonDown (Space)
to this: Input.GetKeyDown (KeyCode.Space)
or this: Input.GetButtonDown ("jump")
if you want to use “space”, then you’ll need to create a new input setting (Edit → Project Settings → Input)
https://unity3d.com/learn/tutorials/topics/scripting/getbutton-and-getkey
https://docs.unity3d.com/ScriptReference/Input.GetButtonDown.html
https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html
Well, Input.GetButtonDown() takes a string, not an enum from what I can see. Check out the Unity Documentation for Input.