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
1
Question by vovo801 · Jun 15, 2015 at 06:01 PM · animatormultipletransitionstate machinestates

Animator transition from Entry state to multiple states in Unity 5

I am making a 2d game. In this game I will have torches. When the scene starts there are two options for torches:

  1. They may be burning

  2. Or they may be not burning and have no flame on them.

Whether the torches should burn or not is determined by a public boolean value "IsBurning" in the script attached to the torch, so I can decide which of them are lit up in the beginning of the scene and which are not burning.

I have made all animations for Burning and not burning states and for transitions between them. Here is how the Animator is looking right now: alt text

What I want to achieve is: If I set IsBurning in editor to true, my torch will immediately appear burning in the scene. If I set it to false, it will appear to have no light on it.

What I have tried so far is making two transitions from Entry State, but no matter what conditions I put in there (tried triggers, booleans), it automatically switches to the default state NoLight. Then, I have created a shortcut transition from NoLight to Burning State that uses a Trigger. I set this trigger in my script`s Start() function, but it does not seem to work either. Instead it is taking a long root. From NoLight it goes to LightsOn, which is gradually bringing up the light and the flame appears slowly, and only then to Burning. I have checked the order of transitions for NoLight State. My shortcut transition to Burning has higher order than transition to LightsOn, but it still chooses this longer route to get to burning state.

What am I doing wrong here? Any help is greatly appreciated.

torchanimator.jpg (60.0 kB)
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

4 Replies

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by vovo801 · Jun 16, 2015 at 05:44 AM

For people having the same problem. The SOLUTION that worked for me - in settings of my transition from NoLight to Burning state there is an option "Has Exit Time". It has to be unchecked. After unchecking this, everything works properly.

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 AubryStrawberry · Sep 06, 2015 at 03:26 PM 1
Share

Did you ever discover a solution without using the workaround? I am having the same issue where transitions from Entry are see$$anonymous$$gly ignored, always opting for the default transition.

avatar image vovo801 · Sep 09, 2015 at 07:29 PM -1
Share

I am now using Unity 5, and there is even no such option now to choose Has Exit Time fot transition from entry state. But it is still working properly. In the setup i have in the example transition to NoLight is default and has no conditions on it. Transition to BurningOnWallFlicker has a condition trigger called ShortcutLit. Then in my start function i do this:

 void Start () 
     {
         if (HasLight) {
             anim.SetTrigger ("ShortcutLit");
             anim.SetBool ("Lit", true);
         }
     }

I remember having an issue when i tried to do this in Awake, it wont work then.

avatar image mottatta · Sep 12, 2017 at 09:01 AM 0
Share

It worked for me! Thanks man! ;)

avatar image
1

Answer by Eluem · Oct 16, 2015 at 10:33 PM

Has anyone figured out how to get this to work correctly?

According to this: http://blogs.unity3d.com/2015/02/11/having-fun-with-the-new-mecanim-features/

We should be able to use this feature trivially, yet I can't get it to work at all in my project...

Edit (Solved?): I think I figured out the problem.

I don't know exactly the correct terminology to use for this.. but basically what seems to be happening (for me at least) is that if I attempt to rely on the multiple transitions from the Entry node when the specific statemachine has been entered automatically, it directly selects the default animation and ignores the conditions on the Entry node. However, if you enter a sub-statemachine using a transition (up or down), it works fine. I'm not sure if this makes sense, but it seems to be working for me.

In my current game I wanted to use an animator with multiple sub-statemachines for each stance (weapon type) a player can use. I have an int parameter for the stance and I want to be able to switch between them. Originally I tried to use the conditional transitions from the Entry node to choose which stance to enter and then I'd use the Exit node on each of my stances below when the stance changes so it'd go back to the Entry.

This did not work since whenever you first start your animator up OR whenever you exit up into the top layer using the Exit node, it jumps DIRECTLY to the default state instead of analyzing the conditions on the Entry node.

However, if you instead use transitions targeting the layer above directly (less clean since it can't be as reusable.. but for my purposes it's fine), it will correctly target the next stance because it will hit the Entry Node correctly. I still have an issue with the INITIAL start up. It still goes directly to the default. To fix that, I'm going to set the default state to something in a sub node of some T-Pose-esk stance that will immediately jump back out to the base layer. This might cause a slight character flicker when a character is first created, but it's a decent work around for now.

TL;DR I'm almost certain that this is a bug. The entry node is skipped/ignored and the animator jumps DIRECTLY to the default state UNLESS you are ENTERING the state machine from another state machine. It's possible that this is the intended behavior, but it seems strange. At the very least, I'd like to have an option to change the behavior.

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
-1

Answer by riseriyo · Dec 14, 2016 at 03:21 PM

Using Unity 5.5. You can change the default transition for the Entry State by right-clicking on Entry and choosing/highlighting, Set StateMachine Default State. Then drag the arrow-line to the State that you want as the new Default.

BTW, I'm using a Mac so if you are a Windows user or a Linux user, use the commands that are equivalent. I don't know them off the top of my head.

Hope this helps.

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 IgorAherne · Feb 24, 2017 at 11:18 PM

Use a StateMachineBehavior, and OnStateMachineEnter() inside of it to CrossFade() into the needed state. Otherwise a default one will be chosen

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

6 People are following this question.

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

Related Questions

Animator dont transition to self or any sub state 2 Answers

Identifying a transition to self in StateMachineBehaviour 0 Answers

how to make multiple transition from one state? 1 Answer

How to make a transition animation, intermediate animation between two main states 0 Answers

Animator set of states 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