some newbie questions

what i would like to achieve is this:
if i click on an object, an animation should play and “hello!” should be printed to the console.

this is my setup:

there is a [mouse over] and [mouse button] sensor that feed into an [add] controller and that into an [action] actuator.

the problem is, the animation starts but only plays to the end if the mouse stays on the object. if the mouse moves away the animation stops. how can i correct this?

for printing “hello!” i use a message that triggers a [script] controller. the script only contains 1 print statement but “hello!” always gets printed twice. why is that?

  1. For the animation playing problem, use Play Stop instead of just “Play” for the animation’s play mode (in the Action actuator).
  2. “Hello” gets printed twice most likely because the message is getting sent twice (once when the mouse clicks and is over the object, and another time when that evaluates as false). I’m not very good with Game Logic Tic Pulses, though - someone else who knows more could help you out.

hm… i don’t find “play stop”, just “loop stop”. i experimented with all modes and none worked like i want.

do you have an idea how i could best achieve that “hello!” only gets printed once?

loop stop, and set the click or mouseover (best use click) to TAP. that means even if you hold it, it goes on, then off till you release the mouse

hm… with “tap” no animation happens at all.

“Play” plays the animation one time and stop when the endframe is reacht.
So play for the motion actuator is okay. You can fix this, when you use a message sensor.


you might want to read this thread: "double execution of a Python controller"
and “A word on pulses”

Why your action actuator does not play until the end - I do not know. What version are you using?

i use the 2.56 beta. didn’t download 2.56a yet.

it didn’t play until the end only if the mouse moved away from the object and wasn’t “mouse over” anymore. if the mouse stayed on the object it played until the end.

by using a property i got it to work exactly like i want now:

but i am not sure if this is the best way to do it. :slight_smile:

thanks for your links! sounds like they cover exactly the confusions i have. :slight_smile: i will check them out now…

this diagram is really awesome, thanks!

some more questions:

  • what is a logic tick? 1 frame?
  • what exactly does the “level” button next to “tap” do?

and python related:

  • how does the engine call the python scripts? per eval()? isn’t that kind of slow?
  • what is the best way to keep variables around between script calls? properties? bge.logic.globalDict? or is there any other way?
  • can i only use bge for the game engine or the whole bpy api too?

Action and Shape Action:
Simply it is a fault in Blender. This fault is in every Blnder version. AniTest.blend (151 KB)
You can ony fix that by using a property or message (post #6).

what is a logic tick? 1 frame?

The number of pulses sent is based on the logic tic rate (physic framerate). Default is 60 times per second.

what exactly does the “level” button next to “tap” do?

Part of the State System.
When the State is activated, it checks to see if a mouse button or a keyboard key is pressed. Sends a pulse to the controller if it is.

thanks for your answers!

and does anyone know about my python questions?

you can use some the the bpy i think, but not sure quite what.
use globalDict variables for between games and scenes, using the save globaldict actuator , or just bge.logic.var for just between scenes

  1. dunno
    2)use bge.your_variable. This is a variable of all the game, accessible by all the scripts, and that is erased only when the ge stops
  2. in your script you can use the bpy api too, but the effect will be refreshed only when you stop the bge, so it’s quite useless to use it

thanks for your answers! :slight_smile: slowly i get the hang of it…

ok, another question came up. :slight_smile:

i would like to change the mouse cursor to a hand or something once it is over the object that triggers the animation. i have looked around a bit, and it seems there is no support for changing the os-native cursor.

so i am thinking of moving a mouse cursor mesh with the mouse coordinates, but if the logic ticks are coupled to the physics engine frame rate, how can i do this every actually rendered frame? won’t this get kind of jerky?

Here is a custom 3D cursor script. You can also change the 3d cursor to a plane with alpha texture.


custom3DCursor2_5x.blend (309 KB)

thanks! i will look into it…

how can i fade in or fade out an object? from transparent to intransparent…

i didn’t find a way to do this. is this only possible with a shader? the problem is that my project is targeted at older graphics cards with no shader model 2.0 support.

i got it to work now with an f-curve actuator and keyframes for the alpha property of the material. my problem was that i used texture face instead of multitexture shading.

the fading works now but i came across another problem i can’t explain.

is the [add controller] broken in 2.56a by any chance? :stuck_out_tongue:

i want to fade in the title screen and if the user clicks on it i want to fade it out again.
but it shouldn’t react on the click until it is fully faded in.

so i combined a [left mouse button sensor] + [property sensor] that reacts to the end frame of the fade in animation. i connected this to a [add controller] but this seems to trigger even if only one of the conditions is set.

with this python controller it works like i want:

import bge

controller = bge.logic.getCurrentController()
s = controller.sensors
a = controller.actuators

print(controller.owner["frame"], s["Mouse"].positive, s["Property"].positive)

if s["Mouse"].positive and s["Property"].positive:

what could be the reason for this?

should i upload the blend file or a screenshot of the logic bricks?

does anyone have an idea what could be the reason for this?

isn’t the above python snippet supposed to do exactly the same as an [add controller]?

but if i try to do the same with an [add controller], then it triggers also if only one of the sensors is true. it’s weird!