Hi,
Try this. Make two events called
pressed
and
released
.
State 1,
Press A
: get key down,
A
key, goes to
pressed
event.
State 2,
Release A
: get key up, goes back to state 1. Not sure, but check also key pressed, if false then also go back to state 1.
1) First watch the FSM. Does it go to the proper state when you press A and release?
2) Now, you can animate the key with a usual animation clip. The is also the new timeline feature. You can move it by smooth transform, with actions like move towards, itween move etc. As a tip, use two empty invisible GameObjects, give them a gizmo icon (inspector top left when selected) to mark the two positions, then your thing can move towards one and back to the other, advantage you can easily tweak the positions by moving your start/end points around. You can also note down the vector (start/end position) and set this in variables. And finally, you can move stuff with physics, add velocity, add force, change gravity etc.
3) Once more, be aware of
Input Manager
. Same principle, but you use Get
Button
etc instead of key, and you assign the keys/inputs to your buttons in the manager. Depends on what you try to do, as always. If you have only keyboard, and it is straight forward, go ahead with keys. If you have other inputs, alternative layouts etc, use Buttons.
Thanks for the advice, I got Press A/Release A, communicating and holding as I hold the key down like I want. But I can't get anything to move! I tried the move towards action as well as animating.
Hi,
Try this. Make two events called
pressed
and
released
.
State 1,
Press A
: get key down,
A
key, goes to
pressed
event.
State 2,
Release A
: get key up, goes back to state 1. Not sure, but check also key pressed, if false then also go back to state 1.
1) First watch the FSM. Does it go to the proper state when you press A and release?
2) Now, you can animate the key with a usual animation clip. The is also the new timeline feature. You can move it by smooth transform, with actions like move towards, itween move etc. As a tip, use two empty invisible GameObjects, give them a gizmo icon (inspector top left when selected) to mark the two positions, then your thing can move towards one and back to the other, advantage you can easily tweak the positions by moving your start/end points around. You can also note down the vector (start/end position) and set this in variables. And finally, you can move stuff with physics, add velocity, add force, change gravity etc.
3) Once more, be aware of
Input Manager
. Same principle, but you use Get
Button
etc instead of key, and you assign the keys/inputs to your buttons in the manager. Depends on what you try to do, as always. If you have only keyboard, and it is straight forward, go ahead with keys. If you have other inputs, alternative layouts etc, use Buttons.