Chapter 6
159
/** Otherwise check to see if we have been
tracking the pending lock long enough */
else if (PendingLockedTarget == BestTarget
&& WorldInfo.TimeSeconds = PendingLockedTargetTime )
{
AdjustLockTarget(PendingLockedTarget);
LastLockedOnTime = WorldInfo.TimeSeconds;
PendingLockedTarget = None;
PendingLockedTargetTime = 0.0;
}
}
}
Otherwise, if we can't lock onto our current or our pending target, then cancel
our current target, along with our pending target.
else
{
if ( LockedTarget != None&&((WorldInfo.TimeSeconds -
LastLockedOnTime > LockTolerance)||
!CanLockOnTo(LockedTarget)) )
{
// Invalidate the current locked Target
AdjustLockTarget(None);
}
// Next attempt to invalidate the Pending Target
if ( PendingLockedTarget != None&&
((WorldInfo.TimeSeconds - LastValidTargetTime >
LockTolerance)||!CanLockOnTo(PendingLockedTarget)) )
{
// We are not pending another target to lock onto
PendingLockedTarget = None;
}
}
}
That was quite a bit to digest. Don't worry, because the functions from here on
out are pretty simple and straightforward.
- As with most other classes, we need a Tick() function to check for something
in each frame. Here, we'll be checking whether or not we have a target locked in
each frame, as well as setting our LastTargetLockCheckTime to the number
of seconds passed during game-time.
/****
- Check target locking with each update
****/
event Tick( Float DeltaTime )