Due to this issue being incredibly confusing I require help, basically I want to set the controllers viewtarget to a pawn if they are looking at said pawn when they are dead but currently it doesn't work, as far as I can tell SetViewTraget and ClientSetViewTarget are being called
Here is the code to get a better look
Here is the code to get a better look
Code:
replication
{
reliable if( Role < ROLE_Authority )
PossessZed;
}
state Spectating
{
function BeginState()
{
Super.BeginState();
if( VSGame(Level.Game)!=None && VSGame(Level.Game).ShouldGoHunt() && !PlayerReplicationInfo.bOnlySpectator )
GoToState('PreySpec');
}
}
state PreySpec extends BaseSpectating
{
ignores SwitchWeapon, RestartLevel, ClientRestart, Suicide, ThrowWeapon, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange;
function PossessZed()
{
local Pawn P;
local vector HL,HN;
local bool bWasSpec;
if( NextPossessTimer>Level.TimeSeconds )
return;
NextPossessTimer = Level.TimeSeconds+0.4f;
foreach TraceActors(Class'Pawn',P,HL,HN,Location+vector(Rotation)*1000.f,Location)
{
if( P != none && P.Health>0 )
{
if( Monster(P)!=None )
{
VSGame(Level.Game).PlayerPossess(Self,Monster(P));
}
else if( KFPawn(P)!=None )
{
bWasSpec = !bBehindView && ViewTarget != Pawn && ViewTarget != self;
SetViewTarget(P);
ViewTargetChanged();
ClientSetViewTarget(P);
if ( ViewTarget == self || bWasSpec )
bBehindView = false;
else
bBehindView = true; //bChaseCam;
ClientSetBehindView(bBehindView);
}
return;
}
}
ClientMessage("Can't possess: You must aim at the specimen to possess.");
}
exec function Fire( optional float F )
{
if( NextPossessTimer<Level.TimeSeconds )
{
PossessZed();
NextPossessTimer = Level.TimeSeconds+0.5f;
}
}
exec function AltFire( optional float F )
{
if( ViewTarget != self )
ServerViewSelf();
}
function Timer()
{
bFrozen = false;
}
function BeginState()
{
if ( Pawn != None )
{
SetLocation(Pawn.Location);
UnPossess();
}
bCollideWorld = true;
CameraDist = Default.CameraDist;
}
function EndState()
{
PlayerReplicationInfo.bIsSpectator = false;
bCollideWorld = false;
}
function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
{
bBehindView = false;
if( ViewTarget!=Self )
SetViewTarget(Self);
Acceleration = NewAccel;
MoveSmooth(SpectateSpeed * Normal(Acceleration) * DeltaTime);
}
}
Last edited by a moderator: