Search Unity

How to create custom binding type and fire values via script

Discussion in 'Input System' started by Deadcow_, Dec 24, 2019.

  1. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    135
    I'm trying to create "Movement" action. Movement should be controlled with gamepad stick and via mouse - based on pointer position relative to player position (in top-down game to run towards the pointer).

    I'd like to do it with two bindings, one is simply for left stick, and second one, as I imagine, should be custom binding, like some script with "Vector2 OnUpdate()" method to check this move direction relative to player position and probably check deadzone around the player (if he's close enough to the mouse he shouldn't run).
    This way I'll be able to process current Movement value with the same code.
    Like it is possible to process button press with actual button press or with OnScreenButton...

    Is it have any sense?
    For now I figured out how to create custom InputDevice, but did not found the way to fire input values with it.
    I've got an idea to use OnScreenControl as a base class to fill in values for my InputDevice, but it should be a better way to do this...
     
    Last edited: Dec 25, 2019