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

Idea for state machine feature with universal application

Discussion in 'Editor & General Support' started by ReviveMusic, Oct 29, 2019.

  1. ReviveMusic

    ReviveMusic

    Joined:
    Sep 16, 2018
    Posts:
    1
    Hi,
    I intended to repurpose the animator state machine for a progression system as described here:
    https://medium.com/the-unity-develo...ow-to-repurpose-unity-s-animator-7c6c421e5785

    It would be great if I could just fire some kind of event to a gameobject in a scene when the statemachine enters a state.

    The problem is, that you can't have references to scene gameobjects in a class derived from StateMachineBehaviour (at least not in inspector) Therefore the whole UnityEventSystem is useless in this context.
    Now I do have an inelegant solution by creating a reference to the gameobject on a monobehaviour and invoke the methods by reflection. But I think there is more to this than just a fun development problem.
    Let's asume this would work in the Unity Editor by default. That you could just reference a scene gameobject in the eventsystem on a statemachinebehavoiur. Then you could implement some kind of System to set triggers based on position of gameobjects or player walking into triggers, etc.
    This would have universal application, because you could just break down any multi state mechanic you want to implement into states and fire events to the involved gameobjects without any custom scripts.

    Hope you concider my idea ;)