[Solved]Simple Axis-aligned rectangular collision resolution

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

[Solved]Simple Axis-aligned rectangular collision resolution

Post 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:
Last edited by RandomDever on Thu Aug 09, 2012 6:11 pm, edited 3 times in total.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Non-axis-aligned box collision resolution

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Simple Axis-aligned rectangular collision resolution

Post 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?
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Axis-aligned rectangular collision resolution

Post by dandymcgee »

Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Simple Axis-aligned rectangular collision resolution

Post 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.
User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
Posts: 303
Joined: Sun Nov 21, 2010 10:56 am
Current Project: Engine
Favorite Gaming Platforms: N64
Programming Language of Choice: C++, PHP
Location: Norway

Re: Simple Axis-aligned rectangular collision resolution

Post 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.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Simple Axis-aligned rectangular collision resolution

Post 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.
Post Reply