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 GKdev1980 · May 08, 2014 at 08:24 PM · mecanimtransition

Mecanim opposite transitions. Easy made hard?

I'll have to admit, I just started using Mecanim, went through a couple of tutorials, tried to use it my scene.

I have an "idle" state and 5 movements on each side (a total of 11 clips). I've set my Animator controller, and I'm working on my transitions. I tried for testing purposes to have simple conditions, so I set an integer variable to control which state will play at a specific time. When this variable equals to 0 it will play my idle clip. And I want to be able to go back and forth between my states. Basically it's a series of integers: -5,-4,-3,-2,-1,0,1,2,3,4,5. When my variable is 0 it plays my idle clip, and I change my variable with a script, so I would like to play my transitions and move the clip besides it, but both ways. So I created transitions from every clip to the previous and to the next one, and the other way around.

I must be doing something wrong there. For example when going from 0 to -1 I set both transitions "when var equals to -1". But naturally when setting my variable to -1 it kept looping between clip"0" and clip"-1", which is not what I want.

So I changed my variable to float and going from 0 to -1 I set the condition "when var is less than -0.5" while going from -1 to 0 I set the condition to "when var is greater than -0.5" and followed that pattern for the rest of the transitions. So going from -1 to -2 I've set "less than -1.5" and "greater than -1.5" etc and on the other side going from 0 to 1 I used "greater than 0.5" and "less than 0.5", "greater than 1.5" and "less than 1.5" and so on. I hope that's clear enough.

And now comes the strange part (at least for me)..

I can go from 0 to -1 and back nicely. If I go from -1 to -2, the opposite transition doesn't work. I can go to -3 but not back to -2.. Also I can't go from 0 to 1, 2 etc.. It seems like I can only go one way and I can't even go back, except for my first transition to the left..

What am I doing wrong?

Whenever I say "I go from 0 to -1" or something like that, I'm referring to the corresponding animation clips. I don't have any problem with changing my variable value.

Comment
Add comment · Show 4
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 robinrei · May 08, 2014 at 08:27 PM 0
Share

Honestly it seems like you would be better off using a Blend tree for this example.

https://docs.unity3d.com/Documentation/$$anonymous$$anual/AnimationBlendTrees.html

avatar image GKdev1980 · May 08, 2014 at 08:55 PM 1
Share

I thought that blend trees are better when we want to play parts of 2 animations at the same time. I want to play distinct animations..

I got the idea for using transitions from seeing this tutorial http://www.youtube.com/watch?v=4UboS7ZLfUw

In this case, he manages to go from idle to walk to run and back to walk and idle with no problems...

avatar image robinrei · May 08, 2014 at 09:20 PM 0
Share

In that case, perhaps the correct solution for you is to have transitions to all of your states from any state on different triggers. This should only be called a single time or it will keep transitioning to the state from itself. There should only be a single animator.SetTrigger(animString) per animation change.

avatar image GKdev1980 · May 08, 2014 at 10:07 PM 0
Share

You mean have a "central" state (the default "Any State" I get as soon as I open the animator) and all the other states with transitions to and from this central state?

But this way (if I get it right) I would lose any smooth transitions from each animation to the next. I might as well use Legacy animations. But I need smooth transitions, otherwise there would be a jump from one animation to the other...

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by GKdev1980 · May 09, 2014 at 07:24 AM

It seems like the second way I had in mind (using float as the variable type) and checking whether its value is greater or less than the half of the 2 states works..

I changed 2 things at once, so I'm not sure exactly which of them was causing the conflict. First, I got a "index m_intcount" message, with some googling I found that it had to do with the fact that I changed the variable type from int to float without redoing all my transitions. So I deleted them and recreated them..

The second thing, had to do with the script I used to change my variable value, I was using the same controls (left and right arrow keys) with another script I used for a different gameobject, maybe some conflict there..

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

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

mecanim animation transition script 3 Answers

Unity 5.2: Mecanim Transition Blending 1 Answer

How to stop mesh disappearing during Animator state transition blend time? 1 Answer

Mecanim new Trigger parameter explanation? 1 Answer

Mecanim transitions into two places simultaniously 0 Answers


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