I was working on blender game engine, and I have no idea how to change scene using python.

I have an actuator set in to change scene, but I don't understand how

I have made a sample blend file . What I want to do here is to switch to changed_scene using the actuator change_scene (Under player logic) using python. I need to know this, because I am making a game and the game requires switching scenes when the player dies.


2 Answers 2


When your player dies, change a property (e.g. "dead" to "1")
BGE property

Then use a property sensor ("dead" == "1"?) and hook it up to scene actuator.

Okay, there's a bit more to it

I did a collision sensor, colliding with property "damage." I added property "damage" to everything except the floor!

I added health to your cube player, default 100. connected collision sensor to property actuator add "-50".

Created property sensor, health less than 1. connected to property actuator, dead = 1
logic bricks

created property sensor, dead equals 1, connected to change scene actuator. Probably could be more efficient, but it works! :)

You'll want to "and" a delay so your dramatic final collision plays out before changing scenes though

Blend File

  • $\begingroup$ good answer, mind posting some pictures with it? $\endgroup$ Nov 17, 2014 at 14:56
  • $\begingroup$ Thanks for the answer, I will try it out whether it works or not. Also isn't it possible to use a command from python to set scenes? $\endgroup$ Nov 17, 2014 at 19:12
  • $\begingroup$ @BlendingJake sure :) !damage health logic. !damage property set on collideables. $\endgroup$
    – ball2000
    Nov 18, 2014 at 0:55
  • $\begingroup$ ^markdown fail lol $\endgroup$
    – ball2000
    Nov 18, 2014 at 1:03

Along with the answer from ball2000 , I integrated python code to delay the scene switch. The code looks something like this

   if player.sensors["water_collision"].positive:
        curtime = time.time()
        while(time.time() - curtime < 20):
            print(time.time() - curtime)
        player["dead_status"] = 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .