Random Death

I doubt I can get much help here on this but I’ve looked at all the code that seems remotely relevant and I have no idea what’s happening here.

I’ve got a platformer where you periodically die and get returned to the starting area. I have a few killzones (bottomless pits) that kill you automatically and a few hazards that reduce health, until you hit 0.

There’s a few other places where you go into a chimney and then come back out. They are not near any kill zones, none of the involved code reduces health or triggers the death variable, but there appears to be a 10% (approx) chance whenever you exit a chimney that the game will kill you and return to the starting area.

I’m not sure what I expect here exactly - I think you’d have to see the entire scene file to figure anything out and I don’t expect anyone to do that. The bug is most likely caused by a simple misapplication of basic code - I can’t think of any advanced scripting stuff I don’t know yet that would be causing a bug specific to my game.

I guess my question is, has anyone had a similar problem and was there any particular technique to help dislodge you from looking at the coding the same way over and over again? I keep searching but I keep seeing exactly what I expect to see.

If I were experiencing a similar issue I would print the player’s health to the console to make sure it wasn’t being reduced somehow. I’d also add similar print calls in the collide functions of the bottomless pits. Make sure one of these calls isn’t being triggered inadvertently, then go from there. Keep narrowing it down like that until you find the single offending line of code.

Thanks. Found it. I had recently added “falling damage”, and going down the chimney was triggering that. I’m pretty sure it’s fixed now, although given that it didn’t always happen in the first place I may just be lucky so far.