Track object=propvalue

controller = GameLogic.getCurrentController()

sen = controller.sensors[“sensor1”]
sen.propName = “prop”
val = sen.value

print val

act = controller.actuators[“act”]

act.object = val
act.use3D = True

This script was supposed to make the obj track another object, tha name of whic was the same of the propertyvalue. BUt, as you can guess, it isn’t functioning

Actuators need to be… activated.


first you need to know if the sensor has been activated :

controller = GameLogic.getCurrentController()
sen = controller.sensors["sensor1"]
if sen.positive :

then retrieve the info :

	val = sen.value

be sure val is a string whith no ‘OB’ in its name (use the blender name, not the G.E. name)

	if 'OB' in val : val=val[2:]
	act = controller.actuators["act"]
	act.object = val
	act.use3D = True 

for track you don’t need to add :


at the end. idem for the sensor, no need to activate the true triggering.
I speak about that because activate is mandatory in most of the other cases.

(it should work but I didn’t test)

have a look here for G.E. API + examples and many more :

I tried both, unsussesfully

controller = GameLogic.getCurrentController()
sen = controller.sensors[“sensor”]
if sen.positive :
val = sen.value
if ‘OB’ in val : val=val[2:]
act = controller.actuators[“Track”]
act.object = val

This is my file, only 100kBs


I fixed it, but i also had to rotate your whole scene because your track to actuator was set to 2D.
Fixed.blend (146 KB)

EDIT: Btw the string “Tracker” is still on the object, you can remove that if you want.

hi OriginalBBB,

Yet another way of doing it. I left it so it still uses the message actuators to set the object being tracked.

I changed the first property actuator to assign “OBAAA” to the property named Tracker instead of “AAA”. That is just for testing purposes to make sure the code strips “OB” from in front of the Object name if it’s there.

Also, the Track To uses the Y axis so I rotated the pointer axis so the tip points along the y axis instead of the z. And I set the Track To to use 3D.



trackto_propvalue_fixed.blend (147 KB)

that’s what I call support !
it would be great that my ISP does the same.

:ba: Thanks to you all guys. I’m very gratefull :D:yes: