Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 kitsune9000 · Oct 07, 2015 at 05:50 PM · animatormecanim2d animation

2D-How to call a synced layer animation up in script (Animator)

I have a 2D character with hand-drawn animations. The method that I decided to use to simulate a 'costume change' was to make a new layer in the Animator window and sync it with the original tree. Thus, I can run, jump, and melee attack (to name a few). And no matter what costume the hero wears, he can do all of these things. The animations are essentially what is changing, not puppet parts. Hence the use of Layers. So then, in my MainCharacterMovement script, how can I call a synced layer to replace the original layer? If I have DefaultLayer as the initial layer to start on a new game at runtime, how can I then switch to Layer1 or Layer2? I was thinking my logic would be something like:

if(costume1) switch animator layer

But my problem is that I don't know the syntax to switch layer states, or if it can even be that simple. Also, what dataType are layer states in mecanim? I want to make another variable for writing permanence later, so I want to be able to reference it. Again, I am using 2D everything in this game, collisions, rigidbodies, ect..

Thanks for any help.

Comment
Add comment · Show 1
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 kitsune9000 · Oct 20, 2015 at 03:48 PM 0
Share

I wanted to update my question as I haven't got any responses yet. I am still trying to find the code when I have a layer in $$anonymous$$ecanim that I add in addition to the original layer and use sync on that layer. Example: Layer0 is the base layer which is the default animation. Layer1 is a synced layer. Lets say in Layer0, I want a cube character to be plain blue, but in Layer1, the cube character will have polka dots.... So I have all my animations for this already (in the form of sprites -- from a sprite sheet). In the script,

how can I say:

"Ok, when polkaDots is true, switch to all animations from Layer1? And if polkaDots is not true, switch all animations back to Layer0."

Is anyone able to help?

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to link 2 animations of different objects in Mecanim? 0 Answers

Mecanim Runtime Controller is Private! 4 Answers

How do I make the transition between two states in the "Animator" happen instantly? 3 Answers

Mecanim deltaPosition is increased with more avatars 1 Answer

Animation Speed with Variable? 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