Sign in to follow this  
Beaverbutt8

Whoa! This is some wierd collision

Recommended Posts

Hey everyone, I finnaly got some simple boundin' box collision figured out, but there's a wierd problem. My camera is based on the one from apron tutorials. Well here's what i did. There's a wall at z = 28. So i made an if else statement - if ( objCamera.mPos.z > 28.0f) { objCamera.mPos.z -= 2.0f; } Ok, cool. So to test it, i ran into the wall. For a few seconds it stopped me, but then i broke though. When i stepped back, it had increased the camera's speed in all directions signifigantly ( did i spell that right? :P ). Kinda wierd. So, what do i do about this?? o_0 ~ Thanks :D Mike

Share this post


Link to post
Share on other sites
heh i had this problem before as well, i know you've figured it out already, because it's one of those silly things that you realize is obvious but it bugged me for like half an hour when i was first learning openGL :P

its like, because you're saying "if i cross this line, push me back this far", if you might get pushed back a little but then be able to skip past the line, and it wont do anything.

also, if you use objCamera.mPos.z >= 28.0f instead of just >, the same thing could happen. thats why i tend to use collision prediction instead of detection, so that movement is inhibited when you reach a collision, not reversed. know what I mean?

like the wall stops them, because they bumped into it, it doesn't spit them out because they moved inside of it.

Share this post


Link to post
Share on other sites
how about

if ( objCamera.mPos.z > 28.0f)
{

objCamera.mPos.z -= (the distance moved since last visit)

}

maybe that will stop you from braking through...

Share this post


Link to post
Share on other sites
What i did was, instead of push my player back, i just stopped him - prediction, like AAPP said


if ( objCamera.mPos.z > 28.0f)
{

-CAMERASPEED;

}
As simple as that :)

Share this post


Link to post
Share on other sites

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