Sliding Sprite Collisions

Advanced game related topics
Cammar
New User
New User
Posts: 8
Joined: Mon Mar 20, 2006 2:55 pm

Sliding Sprite Collisions

Post by Cammar »

I'm trying to setup simple bounding box collisions with 4 directional movement. I have a sprite with a bounding box on it, the sprite moves around the screen in 4 directions. I want to setup a series of box's on the screen that the sprite bounding box can collide against. That part is easy enough, but I want the sprite to slide against the edge of the box its colliding with. So if the sprite collides with the box from the side I want the sprite to still be able to move vertically. Any one have any psuedo/code to share?
Thanks
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

First, if this is 2D then theres no boxes but squares.

So, really, doing a calculation in one more dimension that you need, is not very wise :D


The sliding is part of the collision response and not the detection. I recommend you to read about collision response and start your own sliding response, if you get stucked then post the problem and we'll join forces to help you solve it.

I believe its better if you understand the entire process before!.

If you find it too hard, I will post an example of custom 2D collision with sliding response, if it makes anyone happy that is. But you should try first.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Cammar
New User
New User
Posts: 8
Joined: Mon Mar 20, 2006 2:55 pm

Post by Cammar »

When I said box I meant a 2D box/square :D (Not used to 3D terminology). Time for a google crawl for rigid body physics and that glorious stuff!
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

:? I think a box is not the same as a square... I know what you meant but It's just that it's wrong. For example when people saids "I need a couple of ..." Well a couple means 2 but they'll grab more than 2, They refer as a "bunch" but the world COUPLE means 2... Same thing in this case almost, box, square.. none are the same.

And yes, "google will provide"
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Cammar
New User
New User
Posts: 8
Joined: Mon Mar 20, 2006 2:55 pm

Post by Cammar »

Aha Success! Simple enough really no need for real physics in my situation at least. Thanks Captain "dagcrack" Pedantic anyway for the offer :D
Post Reply