- Home /
Animation Script Help
I have wrote this script which kind of does what I want it too; I want it to play an idle animation if nothing is being pressed play a walk animation when w or s is pressed, play a shoot animation when the LMB is clicked and play a reload animation when r is pressed. All this works but the shoot animation sort of delays which I dont want. Can anyone help me out with this?
this is my script,
function Start () {
animation.wrapMode = WrapMode.Loop;
animation["idle"].speed = 0.2;
animation["walk"].speed = 1;
animation["reload"].speed = 1;
animation["shoot"].speed = 2;
animation["shoot"].wrapMode = WrapMode.Once;
animation["reload"].wrapMode = WrapMode.Once;
animation["shoot"].layer = 1;
animation["reload"].layer = 2;
animation.Stop();
}
function Update () {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("walk");
else
animation.CrossFade("idle");
if(Input.GetButtonDown("Fire1"))
animation.CrossFade("shoot");
if (Input.GetButtonDown("r"))
animation.CrossFade("reload");
}
What do you mean delayed? It takes time before it begins? Does it do this for all the animations?
if I click the L$$anonymous$$B it plays the animation but then I have to wait a couple of seconds before I can do it again.
Answer by suruz@kento · Dec 01, 2011 at 07:46 PM
Shooting must have instance response.I think your shoot animation is being delayed because of crossfade or transition what ever you say.So, stop any previous animation instantly before using shooting animation.
if(Input.GetButtonDown("Fire1")){animation.Stop();animation.Play("shoot");}
if(Input.GetButtonDown("r")){animation.Stop();animation.CrossFade("reload");}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Reloading Help 2 Answers
Trying to simply play this animation... Help please. 1 Answer
Need help with some OnTrigger Scripting 2 Answers
what's wrong with this script? 2 Answers