• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

False collision event in debug mode

BarrowBloke

Member
Hi,

I'm getting some false collision events between 2 instances but this only occurs when I'm running the debugger.
Is this a known bug?

Some more details:

I have an object instance that I've called objCalibrationBox in the centre of the room. When the player presses a gamepad button an instance of objPlayer is created at 0,0 in the room.
When the player is created there is a large gap between the player and the calibration box i.e there is no overlap or possibility of a collision
And I draw a yellow rectangle using the bbox variables of each instance to confirm this.

If I just 'Run' the project then all is fine.
However, if I 'Debug' the project using F6 then I get a crash in the collision event of objCalibrationBox at the moment the player is created because the objCalibrationBox id is 0 (the collision code is in the objCalibrationBox so I'm not sure how this happens!)
To catch this I used an IF statment on id as follows:
GML:
show_debug_message("player collided with calibration box");

if(id > 0) {
    if(calibrating == false) {
        other.x = x - 400; // move it away so we don't re-trigger calibrating later
    
        GP_names = get_GP_names();
        chosen_GP_ID = 0; //go to 1st entry
        calibrating = true; // set our own flag
    }
}
else if(id == 0) {
    show_debug_message("collision error: id == 0. Erm...how?  " + string(random(100)));
}
And I found the Output tab filling up with "collision error: id == 0. Erm...how? " while the player was in an area the size of the calibration box in the top left of the screen.
Almost like it thought the calibration box was in the top left of the screen even though it was plainly visible in the centre of the screen and could be correctly collided with there.

As always, any help or insight is much appreciated!

Regards,
Barrowbloke
 

Roldy

Member
You would need to at least provide the relevant info.

When is the code you posted called and from what instance, the event that is calling it, what is the call stack if you break point inside your conditional?

the collision code is in the objCalibrationBox
No code is 'in' any object; Scripts, functions or methods are called during events within an instance context (id).
 

BarrowBloke

Member
Hi,

The code I posted is the code in the collision event. It's called from objCalibrationBox when there's a collision between objCalibrationBox and objPlayer.
If I put a breakpoint on the 2nd show_debug_message in the code then the call stack is only 1 line:
objCalibrationBox::eek:bjCalibrationBox_Collision_objPlayer : objPlayer : Line 14

At this point in the Variables tab of the debugger I can that 'Self' = 0 whereas I would expect it to have a valid value E.g like 100001.
The 'Other' value is 100005 which seems to be valid.

The strange thing is this only occurs when I run in Debug. If I just run it with F5 then this false collision isn't triggered.
 

Nidoking

Member
Are you using the latest runtime version? I used to have this problem, but I think it got resolved in an update along the way.
 

BarrowBloke

Member
Yes, I've tried the broom a couple of times.

I've exported the project as a YYZ file so anyone might verify this behaviour themselves
link to YYZ file
When you Run or Debug it you should see a black screen with a large purple square in the middle.
Press any of W,A,S or D and a player object (a red square) will be created in the top left of the screen.
Look in your 'Output' tab for debug messages and see if alot are generated of the form "collision error: id == 0. Erm...how? " with a random number at the end (I included the random number so you could see the new messages being generated and scrolling up the window)

Fyi ,this project isn't a game - I was just trying to make an InputManager object which would handle remapping of buttons/keys. Crashing the player into the 'CalibrationBox' is just how I chose to trigger that remapping mode for testing purposes.
And then I noticed these false collisions.
 
Top