How to pause the whole scene except the object I choose in blender game

Como pausar toda a cena menos o objeto que eu escolher no blender game, por exemplo, o suspendScene pausa a cena toda, mas eu queria que um objeto ficasse ativo, eu tentei usar o suspendiPhysics, mas ele só pausou a fisica, suspend Dynamics também é a mesma coisa, tentei o modulo bge chamado “obj.suspend()” mas não funciona, tentei o time.sleep() só que ele pausa a cena inteira :frowning:

Bemvindo ao BA :slight_smile: Este é um fórum de língua inglesa, então traduzi sua resposta para o inglês.

Welcome to BA :slight_smile: This is an English-speaking forum, so I’ve translated your post into English.

How to pause the whole scene except the object I choose in blender game, for example, suspendScene pauses the whole scene, but I wanted an object to stay active, I tried using suspendiPhysics, but it only paused physics, suspend Dynamics too it’s the same thing, I tried the bge module called “obj.suspend()” but it doesn’t work, I tried time.sleep() but it pauses the whole scene :frowning:

1 Like

If you’d like to suspend logic as well for all objects except a articular object, you can simply change the current states of the other objects to an inactive state (a state that doesn’t have any Logic Bricks). Not sure if this works with Python Components…

import bge
def main(self):
    for o in self.owner.scene.objects:
        if "Pause" in o.getPropertyNames():
             o.state = 2

For example in the code snippet above, we set the state of any object that has the game property called Pause. You can also selectively get objects by object names, mesh names, a predefined list or dict, etc. You’re not limited to just a few options. Likewise you can set the state to any available state. (0 - 20.)

Tanks bro, nice!! :smiley:

Well it changed state, when I come back it restarted the animation and the properties continue processing

I used this code to suspend the object but it didn’t work either

import bge

obj = getCurrentController().owner

if obj['Pause'] = True:

Well, what you could do, is store the current animation frame that you’re on before switching states. You can do this using bge.types.KX_GameObject.getActionFrame. Store the value in a variable or game property, and set the animation frame when you revert the states to restore the saved frame.

That’s because KX_GameObject.suspend() isn’t actually a method and does not exist? Surprised you didn’t get any errors…

You’re either looking for bge.types.KX_GameObject.suspendPhysics or bge.types.KX_GameObject.suspendDynamics.