J's Study log

[Unity] Input keys 본문

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.

'Computer Language > Unity' 카테고리의 다른 글

[Unity] Parents and Child Object  (0) 2019.02.27
[Unity] Input Mouse Button  (0) 2019.02.27
[Unity] Input Arrow Keys  (0) 2019.02.25
[Unity] Camera Work  (0) 2019.02.25
[Unity] GetComponent  (0) 2019.02.23
Comments