GMS 2.3+ Help with collision bug

Hi there everyone so the title should be pretty self explanatory. However that's only a brief decription of the problem so here comes the full description.
Now I've coded a basic collision system into my game using the place_free method and for the most part it seems to work fine.
However there is a slight problem I've encountered. The bug occurs whenever the player transitions between two specific rooms.
When I first boot up the game collision works just fine, but it all goes haywire when the player moves between different rooms.

Specifically what happens is that spaces the player was able to move through when the game first boots up now trigger collision once the player moves to another room.
I don't know exactly why this happens but I've been told it could have something to do with the game's graphics.

Advice on how to fix this would be appreciated.
 

CloseRange

Member
For debugging create this script:
GML:
function DebugBBox() {
    draw_set_color(c_red);
    draw_line(bbox_left, bbox_top, bbox_left, bbox_bottom);
    draw_line(bbox_left, bbox_top, bbox_right, bbox_top);
    draw_line(bbox_right, bbox_top, bbox_right, bbox_bottom);
    draw_line(bbox_right, bbox_bottom, bbox_left, bbox_bottom);
}
then just call DebugBBox() in the draw event for the player and the solid objects.
you'll now see the bounding box of the objects, did the players box grow on room change? when the collision occurs do the squares still hit?
 

rytan451

Member
@CloseRange, I'd actually recommend this script:

GML:
function DebugBBox() {
  draw_rectangle_color(bbox_left, bbox_top, bbox_right, bbox_bottom, c_red, c_red, c_red, c_red, true);
}
It's safer, since it doesn't set the draw color as a side-effect. For example, look at this code:

GML:
draw_set_color(c_lime);
draw_text(bbox_left, bbox_top, "Player 1");
DebugBBox();
draw_rectangle(bbox_left, bbox_top - 16, lerp(bbox_left, bbox_right, hp / maxHp), bbox_top - 4); // Green healthbar
With your DebugBBox implementation, the healthbar would be red, but without knowing the implementation of DebugBBox, one would expect it to be green.
 

CloseRange

Member
it's for debugging not for final products anyway.
I for one prefer drawing lines as it allows for more flexability than a square. If color is your issue though:
GML:
function fn() {
    var preCol = draw_get_color();
    draw_set_color(...);
    ...
    draw_set_color(preCol);
}
but I suppose drawing a rectangle is fine in this case just not how I like to do things
 
Ok Guys found something that might help. One solution that seems to work for now at least is that I implemented a way for the player to change the player objects movement speed.
I don't know if this will just come back to bite me later though. Since I still don't know why this happens.
 
Can you show your collision check and player movement code? We would get a clearer idea.
Here's the relevant collison code for anyone interested
Code:
if (place_meeting(x+move_x,y,obj_wall_3)){
    move_x = 0
}
if (place_meeting(x,y+move_y,obj_wall_3)){
    move_y = 0
}

if (place_meeting(x+move_x,y,obj_flipwall)){
    move_x = 0
}
if (place_meeting(x,y+move_y,obj_flipwall)){
    move_y = 0
}

x += move_x
y += move_y
 
Top