Time for action – Casting Actor variables
The answer of course is casting. Let's set up a subclass of AwesomeActor
and see how we can use it.
Create a new file in our
AwesomeGame/Classes
folder and call itUberActor
. Type the following code into it:class UberActor extends AwesomeActor placeable; function UberFunction() { `log("UberFunction was called!"); } defaultproperties { }
We're extending off of
AwesomeActor
and adding a function calledUberFunction
that will log when it is called. Remembering our inheritance, we don't need the sprite in the default properties because we will inherit it fromAwesomeActor
.Compile the code and open the editor. If we take a look in the Actor browser we'll see our
UberActor
underneathAwesomeActor
in the class tree.Close the editor for now; we'll be spawning the
UberActor
directly so we can get an easy reference to it.In our
AwesomePlayerController
class, add theStartFire
function again and spawn anUberActor
into ourMyAwesomeActor
variable...