• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ error reaching limit

eams1986

Member
How can I make this error go away?

in this case the player Red is on the verge of true or NOt :( but I want it to remain stable to tell me if it is YES or If it is No when being in that position!


GML:
if collision_rectangle(960-400,0,960+400,250,o_parent_47,1,1) {
    show_debug_message("SUBE");
    o_go.activar_panel = true;
    }
else {
    show_debug_message("BAJA");
    o_go.activar_panel = false;
    }
Thanks
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Is this an "error" as in "error message" or as in "unintended behavior"? It sounds a lot like the latter, but conventionally, "error" refers to error messages. That could potentially be confusing for respondents.

From what I understood, this code is alternating between setting activar_panel to true and false... is that correct? If so, does anything else happen when these variables are being set? Something has to change as a result of it, as an instance can't both be colliding with something and not colliding with something. For example, maybe the calling instance moves or changes its collision mask, or the instance being collided with moves or changes its collision mask (e.g. because it changes its sprite, and therefore potentially its collision mask, depending on the value of that variable).
 

rytan451

Member
You should keep track of the collision boxes of the objects. This will make it more obvious what the problem is.

In the Draw End event:

GML:
draw_set_color(c_red);
draw_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom, true);
I suspect that the rotation is causing the red car to be quickly changing between colliding and not colliding with the rectangle, thus leading to the behaviour you've shown.
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
... oh dammit, I missed that that's a GIF (I have animations disabled by default). Good catch.

In that case, it is important to note that collision masks rotate alongside their instances - and not always in the way you'd expect! - so I agree that it's most likely the rotation that is causing the issue. More specifically, changing image_angle will rotate the mask.

Unless you are using a precise collision mask - in which case it will rotate the way you'd expect - the mask will actually retain its defined shape, using the outer bounds of the rotated region (that was defined as the bounding box) as the new bounds. The result of this is that a rectangular mask will grow and shrink in size as it rotates, but does not rotate.

Control the visual aspect of the rotation without setting image_angle to retain the original mask (you may want to define a differently shaped mask that will fit the instance no matter how it is rotated for this), or change the shape of the mask to change how it rotates.
 
Top