Time for action – Using the default properties block
Let's start by defining some variables in our
AwesomeActor
class.var string MyName; var int NumberOfKittens; var float DistanceToGo;
In our default properties block, we can give these variables initial values. These are assigned before any of the code is run.
Defaultproperties { MyName="Rachel" NumberOfKittens=3 DistanceToGo=120.0 }
In our
PostBeginPlay
function, instead of changing the values we'll just log them to see the default properties in action.function PostBeginPlay() { 'log("MyName:" @ MyName); 'log("NumberOfKittens:" @ NumberOfKittens); 'log("DistanceToGo:" @ DistanceToGo); }
Now our class should look like this:
class AwesomeActor extends Actor placeable; var string MyName; var int NumberOfKittens; var float DistanceToGo; function PostBeginPlay() { 'log("MyName:" @ MyName); 'log("NumberOfKittens:" @ NumberOfKittens); 'log("DistanceToGo:" @ DistanceToGo); } defaultproperties { MyName...