Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by bleg cheese123 · Dec 13, 2014 at 05:45 PM · fire1gun-animation

Animations not working


Hey guys, I am working on a post apocalyptic zombie shooter I am right now trying to make the Animations play, I have looked at all tutorials on youtube and unity lessons, but they don't work, i have attached the animation to the gun but for some rason it dosent work, here is my script:

 #pragma strict
 var Bullet : Rigidbody;
 var Spawn : Transform;
 var Bullet_Speed : float = 1000;
 function Start () {
 
 }
 
 function Update () {
 if(Input.GetButtonDown("Fire1"))
 {
 Fire();
 }
 }
 function Fire()
 {
 var Bullet1 : Rigidbody = Instantiate(Bullet, Spawn.position, Spawn.rotation);
 Bullet1.AddForce(transform.forward * -Bullet_Speed);
 audio.Play();
 animation.Play(); // Animation not working here :(
 
 
 }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by screenname_taken · Dec 13, 2014 at 05:48 PM

Do you have a component on the object called Animation, or Animator? You are using the "animation" calls which are used for the old animation system, but if your object has an "Animator" component then that is for the new animation system. So you would be mixing the two systems. Check the actual unity tutorials on mechanim instead. http://unity3d.com/learn/tutorials/modules/beginner/animation

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bleg cheese123 · Dec 13, 2014 at 11:38 PM 0
Share

yes there is an animator component on the gun, unless you mean in the script also thx fr the info :)

avatar image screenname_taken · Dec 14, 2014 at 06:48 PM 0
Share

Then your script is trying to access the "animation" component (old way of dealing with animations) while your component is the "animator", the new way of dealing with the animations.

avatar image spiceboy9994 · Dec 15, 2014 at 06:48 PM 0
Share

animation.Play(); code is for the Old Animation component, not for the animator. If you are using an Animator, then you have to transition to states and assign the animation to a selected state. If you're using a legacy animation, check this answer http://answers.unity3d.com/questions/828207/problems-with-animation-4.html

avatar image
0

Answer by wesleywh · Dec 15, 2014 at 05:26 PM

I would make sure that you can play the animation in the inspector. Also check if it is looping or not. If it isn't looping I know I have had some problems with my animations not playing before.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by bleg cheese123 · Dec 18, 2014 at 07:11 PM

@wesleywh yeh, they play in the inspector alright but other then that it dosent work. :(

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image screenname_taken · Dec 18, 2014 at 10:12 PM 0
Share

As i've said, you are mixing the two (incompatible) animation systems. You have the Animator component on your model (which is the new animation system) but you are trying to access it with the code for the old animation system (the legacy system). You should take a look at the unity tutorials about animation. NOT any generic 3rd party tutorial on youtube, unless you know for sure that they are covering the new animation system, $$anonymous$$ecanim. Just take a look at the link i provided in my answer above.

avatar image wesleywh · Dec 19, 2014 at 05:43 PM 0
Share

As screen_taken has said you are mixing the two animation systems. I have written some code to help someone else play their animations with the "Animator" component here:

http://answers.unity3d.com/questions/857058/make-animation-stop-when-ai-dosent-have-a-target.html

Here is the code if you were using an "Animation" component on your character:

 animation.Play("walk");//this will play your "walk" animation.

Now the issue with this is that if the animation wasn't built for your specific character it will not play. You can't play animations that was built for a different character.

Here is the example of turning walk on with the "Animator" component:

 SetFloat("speed", myspeed);//this checks your speed and in your animator state if your speed > 0.1f play the walk animation by going to "walk" State that has your walk animation on it.

With the "Animator" component you CAN play animations that were built for a different character.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

stopping a Coroutine while it is running. 1 Answer

Unity Android Fire1 UI Button? 1 Answer

My gun shoots while I'm reloading 2 Answers

Buttons in input manager don't do anything 1 Answer

MachineGun Script Not Working Dont Know Why! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges