OB data of another OB


(TankCoder) #1

Hey all, I want to find the getPosition of an OB thats not of the OB I am using… for example. Say I call the script “foo” from an object(bob) when it gets close to another object(dave). how would I get the OB data from dave when my script is running in bob?


(S_W) #2

thats a question i always wanted to know, too! :wink:


(Ben) #3

-Connect your controller that handles the python script with an actuator
(it’s not important which one)of the object you want the position.Than in
the script add

owner1=cont.getActuator(“name_act”).getOwner()
pos=owner1.getPosition()

pos is the position of the other obj,name_act the name of the actuator you added.


(saluk) #4

Its better for this situation I think to use a near sensor.

c = GameLogic.getCurrentController()
near = c.getSensor(“MyNearSensor”)

dave = near.getHitObjectList()[0]

dave will be the first object that the near sensor reads. Make sure of course on the near sensor to make it look for prop “dave” and give Dave the prop “dave”.