I need help with SetViewTraget, so far no matter what I try nothing works I've tried replicated the function from the Client to Server like said but nothing works
Here is the code, PossesZed is on the server and is called by the client I'm unsure but I think here SpectatePlayer needs to be from the server to client
Here is the code, PossesZed is on the server and is called by the client I'm unsure but I think here SpectatePlayer needs to be from the server to client
Code:
state PreySpec extends BaseSpectating
{
ignores SwitchWeapon, RestartLevel, ClientRestart, Suicide, ThrowWeapon, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange;
function SpectatePlayer(Pawn Target)
{
local bool bWasSpec;
bWasSpec = !bBehindView && ViewTarget != Pawn && ViewTarget != self;
if( Target != none )
{
SetViewTarget(Target);
ClientSetViewTarget(Target);
if ( ViewTarget == self || bWasSpec )
bBehindView = false;
else
bBehindView = true;
ClientSetBehindView(bBehindView);
}
}
function PossessZed()
{
local vector HitLocation, HitNormal, TraceEnd, TraceStart;
local rotator R;
local Actor A;
local KFMonster M;
if( NextPossessTimer>Level.TimeSeconds )
return;
NextPossessTimer = Level.TimeSeconds+0.4f;
PlayerCalcView(A, TraceStart, R);
TraceEnd = TraceStart + 1000 * Vector(R);
A = Trace(HitLocation, HitNormal, TraceEnd, TraceStart, true);
if ( KFHumanPawn(A) != none)
{
SpectatePlayer(KFHumanPawn(A));
return;
}
else if ( KFMonster(A) != none)
{
M = KFMonster(A);
if( M!=None && M.Health>0 )
{
if( ( M.IsA('ZombieBoss') || M.IsA('ZombieFleshpound') || M.IsA('FemaleFP') || M.IsA('ZombieScrake') || M.IsA('ZombieJason') ) && !ForrestPRI(PlayerReplicationInfo).IsVIP )
{
if( M.IsA('ZombieBoss') && bDisallowPatPossession )
{
ClientMessage("Can't possess: You suicided.");
return;
}
ClientMessage("Can't possess: You must be a VIP to possess this ZED.");
return;
}
VSGame(Level.Game).PlayerPossess(Self,M);
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);
}
}