[Question] Do key events work in class blueprint?

I am trying to create a blueprint for an actor that changes properties when you hold down the G key . I can a prototype of it to work in level blueprint , but when I try it as a class blueprint it will not register .

PlayerController, Pawns, and LevelScript have input enabled on them by default. For any other Actor you need to either call EnableInput on it or change the properties to AutoReceiveInput

You mean actor you controlling or actor you retrieving trough trace ? We need more details to work out solution you need.

In any case you Open your Character Blueprint (assuming you have one) and in EventGraph add “InputKey G”, then connect it the rest of graph that is responsible for action you want to trigger.

It is for a separate blueprint actor not a character blueprint.

I’m not sure if that is entirely possible within blueprint.

The actor you are trying to trigger input event at probably doesn’t support InputComponent so it can’t handle input events.

Moreover engine doesn’t have any way of knowing that you want to trigger event on such actor.

In you character blueprint add event logic, and then add your target actor as object. In your target object creat function that will do, whatever you want to do. Then call that fuction within your character blueprint. Instead of character blueprint you could probably do it in level blueprint.

Other option would be to create delegate and call it on input event from either character or level blueprint.

#Using Your Own Casted Controller

You can just make a blueprint for your own custom controller, making sure that your game mode is using this custom controller

and then you can make functions either in C++ or the BP of your custom player controller to tell you about various inputs

in C++ it is WasInputKeyJustPressed or IsInputKeyDown

in blueprints you can make your own functions that utilize the KeyisPressed or KeyisReleased to set a boolean or other var to tell you info about the keys you want

then

in the blueprint you want to get the input data for, you cast to your custom controller and access the variables/functions that will give you the info you want!

Controller is responsible for handling input for the player so this model is actually quite appropriate, though it might take a few extra steps.