- Home /
Animation Problems
I have animated a gun on blender, imported it into unity and wrote a simple script which plays it when the LMB is clicked. But when I do click the LMB it only plays half the animation, I had this problem before but I fixed it by having the animation loop which I cannot do this time because its a pistol. Can anyone help me with this?
This is the script im using;
function Start () {
animation["shoot"].speed = 1.8;
}
function Update () {
if(Input.GetButtonDown("Fire1")){
animation.Play("shoot");
}
}
Have you checked if the animation keyframes are set right?
On blender ive animated it with action editor which I think is the right way to animate, ive checked the the animations over in blender and are fine until I import them into unity.
No, I wanted to ask if you have checked the animation option, where you can select the keyframes the animation is located in blender!
Ive found the problem; my walk animation script somehow makes the other animations glitch out, I have taken the walk script off and it works fine now.
According to the documentation, when you call Animation.Play() on one animation, all other animations in the same layer are stopped. If part of your script is telling your walk animation to play over and over, that's probably what's stopping your pistol animation.
Hard to say since we haven't seen any of the relevant code, but that would be my guess.
Answer by $$anonymous$$ · Nov 26, 2011 at 10:35 PM
If the animation is too long, it will be restarted with every time you shot.
Try to use animation.CrossFade() or let your animation play faster :)
Your answer
Follow this Question
Related Questions
Blender animation 1 Answer
Stop animation after played 30 times? 0 Answers
Animation On Mouse Click 1 Answer
Trying to simply play this animation... Help please. 1 Answer
Reacting to Mouse animation... 2 Answers