Public Group

Whoa! This is some wierd collision

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

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 on other sites
Show us the camera code.

Share on other sites
It's the apron tutorials camera, quite a bit of code

http://www.morrowland.com/apron/tut_gl.php

it's the first person cam

Share on other sites
wait! hold that thought, i figured out something! yay!

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 on other sites
if ( objCamera.mPos.z > 28.0f) { objCamera.mPos.z -= (the distance moved since last visit)}

maybe that will stop you from braking through...

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 :)

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 28
• 15
• 39
• Forum Statistics

• Total Topics
634836
• Total Posts
3019544
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!