Time for action – Using vectors
Since we already know that an actor's Location is a vector, let's play around with our AwesomeActor's location.
First we'll declare a vector of our own at the top of our class.
var vector LocationOffset;
Vectors have their X, Y, and Z values set to 0.0 by default. We'll give ours a new value and add that to our actor's current location in our
PostBeginPlay
function.function PostBeginPlay() { LocationOffset.Z = 64.0; SetLocation(Location + LocationOffset); }
When used as a location, the Z float inside a vector represents the up and down axis. Making the values of Z greater means moving it up, lower or more negative means moving it down. In our example we're going to move the actor up 64 units. We use the function in the second line,
SetLocation
, to tell the game to move ourAwesomeActor
. Since we already know its current location with the Location variable, we just add ourLocationOffset
to move it up 64 units.There's one thing we need to do before we...