Quik Question

will sone on tell me witch is the right way to fomat this

import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()
ob = g.getCurrentScene().getObjectList()
object = [ ob["OBPlayer"] ]
 
own.getDistanceTo(object)

or is it

import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()
ob = g.getCurrentScene().getObjectList()
own.getDistanceTo[ ob["OBPlayer"] ] 

are ether of these right or am i doing somthing wrong

I dont know if syntactically they both are correct, but conceptually the first way is faster execution wise. In the first, object is the pointer to OBPlayer, and anytime in your entire code you want to reference it, you have it. In the second way, the interpreter has to defreference each time, and that slows it down.

ok i typed up a script in the first format and it returns an error

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
    File "Text", Line 7, in ?
TypeError: argument 1 must be KX_GameObject, not list

Try it as

object =ob["OBPlayer"]

fianaly thanks it works
thanks

Joel

So quik, you don’t even have time to spell quik. /:]