Computer Language/Unity
[Unity] Input keys
정우섭
2019. 2. 25. 07:02
Input.GetKeyDown(KeyCode.---) - Will happen once when you hit the key
Input.GetKey(KeyCode.---) - Will continue to happen while you are holding the key
Input.GetKeyUp(KeyCode.---) - Will happen once when you release the key
We can use it like this
If you put this code in Update() function the object can jump now.
When user hit Space Key, the Input.GetKeyDown in the picture becomes true value, so the if statement works.
By AddForce(x,y,z,mode) function it also uses Vector3 as value so in the picture the function contains Vector3.up value to move upward.