Advertisement

Physics for a 2D game

Started by June 15, 2018 11:30 PM
4 comments, last by Luhan M. 6 years, 6 months ago

I'm working at a mario clone right now, and I'm not so sure about the method which I should utilize for detecting and handling the collision. I did read and watched about GJK, and even implemented kind of the half of it (I'm only able to detect the collision), but I don't know how should I resolve the collision, nor if this method of detection will be able to resolve the "bullet through paper" problem that could arise because of the acceleration.

Here a little video of the GJK (when turns blue, it's colliding) : https://www.youtube.com/watch?v=qafq116kPsE&feature=youtu.be

Any thoughts about the collision method most suited for this kind of game?

 

 

Just use a simple bounding box collision. AABB.

If you're dealing with rotating objects, then you need to look at collision detection using the Separating Axis Theorem.

If you're using a fixed time step you should never have issues with objects passing through walls, this is a problem when dealing with variable time steps.

I would personally use a fixed time step for the physics.

Programmer and 3D Artist

Advertisement
4 minutes ago, Rutin said:

I would personally use a fixed time step for the physics.

I do use fixed time step, but in my previous game (a breakout), I had problems with tunneling, and did need to use raycast.

The problem I'm thinking about is when you're running against some kind of wall repeatedly, which would cause various collision. So, how could I treat it to not let the character penetrate, or if it was penetrated, resolve the collision in a way that if he persists running against it, he wouldn't pass through it? 

Use raycasts to check for collision, if you check out Sebastion League on youtube he covers a super solid way of handling a 2d platform controller that won't go through objects even at very high speeds. 

"I could either watch it happen or be a part of it." - Elon Musk

3 minutes ago, JoshuaFraser said:

Use raycasts to check for collision, if you check out Sebastion League on youtube he covers a super solid way of handling a 2d platform controller that won't go through objects even at very high speeds. 

I'll check it out, thanks for the tip.

This topic is closed to new replies.

Advertisement