Search Unity

Set IInputAxisProvider without MonoBehaviour

Discussion in 'Cinemachine' started by manpower13, Oct 14, 2020.

  1. manpower13

    manpower13

    Joined:
    Dec 22, 2013
    Posts:
    140
    Hi there!

    I noticed we can provide our own IInputAxis, which is awesome and exactly what I need.

    I manage my input using ECS and components contain information about e.g. mouse position. Whole cinemachine is obviously using monobehaviours, but I'd like to control the input using my ecs components.

    While I could create a monobehaviour that queries the ecs components for its values and returns those in the

    public virtual float GetAxisValue(int axis)
    , it would be awesome if we could avoid the MB for this. Instead of only a
    public AxisState.IInputAxisProvider GetInputAxisProvider()
    inside
    CinemachineVirtualCameraBase
    , a
    SetInputAcisProvider(AxisState.IInputAxisProvider inputProvider)
    next to that would be all I need.
    This way, no Monobehaviours are involved considering the input provider and I could simply create my own implementation (whether that's a SystemBase that does these queries, or some other simpler class).

    Thanks! Let me know if I'm missing anything!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I'm not sure what would be the advantage of avoiding a MonoBehaviour here. Your behaviour would implement the GetAxisValue() method, as you say, and it would query something of yours - perhaps a singleton holding the input values. It would not need to implement an Update method, so being a MonoBehaviour would not incur a significant cost over and above that of the existing vcam.
     
  3. manpower13

    manpower13

    Joined:
    Dec 22, 2013
    Posts:
    140
    Thanks for the response :)
    That makes sense. I'll just use a MonoBehaviour then! It felt cleaner to have a non-monobehaviour way, but I guess in most cases people want to use MonoBehaviour here.
     
    Gregoryl likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    FYI we have a pure-DOTS version of Cinemachine in the works. No MonoBehaviours at all!
     
    manpower13 likes this.
  5. manpower13

    manpower13

    Joined:
    Dec 22, 2013
    Posts:
    140
    That sounds awesome! I guess there's no roadmap/release date yet? :p
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Nothing that I can share just yet
     
    manpower13 likes this.