Activate actuator of an object that doesn't own the script

Hi everyone!

I have an object X with a script.
I would like that this script activate an action of the object Y.

How is it possible?

And con you also tell me how can i modify the properties of the object Y from object X?


easy, and answer 1000 times here on the forum.
please use the search function.

Here you go:

scene = GL.getCurrentScene()
cont = GL.getCurrentController()
own = cont.owner
objList = scene.objects
player = objList["OBplayer"]

#to change/set the players props just do this
player['ProName'] = 100

to get hte actuators of another obect, select both and then link them to your needs.
Then you get the actuators just as they where the ones of the own. Pls keep in mind, that you should different names for any actuator to call it specificly and avoid errors.

Thank you so much!
I’m googled but didn’t find anything, next time i’ll search with the forum function :yes:

Btw now i have another problem

import GameLogic, time

cont = GameLogic.getCurrentController()

own = cont.owner

if own['estratta'] == 0 :

 cont.activate("extr1")  #action of 5 frames

 cont.activate("IN_no") #object1 invisible
 cont.activate("OUT_si") #object2 visible

 cont.activate("extr2") #another action


elif own['estratta'] == 1 :

 cont.activate("extr1")  #same as before

 cont.activate("IN_si") #object1 visible
 cont.activate("OUT_no") #object2 invisible

 cont.activate("extr2") #same as before


the object1 starts visible, the object2 invisible. estratta is a propriety of the armature the script is attached to and starts with 0 (is an integer).
If i run the first or the second condition alone, it works fine, but if i run the script with the 2 condition, it doesn’t work (extr1 is played, then the object1 is turn visible, the invisible, while the object2 is turn invisible, then visible, and than extr2 is played). The script is activate by a keyboard sensor. if a keep it pushed, it works, but is i release it, everything retur as it started…
I can’t figure why, i put an “elif”, so if the first condition is true, the second shouldn’t start…

(no error in the console)

you can directly set visibility by
ob.setVisible(). this makes it easier to read.

time.sleep() - this is crazy. It holds the BGE. You will recognice large performance issues. You should not do that. The Python controller is not running in an own thread.

Your script makes extr1 and extr2 playing at the same time under both conditions. Maybe you miss a deactivate()?

elif is fine, as the conditions exclude eachother.

i need to play the animation, and once it has finished, set the visibility and then play the other animation…
I have an idea (i don’t write it because english is not my mother language and it’s a bit tricky to explain) but it seams quit a workaround. Isn’t a direct method?

(is in plan i 2.5 to make python scripts run multithread? nowadays the majority of the cpus are multicore)

I uploaded the .blend file
Hope you can have a better idea of what i’m trying to do :slight_smile:

Use states.
This is the best approach for sequential logic anyway.
Partly you have it already with your “estratta” property. You need some more values than just 0 and 1.

BTW: This can be done with pure logic bricks either, with the states of the controllers and states actuator.

Con you link a tutorial on en explaination of states? I didn’t found anything,neither in the manual…