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:
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:
What to do? Any help is appreciated.
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: