This topic is 5234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know this would have been asked before but i couldn't find exactly what i was looking for or i just didn't understand the stuff i read. Anyway i'm making a 3d tiled based game and i have collision detection working and at the moment i just move the player back to it's old position when there's a collision. What i want is so the player moves along the edge smoothly when two movement keys are down. Each key only moves the player on 1 axis. eg left moves the player -x direction and up move the player +z direction etc... All the tiles a identically sized cubes. what i realy need is to know what side of the cube the player collides but i can't think of a stable way to do it. I tried checking the player's old position and seeing where it came from and get the side from that but the corners still didn't work right. Anyone with any surgestions. thanks

##### Share on other sites
How about projecting the movement-vector onto the colliding-plane, and using that for moving instead?

##### Share on other sites
but i don't know the colliding plane. that's what i want to figure out.

##### Share on other sites
Ahh thanks that gave me an idea and it worked. Would this work alright under slow speed though? I get the distances from the oldposition to 4 sides of the cube. I then move the player according to which distance is the shortest. The collision detecting is only really 2d i do the y movement part seperately.

##### Share on other sites
It doesn't look like a very costly calculation, especially if you skip the sqrt() for the distance.
But why don't you just do it in 3D instead? Since it's just cubes it's no problem really. Just construct a plane for each side of the cube, and check for intersection between the movement-vector and the planes. If you find an intersection, clip the vector to the plane.

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633757
• Total Posts
3013711
×