Time for action – Actor variable errors
Errors of this type are common when you're getting used to UnrealScript. Knowing when and how to use typecasting and dealing with Actor variables takes some time to get used to. Let's see some of the errors we can come across when doing this:
Let's say this Actor killed anyone who touched it while holding a weapon. We might have a function that looked something like this:
event Bump( Actor Other, PrimitiveComponent OtherComp, Vector HitNormal ) { if(Other.Weapon != none) Other.Suicide(); }
Compiling this code gives us an error:
[0003.90] Log: R:\UDK\UDK-AwesomeGame\Development\Src\BrokenGame\Classes\BrokenActor.uc(6) : Error, Unrecognized member 'Weapon' in class 'Actor'
What's causing this error? If we search
Actor.uc
we won't find aWeapon
variable; what we meant to do is check if the actor bumping us is a Pawn, and check if that Pawn has a weapon. Let's rewrite the function a bit:event Bump( Actor Other, PrimitiveComponent OtherComp, Vector...