|
Hi Unity users. I have 3 animations. The first animation is the Idle animation. The second animation is the Walk animation. The third animation is the Shoot animation. Well, the Idle animation plays when the player doesn't move. The the Walk animation plays when the Player is walking. But now when i press my left mouse button, the Shoot animation needs to play till i release the mouse button. So i got this script to make it possible. But it's not working. The Shoot animation won't play by left click. Someone can help me please? Thanks in advance. DonIlias "
(comments are locked)
|
|
For animation.CrossFade("Shoot') in the last few statements there, you are using Input.GetMouseButtonDown. So the animation is played only when the mouse 'click' is detected because GetMouseButtonDown checks for click . Instead use Input.GetMouseButton, it checks whether the button is 'held' down and the animation is played untill mouse button is released.
(comments are locked)
|
|
i would make a new Java script like this: instead of "shoot" you can put any other animation
(comments are locked)
|

GetMouseButtonDown only returns true the first frame of pressing the mouse button, thus making it only execute once.