Hello, I have a problem. I've recently found out about an UnrealEngine 1.0 problem. I can't seem to change the ViewRotation of a player, who has just been teleported and his feet are nearly touching the ground at that time. It's totally strange, I can't find what's wrong.
This function gets the actor the enters the in-stargate (and is called in the out-stargate) and it processes the location, rotation etc. variables so that the direction of the exit is correct. But after the actor is teleported and after the teleport it's near the ground, the viewrotation doesn't change (so if I jump inside the Stargate it all works perfectly, but when I walk inside the viewrotation won't change). I would appreciate any help. ;-)
Code:
function bool ReceivedObject(actor Other, vector offset, vector Vel, vector Acc, vector Dir, int Roll)
{
local pawn POther;
local rotator NewRot, TempRot;
local vector TempDir, Loc;
local nRestoreCol R;
Current.Received++;
offset*=GateSize;
if(FindTeleLoc(Other, offset)) //searching for an alternative offset, if the one specified is blocked
{
Log("Found valid location");
POther=Pawn(Other);
R=CtrlMut.StoreCollision(Other); //disabling Other's collision and keeping it for restoring after several ticks - prevents crashes and telefragging
if(R==None)
{
Log("R==None");
DestroyObject(Other);
return false;
}
offset.X+=1; // just in case
Loc=Location+(offset>>EmitterRotation); //the teleport location
if(Other.Base!=None) //if the actors' on the floor (walking, for instance) - let it fall out of the other stargate
{
Other.SetBase(None);
Other.SetPhysics(PHYS_Falling);
}
if(POther!=None)
{
//just some player viewrotation tweaks:
NewRot=EmitterRotation;
NewRot.Pitch=0;
TempRot.Pitch=EmitterRotation.Pitch;
TempRot.Yaw=0;
TempRot.Roll=0;
TempDir=Dir>>TempRot;
if(TempDir dot (Dir*vect(1,1,0))<=0)
{
if((TempRot.Pitch>0)==(Dir.X>0))
{
TempRot.Pitch=16384;
}else{
TempRot.Pitch=49152;
}
}else{
TempRot.Pitch=Rotator(TempDir).Pitch;
}
NewRot=Rotator(Dir>>NewRot);
NewRot.Pitch=FixViewPitch(TempRot.Pitch);
NewRot.Roll=Roll+EmitterRotation.Roll;
TempRot=NewRot;
TempRot.Pitch=0;
TempRot.Roll=0;
POther.ViewRotation=NewRot;
Other.SetRotation(TempRot);
}else{
NewRot=Rotator(Dir>>EmitterRotation);
NewRot.Roll=Roll+EmitterRotation.Roll;
Other.SetRotation(NewRot);
}
if(Other.SetLocation(Loc))
{
Vel.X=FMax(Vel.X, 128);
Other.Velocity=Vel>>EmitterRotation;
Other.Acceleration=Acc>>EmitterRotation;
CtrlMut.Replicate(Other, Other.Location, NewRot, Other.Velocity, Other.Acceleration, Other.Physics, Other.Base); //this function just replicates a function to all clients, setting the client-side variables to the ones on the server - it's for the replication torn-off actors like projectiles, also for the ViewRotation replication of the player
Log("Successful teleport of"@Other);
SetSound(2, 4); //the sound number 2 is to be played after 4 ticks, so that the player exiting the Stargate can hear it
Current.Rematerialized++;
return true;
}
Log("Location found, but still couldn't teleport! This isn't supposed to happen, ever!");
R.Destroy();
}
Log("Valid loc not found");
DestroyObject(Other); //actors get destroyed, players die and their corpses are destroyed
return false;
}
This function gets the actor the enters the in-stargate (and is called in the out-stargate) and it processes the location, rotation etc. variables so that the direction of the exit is correct. But after the actor is teleported and after the teleport it's near the ground, the viewrotation doesn't change (so if I jump inside the Stargate it all works perfectly, but when I walk inside the viewrotation won't change). I would appreciate any help. ;-)