I am making a 2D game. In this game I will have torches. When the scene starts there are two options for torches:
- They may be burning
- Or they may be not burning and have no flame on them.
Whether the torches should burn or not is determined by a public bool
ean 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:
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, bool
eans), 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()
method, 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.
Did you ever discover a solution without using the workaround? I am having the same issue where transitions from Entry are seemingly ignored, always opting for the default transition.
– KobI 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.
– EntireIt worked for me! Thanks man! ;)
– Beekeeping