x


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");

}

}

more ▼

asked Nov 26 '11 at 05:05 PM

Dreave gravatar image

Dreave
137 82 95 96

Have you checked if the animation keyframes are set right?

Nov 26 '11 at 10:24 PM Nonakesh

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.

Nov 26 '11 at 11:25 PM Dreave

No, I wanted to ask if you have checked the animation option, where you can select the keyframes the animation is located in blender!

Nov 26 '11 at 11:33 PM Nonakesh

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.

Nov 27 '11 at 08:13 PM Dreave

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.

Nov 27 '11 at 08:41 PM jahroy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 :)

more ▼

answered Nov 26 '11 at 10:35 PM

TheCSharpFreak gravatar image

TheCSharpFreak
3 3 4 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5277
x3936
x3894
x750

asked: Nov 26 '11 at 05:05 PM

Seen: 1226 times

Last Updated: Nov 27 '11 at 08:41 PM