I’m learning Unity (in 2d mode only for now), and I have set up a new InputSystem for my default Player object (the ‘main character’) and attached it accordingly. I’ve left it using the Send Messages behaviour if that matters.
However, now I want to listen to player inputs on a completely different object (not UI). If I try listening to ‘OnFire’ or ‘OnMove’ in an object that doesn’t have the Player Input component on it, nothing happens, which I’m not too surprised at. What I’m not sure about is, what is the best/proper way to make inputs be heard in a completely different object?
Use Unity Events: Unity - Manual: UnityEvents
Alternatively you can use C# Actions or delegates.
Unity Events are more convenient if you want to setup the event-registration in the Inspector.
I did find another approach; I made a separate InputMap in the input settings, specifically for that object, and applied another Player Input component to it, selecting that particular map. Is that a valid approach? Or is it not a good idea to have multiple objects in a scene with Player Input components on them?
I know it’s an old topic BUT, i had the same problem and the solution I found is just to change the behavior of the player input to "broadcast messages " instead of send. With this you can access the “OnMove” method in the children of your Object.