How to refresh scenes in bge

Hello everyone,
I’m stuck with a problem in my game that I’m working on for my Studies Final project, wich is in the display of the game…
Actually, I made a button to set a new scale and color to a specific object. The problem is that this new scal and color doesn’t apply till I go out from the player mode.
I wonder if there’s any way to refresh the redering scene in order to display the new settings…
If there’s any other solution please help me. I’m kind of lost :spin:
Thanks !

It sounds like you were scaling with the bpy instead of bge. Or are you playing actions on object scale and color?

Omg , yeah actually -_- didn’t pay attention I’m scaling with bpy :frowning:
any Ideas on how to do it with bge ? thanks !!!

KX_GameObject.localScale
KX_GameObject.worldScale
KX_GameObject.scaling (Deprecated)

Simply do not use bpy. It is the python binding to Blender.

You need the python binding to the BGE. The API Doc contains both: bpy and bge. Use the bge module (and the utility modules) only.

Thanks a lot for your Help …
it worked ^^
but I have an other issue, I just want to scale a specific object on “Z” axes at the Left Mouse click event :confused: and I’m still stuck in it …

Create an action with two scale keys.

On mouse click play the action. I suggest to use the flipper mode as it plays the action reverse when the event is not active anymore.

That’s not what I look for, I’ll explain a little …
this is an exemple of what I’m goig to do


you see the red and bleu “liquides” if you want and the “plus” button.
What I want is whenever I click the plus button, the blue liquide’s scale on the “Z” axes becomes shorter by 0.02
and the red one increses by 0.02.
Same for locations, the blue one will decrease by 0.02 and the red one will increase by 0.02.
This way, the player will have the illusion that he’s actually pooring it…

Any Ideas please ?

Again … use an action. With that background information, I suggest to use scale and a location keys. When playing use the property mode. this way you can control the current pose via property (remember to activate the action actuator after changing the property).

You can change the property with the property actuator in Add mode (add negative values to play reverse). You can increase/decrease the property with fraction values (e.g. 0.2).

The advantage of the action is:

  • you can animate several channels at once (scale + location)
  • you can set explicit limits - so it will not exceed the available space
  • you can create non-linear animation (e.g. becoming faster/slower at the beginning/end of the container).
  • simple setup

I recommend to create an action for red and an action for blue.
Use the same event to trigger the playing so they both play synchronous.

But how can I save the new Location/Scale everytime the action finishes ??
Sorry I’m new to blender and scripting, and thanks a lot for your help !!

Play it in property mode.

The value of the property determines the current pose.

Have a look at BGE Guide to Messages incl. Healthbar tutorial. You can ignore the message part (it still might be useful for the remaining logic of your file). Look how the value bar is animated. Do the same thing.

Thanks a lot for sharing !! (y)