NicePack/sources/Weapons/Playable/Explosives/SeekerSix/NiceSeekerSixSeekingRocketProjectile.uc

42 lines
1.1 KiB
Ucode

class NiceSeekerSixSeekingRocketProjectile extends NiceSeekerSixRocketProjectile;
var Actor Seeking;
var vector InitialDir;
replication
{
reliable if( bNetInitial && (Role==ROLE_Authority) )
Seeking, InitialDir;
}
simulated function Timer()
{
local vector ForceDir;
local float VelMag;
if ( InitialDir == vect(0,0,0) )
InitialDir = Normal(Velocity);
Acceleration = vect(0,0,0);
Super.Timer();
if ( (Seeking != none) && (Seeking != Instigator) )
{
// Do normal guidance to target.
ForceDir = Normal(Seeking.Location - Location);
if( (ForceDir Dot InitialDir) > 0 )
{
VelMag = VSize(Velocity);
// Increase the multiplier that is currently 0.8 to make the rocket track better if you need to
ForceDir = Normal(ForceDir * 0.8 * VelMag + Velocity);
Velocity = VelMag * ForceDir;
Acceleration += 5 * ForceDir;
}
// Update rocket so it faces in the direction its going.
SetRotation(rotator(Velocity));
}
}
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
SetTimer(0.1, true);
}
defaultproperties
{
}