|
I have an animation script for my walk and idle animation, I also have an animation for my shoot and reload (all scripts are at the bottom). But I have this problem that if I have both scripts attached to my gun the animations clash and dont work properly. I haven't done anything to the animation options on the gun inside the inspector window which I think I need to do, can anyone help me with this? walk and idle script; } function Update () { if (Input.GetAxis("Vertical") > 0.2) else } shoot script; animation["shoot"].speed = 2; } function Update () { if(Input.GetButtonDown("Fire1")){ animation.Play("shoot"); } } reload script; function Start () { animation["reload"].speed = 1; } function Update () { if(Input.GetButtonDown("r")){ animation.Play("reload"); } }
(comments are locked)
|
|
Try setting each animation to an appropriate layer. For the above code I believe you would need to set idle animation to layer 1. Then the walk animation to layer 2. The walk animation would need to be set to PingPong, whilst the idle animation would be set to loop. Nice. Thanks for answering this and finally explaining to me what these mystical animation layers are. I've seen no less than a half-dozen questions just like this one since I started playing with animations last week. The documentation is very clear that playing an animation stops all other animations in the same layer. Now I know what that means!
Nov 28 '11 at 10:50 PM
jahroy
no problem!
Nov 29 '11 at 06:47 AM
TheEmeralDreamer
Thanks for your help
Nov 30 '11 at 08:10 AM
Dreave
(comments are locked)
|
|
I recommend reading the documentation for the functions you're using. When you call Animation.Play or Animation.CrossFade, it effects all the animations that are currently playing (on the same layer). I am very new to animations, but a quick scan of the documentation suggests that the animations triggered by your code will constantly interrupt each other. The code that you've shared will cause the idle animation to play every frame that the up button is not being pressed. Otherwise, the walk animation will play. If you want your shoot and reload animations to play, you probably have to stop your walk/idle animation (and vice versa).
(comments are locked)
|
