Jump to content
  • Advertisement
Sign in to follow this  
Beaverbutt8

Whoa! This is some wierd collision

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!