Archived

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

black_mage_s

Terrain hit detection

Recommended Posts

black_mage_s    103
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
Prosper/LOADED    100
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
Facehat    696
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