• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code How to intercept the 'UseKey'

Hello, how should one intercept the Use or Interact key these days in code?

I have a class which extends ROPlayerInput but after studying that class, I can't see a way to perform my own function if the UseKey is pressed down.

Can anyone point me in the right direction please?

Thanks.

I'd suggest looking in ROPlayerController and seeing if you can override a function there.
 
Upvote 0
Fixed it.

I have my player input class
Code:
class FTPlayerInput extends ROPlayerInput;

function bool InputKey(int ControllerId, name KeyName, EInputEvent IEvent, float AmountDepressed, optional bool bGamepad)
{
	local string keyPressed;
	keyPressed = string(KeyName);

	`Log(">>> DEBUG : InputKey"$KeyName, , 'FTPlayerInput');

	if (IEvent == IE_Pressed)
	{
            // put my code here
        }

DefaultProperties
{
	OnReceivedNativeInputKey=InputKey
}

And then hook up that class inside my player controller class default props:
Code:
DefaultProperties
{
    InputClass=class'FTPlayerInput'
}
 
Upvote 0