UE1 - UT Smooth player velocity

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

megausernameotp

New Member
Feb 6, 2010
2
0
0
I'd like to make ClientAdjustPosition not being updated to server when my character (Player) has Physics Phys_Flying, so moving look smooth (ignores the lag).

For now using this:
Code:
class VelPlayer expands PlayerPawn;

var float aNewLocX, aNewLocY, aNewLocZ;
var float aNewVelX, aNewVelY, aNewVelZ;
var bool bCheckFlyPos;

replication
{
	reliable if ( Role==ROLE_Authority )
		bCheckFlyPos,CheckLocAndVel,aNewLocX,aNewLocY,aNewLocZ,aNewVelX,aNewVelY,aNewVelZ;
}

function ClientAdjustPosition
(
	float TimeStamp,
	name newState,
	EPhysics newPhysics,
	float NewLocX,
	float NewLocY,
	float NewLocZ,
	float NewVelX,
	float NewVelY,
	float NewVelZ,
	Actor NewBase
)
{
	local Decoration Carried;
	local vector OldLoc, NewLocation;
	
	if(Physics==Phys_Flying) 
	{
		bCheckFlyPos = True;
		return;
	}
	if(bCheckFlyPos)
	{
		NewLocX = aNewLocX;
		NewLocY = aNewLocY;
		NewLocZ = aNewLocZ;
		NewVelX = aNewVelX;
		NewVelY = aNewVelY;
		NewVelZ = aNewVelZ;
	
		bCheckFlyPos = False;
	}
	//ClientMessage("Client "$Role$" adjust "$self$" stamp "$TimeStamp$" location "$Location$" new location "$NewLocation$" CurrentTimeStamp "$CurrentTimeStamp);
	if ( CurrentTimeStamp > TimeStamp )
		return;
		
	CurrentTimeStamp = TimeStamp;

	NewLocation.X = NewLocX;
	NewLocation.Y = NewLocY;
	NewLocation.Z = NewLocZ;
	Velocity.X = NewVelX;
	Velocity.Y = NewVelY;
	Velocity.Z = NewVelZ;

	SetBase(NewBase);
	if ( Mover(NewBase) != None )
		NewLocation += NewBase.Location;

	//log("Client "$Role$" adjust "$self$" stamp "$TimeStamp$" location "$Location$" new location "$NewLocation);
	Carried = CarriedDecoration;
	OldLoc = Location;
	SetLocation(NewLocation);

	if ( Carried != None )
	{
		CarriedDecoration = Carried;
		CarriedDecoration.SetLocation(NewLocation + CarriedDecoration.Location - OldLoc);
		CarriedDecoration.SetPhysics(PHYS_None);
		CarriedDecoration.SetBase(self);
	}
	SetPhysics(newPhysics);
	//FIXME - don't do this state update if client dead???
	if ( !IsInState(newState) )
		GotoState(newState);

	bUpdatePosition = true;
}
simulated event PlayerTick(float DeltaTime)
{
	CheckLocAndVel();
	if ( bUpdatePosition )
		ClientUpdatePosition();
}
simulated function CheckLocAndVel()
{
	aNewLocX = Location.X;
	aNewLocY = Location.Y;
	aNewLocZ = Location.Z;
	aNewVelX = Velocity.X;
	aNewVelY = Velocity.Y;
	aNewVelZ = Velocity.Z;
}
state PlayerWalking
{
	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}
state PlayerSwimming
{
	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}
state PlayerFlying
{
	ignores SeePlayer, HearNoise, Bump;

	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}
state PlayerWaiting
{
	ignores SeePlayer, HearNoise, Bump, TakeDamage, Died;

	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}
state PlayerSpectating
{
	ignores SeePlayer, HearNoise, Bump, TakeDamage, Died;

	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}
state PlayerWaking
{
	ignores SeePlayer, HearNoise, KilledBy, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, SwitchWeapon, Falling;

	event PlayerTick( float DeltaTime )
	{
		Global.PlayerTick(deltatime);
		PlayerMove(DeltaTime);
	}
}

But when VelPlayer physics suddenly go to Phys_Falling or any other physics, it "bounces" to some very wierd location very far. Thats the problem i'm asking for.

To test it:
Code:
class Testactor expands Actor;

var PlayerPawn p;

replication
{
	reliable if(role==role_authority)
		p;
}
function Touch(actor Other)
{
	if(PlayerPawn(Other)!=None)
		p=PlayerPawn(Other);
}
simulated function Tick(float deltatime)
{
	if(p!=None)
	{
		p.SetPhysics(Phys_Flying);
		p.AirSpeed = 1000;
		p.Velocity = Vector(Rotation)*600;
	}
}
simulated function Destroyed()
{
	p.SetPhysics(Phys_Falling);
}
defaultproperties
{
	LifeSpan=10
	RotationRate=(Pitch=4000,Roll=4000,Yaw=4000)
	bFixedRotationDir=True
	Physics=Phys_Rotating;
	bCollideActors=True
	remoterole=role_simulatedproxy
}

What to do? Any help is appreciated.
 
Last edited:

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
Could you summarize what changes you've made to the Pawn? It would make it faster to understand what you're attempting to do and what might be happening.

P.S: Physics is handled by native code.
 
Last edited:

megausernameotp

New Member
Feb 6, 2010
2
0
0
Could you summarize what changes you've made to the Pawn? It would make it faster to understand what you're attempting to do and what might be happening.

P.S: Physics is handled by native code.

I just like to make velocity look perfect/smooth in server. For now when it lags or server has low NetServerMaxTickRate view bounces in a crappy way.
(The velocity that TestActor does).

.:..: suggested me to edit ClientUpdatePosition()

For now it look like:
Code:
function ClientUpdatePosition()
{
	local SavedMove CurrentMove;
	local int realbRun, realbDuck;
	local bool bRealJump;
	local vector RealVelocity;

	bUpdatePosition = false;
	realbRun= bRun;
	realbDuck = bDuck;
	bRealJump = bPressedJump;
	RealVelocity = Velocity;
	CurrentMove = SavedMoves;
	while ( CurrentMove != None )
	{
		if ( CurrentMove.TimeStamp <= CurrentTimeStamp )
		{
			SavedMoves = CurrentMove.NextMove;
			CurrentMove.NextMove = FreeMoves;
			FreeMoves = CurrentMove;
			FreeMoves.Clear();
			CurrentMove = SavedMoves;
		}
		else
		{
			Velocity = Vector(ViewRotation)*600.f; // Its the velocity I wish to add.
			MoveAutonomous(CurrentMove.Delta, CurrentMove.bRun, CurrentMove.bDuck, CurrentMove.bPressedJump, CurrentMove.DodgeMove, CurrentMove.Acceleration, rot(0,0,0));
			CurrentMove = CurrentMove.NextMove;
		}
	}
	bDuck = realbDuck;
	bRun = realbRun;
	bPressedJump = bRealJump;
	Velocity = RealVelocity;
	//log("Client adjusted "$self$" stamp "$CurrentTimeStamp$" location "$Location$" dodge "$DodgeDir);
}
View still looked crappy :(

Also he said me to somehow make savedmove know what ViewRotation is, but i couldn't figure out how to make it so.
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
I just like to make velocity look perfect/smooth in server. For now when it lags or server has low NetServerMaxTickRate view bounces in a crappy way.
(The velocity that TestActor does).

That explains what you want to do. What would be nice to know is what you are changing to make this happen. Note that some people don't have hours to spend thinking about a problem.

As far as I understand things, you'd like to interpolate player movement (two player positions => calculate middle position). But I could be wrong.
 
Last edited: