1
$\begingroup$

I have created an animation that works perfectly with alt+A. I tried to use actuators and a script to make it work in bge, but everytime I run it the plane disappears. Here is the blend file.

If you move the mouse, the 3 arrows follow the cursor. When you right click on the ground plane, the animation should have taken place. It does not. Instead the ground plane disappears leaving behind a small green line.

Here is the module code:

#Import the bge library.
import bge

#Make the mouse cursor visible during game running time.
bge.render.showMouse(True)

#Set the current game scene and python controller to variables.
scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()

#The function "initialization" is responsible for setting all scene objects, object sensors and object actuators to variables.
#These variables are created into the function but are for global use. Their names are the names of the objects/sensors/actuators in blender.
def initialization():
    for k in scene.objects:
        exec("globals()[\"%s\"]=scene.objects[\"%s\"]"%(k,k))
    for k in ground.sensors:
        exec("globals()[\"%s\"]=ground.sensors[\"%s\"]"%(k,k))
    for k in cont.actuators:
        exec("globals()[\"%s\"]=cont.actuators[\"%s\"]"%(k,k))

#The function "empty_to_pos" gives the cursor_empty coordinates on the ground.  
def empty_to_pos():
    cursor_empty.worldPosition = (mop.hitPosition[0],mop.hitPosition[1],ground.worldPosition.z)

#The function "cursor_anim" is responsible for the start and end of the cursor animation.
def cursor_anim():
    cont.activate(anim_arrow_1)
    cont.activate(anim_arrow_5)
    cont.activate(anim_arrow_9)

initialization()
empty_to_pos()
if (right_click.positive):  
    cursor_anim()


print ("I reached the end of track.py")

and an image: image

Any ideas why the animation is not working and why the plane disappears? Thanks

$\endgroup$
2
$\begingroup$

Action (animation) actuators need to be part of the object, which you want to animate.

In the .blend, the animations are applied to the "ground" plane instead.

To make objects interact with each other in the logic editor, select them at the same time using Shift + Leftclick in the Outliner:

selecting multiple objects in the Outliner

You will see the objects in the logic editor:

interlinking multiple objects in the logic node editor

Then edit the logic so that one object's controller controls other objects' actuators:

finished interlinking

You can see the full process in this video. Unfortunately two of the arrows don't animate correctly and I'm not sure why that is. Perhaps their transformations need to be applied?

$\endgroup$
  • $\begingroup$ Many thanks, I did not know they had to be in the objects themselves.The mistake you referred to happens because the actuators 9 and 5 had starting and ending frames 0 to 0. Should have been 60 to 100.My bad. $\endgroup$ – Lev May 5 '15 at 13:00

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.