Time for action – A practical example of casting for our game
Let's change the way our Pawn reacts to the weapon he's carrying. We'll make him invisible when he picks up a rocket launcher, and make him visible for a bit after he fires it. Sure why not!
For this example we don't need to do anything to the rocket launcher class itself, all of our work will be in our
AwesomePlayerController
. Let's strip out all of ourAwesomeActor
/UberActor
experimentation and get back to our basicAwesomePlayerController
:class AwesomePlayerController extends UTPlayerController; var vector PlayerViewOffset; simulated function PostBeginPlay() { super.PostBeginPlay(); bNoCrosshair = true; } exec function StartFire( optional byte FireModeNum ) { super.StartFire(FireModeNum); } simulated event GetPlayerViewPoint(out vector out_Location, out Rotator out_Rotation) { super.GetPlayerViewPoint(out_Location, out_Rotation); if(Pawn != none) { Pawn.Mesh.SetOwnerNoSee(false); ...