UPBGE - "Start game from file" actuator always crashes the engine

My game has a lot of scenes, so I was trying to break it up into “levels”, each one being an exe file. When you reach a certain scene at the end of that part, there’s a game>“start game from file” actuator attached to the camera that starts the next exe.
When I start the first level from the first scene in the first file and make my way to the “loading” scene for the level, the engine just crashes. However, when I start the game from the “loading” scene by itself, it does seem to load the next exe. I checked the console and it was strange because, aside from a whole list of warnings in both cases, there doesn’t seem to be an indication of when it crashes or what caused it to…
My best guess would be it’s because there are 4-5 scenes overlayed it just crashes when trying to load a new file due to memory limitations. (?)
Anyways here’s some more stuff to show what’s happening. In the first part of the video, I start the first blend file from the start screen scene. Then, I go to the “loading” scene and start it from there, and it seems to work.


Sensors plugged to controllers owned by other objects break easily, stop doing that. If you need to send signals across entities, use messages. Or better yet, pick up some python.

And if you wonder whether you’re running out of memory, task manager is your friend.

I checked and it doesn’t seem to be a memory issue at all. It only seems to crash when I use that actuator on a scene with more than 2 scenes overlaying at once.

Is this a problem with UPBGE? Has anyone else been having this issue?

I smell a segfault!

Bet it’s broken links. Sensor A tries to reach controller B, cannot find it, throws unhandled exception until the end of time and the process gets shut down. Sounds about right to me, mightier programs have crashed for less.

I could be wrong though, so go by elimination. If you don’t use overlay scenes and files full of objects with broken links work alright when loaded through the actuator, then it’s the overlays.

1 Like

I don’t have any unlinked logic bricks anywhere in both of these files. If I am debugging a scene I usually just uncheck the boxes or delete them entirely.

Is there a script I can use to deal with unhandled exceptions? Although I am not too well versed in python, I am trying to learn as I work on this project. Both blends already have quite a few scripts running, some custom shaders and some scripts to fix blurry type, movie textures, etc.

The console says you have a ton of broken links, look at the warnings.

I guess I’m confussing you, so to clarify: I don’t mean that these links between bricks don’t exist, I mean that these links are lost when loading the blend from another file. This usually happens when one links bricks on one object to bricks on another object.

Note that even if this isn’t the cause of the crash it’s still going to break your logic; if a controller depends on receiving a signal from a sensor whos lost a link to it, that signal will never arrive. And I can’t test it right now, but I think that if you tried to reference that sensor in python through cont.sensors you would run into trouble as well.

So first things first: fix these links. How? To start off, avoid linking bricks across objects. If controller on object A needs to evaluate a property on object B, you can setup logic like so

And if you want to read the body of the message in python, you can have the controller which receives it interpret it like so,

from bge.logic import getCurrentController
cont = getCurrentController()
mess = cont.sensors["Message"]
prop = None

#check that bodies != [] -- just an empty list
#if true, convert the body of the message (a string) into the right type
if mess.bodies: prop = eval(mess.bodies[-1])

#if prop != None, message was received
if prop: doSomething()

#note: if value of property is false, doSomething() will never execute!

In case you haven’t used it before, eval() in python turns a string into an expression; basically it translates text into other values, though it’s limited to common types (int, float, bool, list, dict).

Example: eval( str([0,0,0]) ) returns a list containing three zeroes rather a string “[0,0,0]”. Same functionality for dictionaries, so you can pass around a lot of data this way. Fun fact: it also works on expressions, so you can also do things like

#say s == "function(var)"
var = 1
eval(s) #executes function and uses the attributes we just defined

#say s == "var == 1"
var = 1
if eval(s): print("python is good for you")

Finally, this isn’t a matter of handling exceptions, it’s a matter of fixing your game logic. You could, maybe, add a ton of try/catch blocks onto every last piece of code that depends on a brick that could get lost when opening the file, but that’s a terrible idea. What you want to do is make sure that none of these links get lost, and the way to do that is doing some rethinking.

Yes, I get it – absolute bummer and there’s no quickfix for this. Welcome to game development!