Time for action – Accessed None in function parameters
Even when we're using functions, we have to be careful about Accessed None warnings. Just because a function is passing an actor in doesn't mean it's a valid reference.
Let's remove our
MyProjectile
variable and rewrite thePostBeginPlay
function:simulated function PostBeginPlay() { AdjustProjectile(none); }
Now let's write the custom
AdjustProjectile
function:function AdjustProjectile(Projectile MyProj) { `log("MyProj:" @ MyProj); MyProj.Speed = 1000.0; }
Compile the code and run the game.
Exit and take a look at the log. We're getting the same warnings as before:
[0005.09] ScriptWarning: Accessed None 'MyProj' BrokenActor BrokenMap.TheWorld:PersistentLevel.BrokenActor_0 Function BrokenGame.BrokenActor:AdjustProjectile:0024 [0005.09] ScriptWarning: Attempt to assign variable through None BrokenActor BrokenMap.TheWorld:PersistentLevel.BrokenActor_0 Function BrokenGame.BrokenActor:AdjustProjectile:0038
What just happened?
In...