Page 1 of 1
I'm having problems with collisions in my game
Posted: Mon Aug 14, 2023 8:37 pm
by MaxGamz
I am using Box2D for my physics and I am having trouble my player clipping into the walls and getting stuck in mid air, I am trying to simulate zero gravity in my game or at least an underwater feel so I'm not sure if that could be the cause
The controls are the standard "WASD"
I also have trouble getting the player to appear clearer after scaling it up
Re: I'm having problems with collisions in my game
Posted: Tue Aug 15, 2023 7:49 pm
by Azzla
For the scaling problem (assuming you're using pixel-art) use
Code: Select all
love.graphics.setDefaultFilter('nearest', 'nearest')
For the collision problem, I recommend just switching to something simpler like
bump. It is fast, comes with several ways to handle resolution, and is generally good for axis-aligned platformers like yours.
If you want to stick with Box2D, please provide a snippet of your collision code.
Re: I'm having problems with collisions in my game
Posted: Tue Aug 15, 2023 8:07 pm
by knorke
the body might get stuck because it rotates when sliding along the walls and corner.
you only use its x,y position for drawing but not the rotation angle.
so your graphics and the physics body are not fully in sync.
there is a function to set fixed rotation, try that.