RO2 How to intercept the 'UseKey'

  • 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/

LordGleedo

FNG / Fresh Meat
Jul 18, 2010
800
74
0
Bucks, England
www.theoldgitsarmy.com
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.
 
Last edited:

dibbler67

FNG / Fresh Meat
Sep 4, 2011
654
6
0
Texas
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.
 

LordGleedo

FNG / Fresh Meat
Jul 18, 2010
800
74
0
Bucks, England
www.theoldgitsarmy.com
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'
}