UE3 - UDK Adding custom Interaction

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Shadow_knight

Carpe diem!
Jan 29, 2008
51
0
6
Prague
Hi.

I want to add custom Interaction class to handle player input in UDK and to draw some information on Canvas.

The InteractionMaster class from UT2004 seems to dissapear. How to add custom interaction now? I've something really straightforward via mutator, but it didn't work (as I expected :) ).

Code:
function NotifyLogin(Controller NewPlayer)
{   
	local PlayerController PC;
	if (NewPlayer.IsA('PlayerController')) {
		`log("Trying to add interaction");
		PC = PlayerController(NewPlayer);
		PC.Interactions[PC.Interactions.Length] = new(PC) class'GBInteraction';		
	}
	super.NotifyLogin(NewPlayer);
}

Is it a problem I don't have Local PlayerController? There is also LocalPlayer class with GameViewportClient class that has some methods that handles Interactions (and even some custom interactions). However I couldn't find where to set those Custom interactions in GameViewportClient and I am also not sure if this is the place where to do it.
So far I was also not able to access LocalPlayer class within mutator (it is possible I am doing some silly mistake).

Bets,
sk
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Like in UT200x, Interactions need to be added clientsidely. Thus the *Login() functions in mutators or gameinfos are pointless for anything other than offline-only games.

To properly add an Interaction, you need to call code clientsidely. You're working with the UDK, so I guess you're somehow creating your own gametype. In UT3 Jailbreak we used our HUD to create an Interaction for capturing key presses:
Code:
simulated function PostBeginPlay()
{
	local int iInput;
	// ...
	
	Super.PostBeginPlay();
	
	KeyCaptureInteraction = new(PlayerOwner) class'Interaction';
	KeyCaptureInteraction.OnReceivedNativeInputKey = ReceivedNativeInputKey;
	
	// insert before input interaction to capture movement keys, if necessary
	iInput = PlayerOwner.Interactions.Find(PlayerOwner.PlayerInput);
	PlayerOwner.Interactions.InsertItem(Max(iInput, 0), KeyCaptureInteraction);
	
	// ...
}

/**
Checks for registered keys or commands.
*/
function bool ReceivedNativeInputKey(int ControllerId, name Key, EInputEvent EventType, float AmountDepressed, bool bGamepad)
{
	// ...
}
Note that we don't use a custom Interaction subclass, but just grab key events via the OnReceivedNativeInputKey delegate. We don't need it to draw on the screen either - that's the HUD's job.
 

Shadow_knight

Carpe diem!
Jan 29, 2008
51
0
6
Prague
So the only thing I need is to insert the interaction in PlayerController interactions (on client) to make it work - this is what I needed to know.

Thanks for the info.

sk
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
In our case we wanted to override certain built-in exec functions we didn't have access to (we don't subclass the PlayerController), so we needed to insert our Interaction before the input interaction. Usually you'd probably just add it at the end of the list.