0
$\begingroup$

This question has already been asked, but not really answered: How to activate ANOTHER object's actuator (Python)?

So regardless if I'm supposed to:

I've got following objects parented (simplified):

Cube "Hero" (invisible,actor) [always:player.py]
  > Armature "Skel"     [Walk.action, Jump.action, ...]
      > Mesh "Skin"

"Hero" is my player object. Here I have my Always > player.py script.

Depending on stuff I want my script to activate animations on "Skel".

Currently I'm doing this using playAction while using the settings taken from the Action from Skel.

Now I'd like to use the Action Actuator directly via cont.activate(Walk.action).

The problem is I don't have a controller to activate it with.

How can I do this nevertheless? (And yes, I'm interested in alternatives, too, but I really really would like to have an direct approach first.)

Thanks in advance

$\endgroup$
2
$\begingroup$
from bge import logic

cont = logic.getCurrentController() #Camera
cube = logic.getCurrentScene().objects['Cube']
print(cube.controllers)
print(cube.actuators)
cube.controllers[0].activate(cube.actuators[0]) #AttributeError: 'SCA_ANDController' object has no attribute 'activate'
cont.activate(cube.actuators[0]) #ValueError: Motion not in this python controllers actuator list

The solution: Send a message to trigguer a message sensor to trigger the and controller to trigger the action actuator

enter image description here

In your script:

from bge import logic

cont = logic.getCurrentController()

cont.owner.sendMessage('anySubject')

or just:

from bge import logic

logic.sendMessage('anySubject')

Also you can connect multiple objects logic bricks take a look at blender-game-engine-logics-sensors-and-python-script

$\endgroup$
  • 1
    $\begingroup$ Thanks a lot! Above all I appreciate showing that/why using another objects controller doesn't work. $\endgroup$ – Scheintod Dec 29 '17 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.