Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

StateMachineBehaviour OnStateMachineEnter/Exit confused

Discussion in 'Animation' started by HaiYangLiu, Jan 5, 2019.

  1. HaiYangLiu

    HaiYangLiu

    Joined:
    Mar 28, 2017
    Posts:
    4
    Hi,
    I'm trying to use StateMachineBehaviours to do Animation Logic.But there are something that puzzle me.I know two ways to add SMD which is my custom StateMachineBehaviour to mecanim.

    a)add to a state. It's work fine with the five functions OnStateXXX.

    b) add to a layer.
    when enter play mode,every state in this layer will be added a SMD by clone.But the OnStateMachineEnter function never be called.I think the Layer is a StateMachine and when enter by the Entry Node it will be called but not.I Try to do this with a sub-StateMachine in this Layer and add a dummy animation before sub-StateMachine work fine,So the two function just work in sub-Machine?

    I notice that unity blog is also use a sub-stateMachine.
    https://blogs.unity3d.com/cn/2015/02/11/having-fun-with-the-new-mecanim-features/

    I found this forum talk about this:
    https://forum.unity.com/threads/sta...machineenter-exit-broken-in-5-0-2-5-1.331466/

    the below one is about ‘must use a dummy animaton’:
    https://www.reddit.com/r/Unity3D/duplicates/43ktb5/onstatemachineenter_not_triggering/

    Can someone help me? Thanks!!!
     

    Attached Files: