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 aleem.razzaq09 · Dec 13, 2013 at 06:09 AM · animation2d

Animation is not playing again in Unity 4.3

Hi I have a 2D object in which I added Animation and in Animation disable Loop time, also make disable animator with my game object is just to play when I needed. Below line is call on start function.

rubberObject.GetComponent().enabled = false;

and play this it hits some other object in on enter collider2D function.

rubberObject.GetComponent().enabled = true;

and then disable it on exit collider2D function again. It works fine for first time but when it collider again with object it doesn't animate, the same functionality applied on second time but it doesn't animate. I don't know why this happen is this Unity issue or on my side Issue. Kindly help me on this. Thanks in advance.

Comment
Add comment · Show 2
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 Spinnernicholas · Dec 13, 2013 at 04:30 PM 0
Share

So what, you have an animation that is supposed to play during a collision? Any more information you can give will help.

Also, you need to pass a type to GetComponent,

 GetComponent(Type type);

or call it

 GetComponent<type>();


avatar image aleem.razzaq09 · Dec 16, 2013 at 11:07 AM 0
Share

@Spinnernicholas Thanks and sorry for showing you wrong code I am doing like this as u r suggesting me code. First I disable animator in inspector window and make this enable on to write following line. rubberObject.GetComponent().enabled = true;

It also play animation when I make this enable but I can't play and pause and also stop like this{rubberObject.animation.Play(); rubberObject.animation.Stop();} this when I want this because this play only once, also I again make this disable and then make this enable but It didn't work. $$anonymous$$indly help me on this, if you already done this work for 2D kindly suggest me better way to achieve this target.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Spinnernicholas · Dec 13, 2013 at 04:24 PM

If you are using sprite(dope sheet) animation, it was built to use the Animator component and doesn't work as expected with the Animation component. If all of your animations are animation curves, then this doesn't apply to you.

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 aleem.razzaq09 · Dec 16, 2013 at 11:10 AM 0
Share

@Spinnernicholas I am using sprite animation, so What I have to do to play and stop animation when I want this. I only have to images sprite animation. $$anonymous$$indly suggest me better way to accomplish this task.

avatar image Spinnernicholas · Dec 16, 2013 at 04:24 PM 0
Share

You will have to use the animator component. You can simulate the same functionality of the animation component.

See HERE.

  • Create a parameter for each animation.

  • Then create a state for each animation and set the animation in it.

  • Create a transition from the any state to each animation state and set the transition condition as the parameters you made earlier.

Now, ins$$anonymous$$d of doing:

 animation.Play(animationName);

You will do:

 animation.setTrigger(parameterName);

avatar image Spinnernicholas · Dec 18, 2013 at 11:51 PM 0
Share

How's it going?

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to play and stop animation via code in Unity4.3 for 2D objects. 0 Answers

SpriteManager 2 1 Answer

App get crash on animation of 2d object in Unity 4.3 0 Answers

A node in a childnode? 1 Answer

Animation and Stealth Tutorial 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