Home Unreal Engine

UDK: Increasing strafe speed

So basically I'm making a game which has two players in the same view port, and both players are forced forward automatically like in temple run. because of the camera its important that both players remain in the same area, preferably running at exactly at the same speed the whole time, but obviously when strafing you don't travel the same distance that you would if you just go straight forward. Hopefully if both players have to strafe an equal amount this should balance their distance a bit but id still like reduce the issue.

i came across a bit of code on the EPIC forums, but I'm no great shakes at script and I've no idea how to implement it without getting errors. here is the code:

local float strafeMultiplier;
strafeMultiplier = Abs(Vector(PlayerController.Rotation) dot Normal(Acceleration)) + 0.25f;
Clamp(strafeMultiplier, 0.0f, 1.0f);
Pawn.Acceleration = NewAccel * strafeMultiplier;

i've got as far as working out this probably goes in PlayerController but exactly where does it go D:.

Here is the rest of my code for this bit of script ATM, as i have changed a few things already:

class NutPlayerController extends UDKPlayerController;
state PlayerWalking
{
function PlayerMove( float DeltaTime )
{
local vector X,Y,Z, NewAccel;
local eDoubleClickDir DoubleClickMove;
local rotator OldRotation;
local bool bSaveJump;

if( Pawn == None )
{
GotoState('Dead');
}
else
{
GetAxes(Pawn.Rotation,X,Y,Z);

// Update acceleration.
//NewAccel = PlayerInput.aForward*X + PlayerInput.aStrafe*Y;
NewAccel = X + PlayerInput.aStrafe*Y + Abs(PlayerInput.aStrafe)*X;
NewAccel.Z = 0;
NewAccel = Pawn.AccelRate * Normal(NewAccel);

if (IsLocalPlayerController())
{
AdjustPlayerWalkingMoveAccel(NewAccel);
}

DoubleClickMove = PlayerInput.CheckForDoubleClickMove( DeltaTime/WorldInfo.TimeDilation );

// Update rotation.
OldRotation = Rotation;
UpdateRotation( DeltaTime );
bDoubleJump = false;

if( bPressedJump && Pawn.CannotJumpNow() )
{
bSaveJump = true;
bPressedJump = false;
}
else
{
bSaveJump = false;
}

if( Role < ROLE_Authority ) // then save this move and replicate it
{
ReplicateMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
}
else
{
ProcessMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
}
bPressedJump = bSaveJump;
}
}
}

defaultproperties
{
Name="Default__NutPlayerController"
}
Sign In or Register to comment.