Collisions and sliding

Blitz3D Forums/Blitz3D Programming/Collisions and sliding

Steve Hill(Posted 2003) [#1]
I am writing a simple dungeon crawler and have a problem with collisions and sliding behaviour. Basically if the camera jumps into a corner, then it encounters two collisions with the adjacent walls ... so far ok. However, rather than sliding down (under my gravity), it stops.

I am using the slide collisions behavour (not full slide). With full slide this works as expected, but I don't want my character to slide back down slopes etc.

Does anyone have a workaround for this?


Ross C(Posted 2003) [#2]
hi, sorry. i'm a wee bit confused. you don't want the character to slide down slopes, but you want it to slide under your gravity? Could you clear that up for me? thanks


jhocking(Posted 2003) [#3]
Yeah, your description is inconsistent. Sliding down slopes IS sliding due to gravity; if you want objects to slide due to gravity they are going to slide down slopes.

Re-reading, it sounds a little like (pretty vague though) you want full sliding collision detection for the camera but not for the character. In that case just set the camera and character to different EntityTypes and use two separate Collisions statements for camera-to-walls and character-to-walls.


Steve Hill(Posted 2003) [#4]
Well, there's sliding and sliding :-)

I don't want to slide down a ramp, but I do want to slide down a vertical wall. Perhaps what I am wanting is unreasonable. As it stands though, you can wedge yourself in the corner of a room by jumping up and moving forward (which would be a nimble and athletic thing to be able to do, but not very realistic).

The point is that in the corner there is nothing underneath your feet preventing gravity from working. I assume the walls are not made of glue. On a ramp there is something, albeit at an angle.

I guess I could use full sliding collisions and look at the surface normal below my feet and apply a suitable frictional force to counteract the gravity.

In my case the camera is the same thing as the character, I was just being loose tongued.


jhocking(Posted 2003) [#5]
Ah, what you want is to check the collision normal (using commands like CollisionNX.) That will tell you the angle of the polygon collided against. Then you can react differently depending on the normal.

What I would do (ie. this may or may not be the best way) is to actually turn off "gravity" if the surface collided against is at a shallow angle. Thus there is no force pulling the character down when standing on ground up to a certain angle.

EDIT: Didn't read the last couple lines of your post until just now. The second to last line is essentially what I just suggested.


Ross C(Posted 2003) [#6]
yeah, i would use the collisions normal command, and specify an angle which sliding will occur, don't apply gravity if the angle is less than say 45 deg. a bit like tomb raider.