- Home /
Play Specific Animations of an Object
Hi everybody, I've been messing with Unity a little but I'm still new to it. I'm trying to make this gun game where I made a modeled and animated machine pistol that I want it to play the shooting animation when mouse is clicked. I have it set to that part, but how do I play the animation when it needs to reload? I don't want it to intersect with the shooting animation. I also, BTW, have the animation split up so that it will work. The shooting animation is basically named "shoot", and the reloading is "reload". So... how do I do it? Anyone help me please?
Answer by whydoidoit · Nov 18, 2012 at 10:52 PM
You've got lots of choices :)
You can animation.CrossFade("reload") which will blend one into the other. Then cross fade them back.
You can stop the shoot animation and just play reload: animation.Play("reload")
You can put them on different layers (so reload is higher than shoot) then animation.Play("reload") will take over from the shooting and then go back when it stops (presuming its set to Once).
You can get the individual animation states by doing animation["youranim"] and set the weight, the speed and whether it is enabled for each animation separately.
Takes some kicking does the animation system - powerful though.
Yes, I've solved the problem -- it turns out that I had two variables -- shoot and reload. When shoot is 0, reload = 1 which means true. Then you can't shoot at that time. Vice versa for reload. Thanks for the answer and sorry I've not updated for a long time~ :)
Your answer
Follow this Question
Related Questions
Unity animation is off please help 0 Answers
3rd person gta like weapon problem?? 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Animation On Mouse Click 1 Answer
Animation on gun sometimes skips? 1 Answer