Page 1 of 1

[Solved]Simple Axis-aligned rectangular collision resolution

Posted: Tue Aug 07, 2012 8:57 pm
by RandomDever
All I need is how to resolve collision when the moving object is moving diagonally.
I have already implemented one-directional resolution but whenever the object moves diagonally the object jumps like he collided on the x axis ( because this is checked before y ).
Example code or article links are greatly appreciated. :)

Edit: Edited the subject because I am an idiot. SHOCKER! :shock2:

Re: Simple Non-axis-aligned box collision resolution

Posted: Tue Aug 07, 2012 9:11 pm
by dandymcgee
RandomDever wrote:All I need is how to resolve collision when the moving object is moving diagonally.
Umm.. AABBs can move diagonally, so I'm assuming you mean detecting collision between objects which are not axis-aligned?

If so, search the forums for one of the many Separating Axis Theorem posts.

Re: Simple Axis-aligned rectangular collision resolution

Posted: Tue Aug 07, 2012 10:18 pm
by RandomDever
Yep I said that but that's not what I mean't.
Just simple rectangular collision which is Axis-aligned I guess.
Just so I don't have to edit the entire post again axis-aligned means no rotation right?

Re: Simple Axis-aligned rectangular collision resolution

Posted: Wed Aug 08, 2012 8:27 am
by dandymcgee

Re: Simple Axis-aligned rectangular collision resolution

Posted: Thu Aug 09, 2012 12:40 am
by RandomDever
Thanks dandymcgee that first article worked like a charm.
I now have a basic physics engine. :mrgreen:
BTW does anyone know why my rendering is jumpy?
It seems to jump consistently every second. So I render a square moving 60 pixels per second and every second it jumps ahead a few pixels. It's not super noticeable but it is noticeable.

Re: Simple Axis-aligned rectangular collision resolution

Posted: Thu Aug 09, 2012 11:08 am
by superLED
RandomDever wrote:Thanks dandymcgee that first article worked like a charm.
I now have a basic physics engine. :mrgreen:
BTW does anyone know why my rendering is jumpy?
It seems to jump consistently every second. So I render a square moving 60 pixels per second and every second it jumps ahead a few pixels. It's not super noticeable but it is noticeable.
I had that shit in my programs as well. I think it was something to do with the 60 FPS-limitation. After a second, it noticed that the program was running too fast, and then slowed down a bit. Or hurried up, depending on the CPU-speed.

Re: Simple Axis-aligned rectangular collision resolution

Posted: Thu Aug 09, 2012 6:10 pm
by RandomDever
I reduced the frame rate to 50 and seems to be better.
But running at such a low frame rate makes getting a fast velocity to look good difficult.
But I'll see how it looks when I test animation and I'll return here if I have any questions.
Marking as solved.