PDA

View Full Version : new scripter question


navboy
10th Sep 2001, 02:05 AM
Been at this about 2 weeks now, have subclassed 4 actors, it's working pretty well, but now i'm worried about performance and side effects. Here's something i see done both ways alot:

How are these different and if they're equivalent which one is better (for
network play)?

1:
if( Other.IsA('Pawn') )

2:
if( Pawn(Other)!=None

anyway, thanks for any help

nighthack
12th Sep 2001, 08:46 AM
I guess (Pawn(Other)!=None) should work faster, even if the difference shouldn't be that big.

Ohter.IsA('Pawn') is a function call which naturally takes more processing time than a simple comparsion.

navboy
12th Sep 2001, 03:11 PM
Originally posted by nighthack
I guess (Pawn(Other)!=None) should work faster, even if the difference shouldn't be that big.

Ohter.IsA('Pawn') is a function call which naturally takes more processing time than a simple comparsion.

hmm, and Pawn() is not a function call? Or is it a game engine call therefore "special" and/or faster? Please bear with my newness ;)

ca
12th Sep 2001, 03:56 PM
You can (try) to cast any object into a specific class, and Pawn(SomeObject) is just an attempt to cast into the Pawn class. If you try to cast an object into a class that it isn't a child of, or isn't an instance, then it will return None.

I don't remember the specifics, but I'm pretty sure Other.IsA('Pawn') is more network friendly than the none check, Pawn(Other) != None. I don't think it'll make much of a difference either way, so I wouldn't worry too much about it.