Skip to main content
gamedev.net
🔒 Locked

Basic collision detection

Started by danne89 Dec 14, 2005 at 4:54 AM 1 replies 450+ views
Original Post
danne89
danne89
Hi! I'm making my first 3D game. I like to restrain the player in a certain area. What I'm doing right now is:

if(playerPosZ < 6.0 && playerPosZ > -6.0) { move() }
...
The problem is, that you begin to glide when you move towards a wall in an angle. My friend say this is a common problem, but still I cant find any information about it neither here nor using Google. Daniel Lännström
http://www.cis.gsu.edu/~shong/oojokes/
LilBudyWizer
LilBudyWizer
My guess would be that you need to move them back the direction they came from and are most likely moving them perpendicular to the wall instead. That gives them a movement parallel to the wall. Say you have a wall at x=0. The player is at (5,0) and moves by (-10,10) which would put them at (-5,10). They can't move through the wall though so you move them by (5,0) to (0,10). The result is they logically move from (5,0) to (0,5) to (0,10), i.e. they slide along the wall by 5 units. Instead when they were found to be at (-5,10) they should have been moved by -0.5*(-10,10)=(5,-5) so they end up at (0,5), i.e. they got stopped by the wall.
Keys to success: Ability, ambition and opportunity.
danne89
danne89
Yeah, you are so right.
http://www.cis.gsu.edu/~shong/oojokes/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.