Is there a way to fix "sensor has lost a link to controller"?

I’m asking for a fix to this, because I have made a HUD. When I add it, then use endObject() to get rid of the duplicate HUD for performance, all of my sensor links pertaining to the HUD displayed on-screen suddenly are “lost”, and the HUD is non-functional.

Any way to preserve these links without crashing UPBGE 0.3 or redesigning logic? It’s ruining my HUD! Or am I screwed here?

Just so you know, this is a linked HUD I have made, and it is an Instanced Collection. If I do it without instancing the Collection, same thing.

I’m desperate here.

I’ve had this problem before but only on big projects, and it was caused by the new undo system, switching to the legacy one didn’t solved the lost links, but prevented to happen again for me, and also, the legacy undo is slower.

I reckon the team should work on a fix for the “sensor has lost a link to controller” issue. It sounds like a bug.

I didn’t know how to reproduce the error, since it seems random to me, sometimes I get the problem, sometimes don’t, so I don’t know exactly when this is happening, the only thing that I found was that sometimes using undo, I was having the error, and sometimes everything worked fine.

if your sensors or actuators have a connection with objects that you delete, you will destroy these connections - most likely this will lead to errors or failure - the only way out is to use python to control such objects, for example, I used the overlapping HUD of the ship, but I did not hide it in collections and I control the camera in the cockpit with a script on an external object when I’m changing the cockpit, I’m not removing the camera, which is overlapping so as not to get an error, you can place many UI details on the player’s camera itself without overlapping collections

Open a new /blend file.

Menu->import → import everything from the old .blend file. Problem should be solved now.

I basically created a fallback sensor on the original object and then used try and except to get the fallback sensor should the “obname_linkonly” or other kind of sensor’s connection be destroyed. This way, the fallback sensor inside the actual HUD element that uses the python script (like health or magic etc) is used instead as a backup. This helped stop Python from throwing errors. Not always successful, but is painful at times to build new logic for a fallback system.

You will find that “try” and “except” can be your best friends 80% of the time, except when trying to catch NoneType.

Is it possible to catch a NoneType exception? It says that it cannot catch a NoneType if you try.

you can check for the presence of a type in a variable None through “if x!=None” “if x==None” or so that None is not included in the ranges of lists - “for item in list: if not None in item” - these are simple logical checks not related to exception handling, personally I very rarely use try/except exception handling - since I do not have unforeseen situations - as I wrote above, I create a HUD/UI system for the player in a different way, the interface elements themselves do not have scripts or logic blocks and are controlled from outside, as a rule, they are controlled by the player’s script function that transmits data to the interface - this means that it’s just not possible for them to create an error, even things like stripe animations can be replaced with scaling - bar.scaling = [own[‘health’], 1.0, 1.0] you just need to scale the healthbar itself