Sign in to follow this  

Check Every frame in game

This topic is 3486 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

For my collisiondetection i check if the player is < 0.3f distance to a plane, this isnt working because when the player is <0.3f he has come to close to the plane. How do you check every frame? i want to save the status before player moved and compare this one against when player moved so i can back the player if he is to close. Also, i can perform this: Frame 1: Player is Facing plane Frame 2: Player is not facing plane and distance is to short = player hit the plane. basically i need good structure for checking every frame in my game app so i can use old player locations. Right not i can sortof do this because i always have the pos before the player moved but i think checking everyframe is more accurate then check before movement.

Share this post


Link to post
Share on other sites
I don't know much about this, but I think what you are looking for is called "continuous collision detection". Doing a google search brings up some interesting results.

BTW, what you are describing is called "frame-to-frame-coherence". Google is very helpful here as well.

Share this post


Link to post
Share on other sites
Quote:
Original post by Meshboy
How do you check every frame?

What? You call your collision routine before or after every time you draw your scene?

Quote:
i want to save the status before player moved and compare this one against when player moved so i can back the player if he is to close.

You're not making much sense to me... but if I understand correctly you want to know if the player is GOING TO be too close to the plane.
You can advance the player position one timestep (newPosition = oldPosition + velocity) and check that new position against the plane.

Quote:
Also, i can perform this:

Frame 1: Player is Facing plane
Frame 2: Player is not facing plane and distance is to short = player hit the plane.


I'm trying to read between the lines here, so correct me if I'm wrong. Are you asking this question because your player gets stuck in the plane and you see him shaking as he does?
If so, there is an additional check (other than just the distance) you can do to see if there REALLY was a collision. You can check if the player is moving TOWARDS or AWAY from the plane. If the player is moving towards the plane AND within the collision distance you have a collision.
However, if he is moving away from the plane AND within the collision distance you don't have a collision.
Basically you take the dot product of your plane's normal and the velocity vector. If it's smaller than 0 your player is moving towards the plane, if it's greater than 0 it's moving away from the plane.

Share this post


Link to post
Share on other sites
You can also do a double check to see if the player/object has passed through an triangle.

First check the sign (+/-) of the player position to the triangle.
Then check the sign of the player position + velocity change.
If these differ from eachother the player has passed through the triangle.

/Robert

Share this post


Link to post
Share on other sites

This topic is 3486 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