In any game it is essential to have a user input to control the behavior of the player. A user can give inputs either by keyboard, mouse or by touch.
So for a developer it is essential to learn how to take the user input and manage your character behavior.
Today we are going to learn about keyboard inputs-
Taking input from keyboard is not that tuff all we need to do is check if the user has pressed any key, if yes do certain thing, as the user can press the key at any point of time user inputs code are mostly written in update method.
To start with today's blog
1. Create a scene add a cube and plane to it.
2. Write the following script.
(Note the difference in GetKey, GetKeyDown and GetkeyUp).
All these are input types while working with keyboard commands.
GetKey-Works till the user has pressed the key. (Runs multiple times till the key is down).
GetKeyDown -Works only when a key is held down. (Runs once when the key is pressed).
GetKeyUp-Works once the key is held up. (In easy language when a key is released).
That's all for today this post is open to edit and comment.
Post A Comment:
0 comments: