how do players in unreal 'use' items?

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

pospi

New Member
Jun 30, 2003
298
0
0
www.pospi.cjb.net
Hey again everyone!

My mod idea depends in part on extending the way players 'use' items. Basically i need to pass a string from the player to the object when they use it in addition to whatever else happens. But, in order to do that i need to know if its possible and where i can find the code which controls what happens between a player and a useable object (such as maybe a vehicle, since im not aware of anything else in unreal which requires the 'use' key to be pressed).

Anyone know?
cheers
 

Shambler[sixpack]

New Member
May 3, 2001
564
0
0
Ireland
Visit site
Here is the code you can find in PlayerController.uc:
Code:
// The player wants to use something in the level.
exec function Use()
{
    ServerUse();
}

function ServerUse()
{
    local Actor A;
	local Vehicle DrivenVehicle, EntryVehicle, V;

	if ( Role < ROLE_Authority )
		return;

    if ( Level.Pauser == PlayerReplicationInfo )
    {
        SetPause(false);
        return;
    }

    if (Pawn == None || !Pawn.bCanUse)
        return;

	DrivenVehicle = Vehicle(Pawn);
	if( DrivenVehicle != None )
	{
		DrivenVehicle.KDriverLeave(false);
		return;
	}

    // Check for nearby vehicles
    ForEach Pawn.VisibleCollidingActors(class'Vehicle', V, VehicleCheckRadius)
    {
        // Found a vehicle within radius
        EntryVehicle = V.FindEntryVehicle(Pawn);
        if (EntryVehicle != None && EntryVehicle.TryToDrive(Pawn))
            return;
    }

    // Send the 'DoUse' event to each actor player is touching.
    ForEach Pawn.TouchingActors(class'Actor', A)
        A.UsedBy(Pawn);

	if ( Pawn.Base != None )
		Pawn.Base.UsedBy( Pawn );
}

So basicly if your actor is touching the pawn and you have your own special code in that actors UsedBy function then you can do what you want.