Sign in to follow this  

sorry for asking but...

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this