Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

black_mage_s

Terrain hit detection

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

okay, this is not so much a problem as a strange quirk. the hit detection engine i got in another topic seemed to work fine uuntil there was an angle of 90 degrees. when you run into this angle, the player stops and cant go any further.is there any way to fix this?

Share this post


Link to post
Share on other sites
Advertisement
I can''t really help without the algorithm but the problem may be that it uses the tan() function to compute some value. Since the tan mathematical function isn''t defined for 90°, the tan() C/C++ may return strange values and therefore generate weird bugs.

Share this post


Link to post
Share on other sites
Ah, its because the code shoots a line straight down, parralell to the x/z axes, however, when you have a 90 degree incline you''re trying to get the collision point of a line thats paralell with the plane, so there are two possible outcomes: 1) no hit, or 2) infinite hits, in which case the line/plane collision function will probably fail. So, for walls and such you need a different method for detecting collisions -- the example code I showed only works for terrain grids.

---------------------------
FaceHat Software -- Wear the hat.

Share this post


Link to post
Share on other sites

  • 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!