Windows Sprite Collision box increasing/decreasing at random [Solved]

Discussion in 'Programming' started by Awesomealan1, Jul 10, 2019.

  1. Awesomealan1

    Awesomealan1 Member

    Jul 10, 2019
    So I recently got into GameMakerStudio, and bought it just yesterday, and have been paying close attention to tutorials/guides.

    I'm currently following this tutorial:

    and at around 25 minutes, the problem this person is having is that the collision box is off center, they quickly fix the problem in the following minutes.

    My problem, however, is that my collision box is changing at randomly as my character moves around. I've used the draw_rectangle to see my collision box, and it's all over the place whenever I move. I'm not sure what's causing it, and i'm certain i've followed the tutorial precisely. I'm not sure what's causing this to happen. Maybe it has something to do with the sprite sheet and the way collisions are handled? Any help would be appreciated.

    download (1).png download (2).png download.png

    I'm unable to upload it as a gif, but these images are seconds after eachother.
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Apr 13, 2016
    What's your draw code to draw the bbox?
  3. Awesomealan1

    Awesomealan1 Member

    Jul 10, 2019
    draw_rectangle_color(bbox_top, bbox_left, bbox_right, bbox_bottom, c_yellow, c_yellow, c_yellow, c_yellow,true);

    Another note in case it's relevant, before, I was using just a single sprite (not a strip) that I used as a test character. It would move in all directions and hit the white boxes as shown in the images perfectly.

    My new one is a sprite sheet, using the draw event to draw the sprites in each direction. I've needed a collision mask to tie the sprite sheet together so that it behaves like a normal, single sprite. It goes over the boxes, outside the boundaries, or it stops a long time before getting close to the boxes.

    Then all this stuff happens with my collision box. I didn't know what the problem was until I actually drew the bbox.

    EDIT: Okay, so after a bit of troubleshooting, the collision is working fine, sort of. He's able to interact with the white walls just as he is supposed to, with collision working in that department. However, the collision box itself is still all over the place, and i'm not sure if that's a problem or not. It definitely isn't shown like that in the tutorial, but collision still works as intended. Maybe I wrote the bbox script incorrectly? I'll double check. But, like I said, collision is working I think.

    SECOND EDIT: I'm glad I had a night to sleep and think on it all. Because i'm stupid. I'm not sure what was causing the collison problem before, but I fixed that. The bbox code? Yeah I messed up. I figured you could just write out each of the sides in any order and it would create the box. Nope. I changed the bbox_left and bbox_top to their correct parts after reading into the function of it a bit more. Fixed everything.

    Everything's fixed! Thanks for directing me to the attention of my bbox, I thought it would not be related honestly.
    Last edited: Jul 11, 2019
    Nocturne likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice