Before enhanced input you could create custom inputs that’d work across any moveable actor in a scene it was assigned to. So for example, I can create a MoveCubeUp function for a floating cube actor in my level that will move when the player presses the assigned key. There is no character or pawn involved at all.
My question is as follows: Is it possible to use Enhanced Input with actors that are NOT characters/pawns?
All the tutorials and coding examples so far assume you want to control the player pawn but can I not just port over the Input Mapping Context to say an external camera or my floating cube example?
Seeing all these examples assuming you’d want to be moving your pawn around makes me think that they made this system for only one use-case in mind rather than any actor you’d want. Or maybe I’m overthinking it and got it all mixed up?
The only places input events will fire are on widgets (in world or not), controlled pawns, and controllers.
This is pretty much the case. There is a way to allow it, but I’m not telling cause you shouldn’t use it. All your input should be in these three places- you shouldn’t ever have input directly on a cube. It’s general bad practice to have input in random classes.
If you need an external camera, put that external camera in a pawn and control that pawn.
If you need to do something with a floating cube once (ie an ability that throws it), that should all be done in the player character. If it’s the target of a crane minigame or something, then it should be a pawn.
All the actual events should be in the previously mentioned three places, but it’s perfectly fine to trigger events in other places when those events are triggered.
I figured it out in the end and yeah I was over thinking it (and tired).
All AActors still contain a generic InputComponent that is used when you’ve set the actor to enable player input. If you’ve set your project to use EnhancedInput, this input component will then carry on the enhance input commands like any pawn does. You can test this by casting it to enhanced input or printing out its name to see if it is being used that way or not.
So to do what I want for my cube example I’d have to override the EnableInput function to then begin doing my usual BindActions just like before. The only difference is that I’d have to create the DataAsset containing actions separate from the cube’s own class.
The main thing I was hung up on was how every tutorial assumes that you want to do this solely on a pawn which, when possessed by a player controller, calls the functions needed to bind actions (in which it calls SetupPlayerInputComponent).
It’s general bad practice to have input in random classes.
I should’ve clarified that my use case does NOT pertain to gaming or the typical pawn/controller setup, but actors used in scenes for things like virtual production. Indeed it is bad practice to do anything that I am doing in any typical game setup where every player action should be handled by a Player Controller and a good state machine but nDisplay and other camera types like it do not at all play nice when things are being controlled by a 6DOF tracker.
Thanks for your reply but a real answer should be given and not advice.
There are tags that you should use to mark your question.
This seems like it would go under Virtual Production, Cinematics, or TV.
Advice is the real answer.
If someone’s asking how they can quickly add 100 sequential variables to their player, you don’t give them a python script- you tell them about arrays.