0
$\begingroup$

I have big problem with python scripts in the game engine. I have a cube with an action in the X axis. Another cube which after clicked with mouse, starts a script.

button=bpy.data.objects['buttonLogic1'].location
print('button[0]')

But this gives me back only the location before action, and not after the action.

$\endgroup$
  • $\begingroup$ will you put your whole script there (or if it is long just the affected parts) it is hard to know what is going on with your script just from those two lines. Also is 'buttonLogic1' the cube with the script, or the animation? $\endgroup$ – David May 14 '16 at 15:17
1
$\begingroup$

Bpy does not work in the game engine. Instead you have to use the game engine modules

For this particluar application, your script could look something like:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
scene = own.scene
button = scene.objects['buttonLogic1']
print(own.worldPosition)

The standalone modules are also available in the game engine.

| improve this answer | |
$\endgroup$

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.