- Home /
Unity 3D 4.3.2 , animation.Play("name"); not working
First, the Unity 3D Hello guys , I liked the program that creates games :) ! Come to that I have a problem , I saw a video of how to add weapons and etc , but I reached a point where I wanted to add an animation when the gun shot was fired , and edited the script etc , but the animation is not performed. Script I use :
https://dl.dropboxusercontent.com/u/99253328/Riffle.js
END OF CODE IS MORE LINE DO NOT PART OF THE SCRIPT
good, the animation of the firing of the bullet is not forfeit by Weapon tab Hierarchy has the Animation component , this is finally someone help me I am grateful , sorry for my bad english , I am Brazilian and I used the google translator to help me ! Images that might help you : http://imagizer.imageshack.us/v2/800x600q90/706/f5w3.jpg
Answer by gameboyforlike · Jan 19, 2014 at 05:22 AM
try to use animation.crossfade("Name of animation"); or animation.play("Name of animation");
or else
OnMouseDown()
{
if(Input.GetMouseButtonDown(0)) {
animation.Play("tiro", PlayMode.StopAll);
Instantiate(bala,transform.position,transform.rotation);
}
or
function OnMouseUpAsButton(){
animation.Play("tiro");//, PlayMode.StopAll);
Instantiate(bala,transform.position,transform.rotation);
}
sorry if OOT, may i know what is Play$$anonymous$$ode.StopAll used for?
Sorry, that did not work in my script, must be why the spaces of the new script you asked me to replace the lines of the animation, in answer.unity3d.com they decrease the spaces, I could write the same scripts on some site Hosts file for me to download? Thanks for responding, I am grateful if you help me, animation.crossfade not work here! :/
Answer by Frostbite23 · Jan 19, 2014 at 05:55 AM
it could be that your animation is not marked as legacy, meaning that it was created in the animation editor but it could not be read by the animation component. or it may be the PlayMode.StopAll
affecting it and also to point out you are setting the PlayMode of the animation to stop or stop all (don't know what StopAll is used for). and why are you using the PlayMode.StopAll
for? you can just use animation.Play("tiro");
Thanks for answering first, but how do I do that? I did the animation in the 3d-editor of unity and saved everything correctly but the unity talks that when I press "Play Game" and try to shoot the gun:
The animation state shot Could Not Be played because it could not be found!
shot which is the name of the animation! And I think the script may be correct but the animation is not found by the script, also tried the animation "walk" which already comes in unity to use Third Person Character
Thank you, I am grateful if you answer me: (
Answer by blenderblender · Sep 22, 2014 at 12:42 PM
I think that the animation function does just work in the Update
Your answer
Follow this Question
Related Questions
Game name incorrect on android build 0 Answers
Why cant I download anything off the forum? 1 Answer
Running a 2D game in a 3D environment - can it be done? 2 Answers
Extra black space when embedding webplayer game 0 Answers
Access Denied 1 Answer