Time for action – Making the TestEnemies move
Since TestEnemy
is only a temporary class, we won't get too complex with its behavior. We'll just use some simple math and adapt some of our camera movement code to get them working.
The first thing we need to do in
TestEnemy.uc
is get a reference to theAwesomePawn
that's running around shooting at us. Since the player doesn't spawn right away, we can't do this inPostBeginPlay
. Instead, we're going to constantly check if we have a reference, and if not try to find one until we do.Let's add a Pawn variable to our
TestEnemy
class:var Pawn Enemy;
Now let's see if we can get a reference to the player after they've spawned. Let's use the
Tick
function for this:function Tick(float DeltaTime) { local AwesomePlayerController PC; if(Enemy == none) { foreach LocalPlayerControllers(class'AwesomePlayerController', PC) { if(PC.Pawn != none) { Enemy = PC.Pawn; `log("My...