I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Legacy talk:Fire And Forget Self-Guided Missile

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Spectra: Here is my Simplified version, Probably took it from SeekingRocketProjClass:

class RSGProj extends RocketProj;
var Actor Seeking;
var vector InitialDir;
 
replication
{
    reliable if( bNetInitial && (Role==ROLE_Authority) )
        Seeking, InitialDir;
}
 
simulated function Timer()
{
    local vector ForceDir;
    local float VelMag;
    local Pawn P;
 
    if ( InitialDir == vect(0,0,0) )
        InitialDir = Normal(Velocity);
 
	Acceleration = vect(0,0,0);
        Super.Timer();
 
	if( (Seeking == None) || (Seeking == Instigator) )
	{
		foreach visiblecollidingactors(class'Pawn', P, 2500,, true) 
		{
                        //Find the Target of its own
			if(P != Instigator && P.Health >0) 
			{
                                // Ignore The Team Mates in Team Games
				if (Level.Game.bTeamGame && (Instigator.GetTeamNum() == P.GetTeamNum()))
					return;
				else
					Seeking = P;
			}
		}
	}
	else if ( (Seeking != None) && (Seeking != Instigator) ) 
    {
		// Do normal guidance to target.
		ForceDir = Normal(Seeking.Location - Location);
 
		if( (ForceDir Dot InitialDir) > 0 )
		{
			VelMag = VSize(Velocity);
 
			// track vehicles better
			if ( Seeking.Physics == PHYS_Karma )
				ForceDir = Normal(ForceDir * 2.0 * VelMag + Velocity);
			else
				ForceDir = Normal(ForceDir * 2.0 * VelMag + Velocity);
			Velocity =  VelMag * ForceDir;  
			Acceleration += 5 * ForceDir; 
		}
		// Update rocket so it faces in the direction its going.
		SetRotation(rotator(Velocity));
    }
}