• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED Problem with my mask position

Dilawlaw

Member
Hi guys, I am working on an 8-bit game and I have a problem with the collision mask of the player where it's not situated exactly as I see it on my sprite. I wrote a code to draw a rectangle showing my collision boundaries ( bbox_left, right top, and bottom). here is a zoomed picture of how the game looks compared to the mask I have on my sprite. which doesn't make sense since the boundaries are taking like half a pixel on top and half on the bottom

1595367227606.png 1595367352076.png

by the way, I am not scaling the player on anything, just did a zoom on the actual game screenshot, as you can see this problem causes the player to get inside the ground

Does anyone have any idea how to solve this?
 

Roldy

Member
Most likely this is caused by bbox values and other collision functions working with integers. If your position is not integer then you may have a difference in the sprite/object position and the bbox position.

Additionally if your sprite origin is set to middle center with an even number of pixels then the middle center is actually a half pixel (not in the center of a single pixel, but between two pixels).

Feel free to verify this and check if it might be the cause of your issue.
 

Dilawlaw

Member
Most likely this is caused by bbox values and other collision functions working with integers. If your position is not integer then you may have a difference in the sprite/object position and the bbox position.

Additionally if your sprite origin is set to middle center with an even number of pixels then the middle center is actually a half pixel (not in the center of a single pixel, but between two pixels).

Feel free to verify this and check if it might be the cause of your issue.
You were right! after double-checking I noticed my y position getting weird float values because of my gravity being none integer. I fixed it by flooring the Y value before calculating the ground touch position, THANK YOU!
 
Top