Archived

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

Player over terrain - point or box?

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

What''s the better way for you to implement a player walking over a terrain mesh? a) the easy one, a simple point b) a more accurate but harder one, an axis aligned box? so I have to check 4 points and maybe something else? Thanks.

Share this post


Link to post
Share on other sites
For walking over a terrain, a single point will probably actually work alright so long as you don''t have any really extreme ridges (like two planes meeting in a sharp V sort of formation).

If you want accuracy, a sphere (or ellipse) would be the best choice. An AABB would probably be awkward and error prone since it can''t slide over the terrain very smoothly (or at least not in a logical and physically correct fashion).

----------------------------------------
"Before criticizing someone, walk a mile in their shoes.
Then, when you do criticize them, you will be a mile away and have their shoes." -- Deep Thoughts
"If you have any trouble sounding condescending, find a Unix user to show you how it''s done." - Scott Adams
FaceHat Software -- Wear the hat.

Share this post


Link to post
Share on other sites
box would give a better overall result, although it''s a decision between having the player''s feet go through terrain, or have them hover above the terrain, in case of a sharp incline.


if you have an heightmap, you just get the height of the texel under the point of interest (corners of the box, or the central position of the player). if you do a box, you can either average the 4 corners height, take the highest, or any combinations you like.

if you have loads of entities you need to move around the terrain, a singular point would be sufficient and obviously faster, especially if they are not very visible.

Share this post


Link to post
Share on other sites
Thanks for the replies.

I like the sphere solution, a bit harder than point (more triangles to check at same time) but much easier than the box one.

Regarding the box I''m scared also when a terrain edge '' /\ '' hits a box even when no vertices of the box fall under the terrain... too much hassle, it''s not worth imho

Share this post


Link to post
Share on other sites
unless you have a very spiky terrain, it should be fine, really. Or the character might get something sharp poking where the sun don''t shine. Yeah, spheres are the safest option I guess.

Share this post


Link to post
Share on other sites
Whynote a box or sphere for each foot to determine what the player is standing on.? Heck, even a certain number of vertices in each foot of the model? Can do the same thing for horizontal collision can''t you?

Basically you pick a vertice as a reference, tip of the nose or center of the chest. Check that vertice against other planes to see what has been crossed or not. Same with the feet.

It''s a few more checks that a simple all inclusive bounding box
if you use multiple boxes. However. If you pick 2 vertices on each foot them you only have to check 4 total vertices total to determine where the character is standing on the terrain.

If your charcter has bones it''s then just a matter of telling the root bone how high to be and let the rest of the bone structure actually place the legs and feet.

Note sure but this might be similar to a toned down Inverse Kinematics where the child in the structure controls where the bones higher up are. Well, there would be a mix. The feet would determine the overall height and then the root would determine the actual placement.

Seems like it could work with a little thought applied to it.

Webby

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Depends on what u have access to, but a point and normal data of that point would work just as well...

In fact, if you have a normal map, you won''t need to do any kind of averaging as the normal data should already be smooth.

Share this post


Link to post
Share on other sites
WebsiteWill: well now I need something simple, not so accurate at the moment such as points on foot... maybe later, btw thanks for the idea

AP: yeah I have access to vertices, triangles and normals... so using points sounds pretty easy. I will try with point, than I will experient with a sphere than with an ellipse.

Share this post


Link to post
Share on other sites
This question came up once on the ODE (Open Dynamics Engine) forums and apparently professional games use a cylinder capped with hemispheres (so that it looks like a pill). Using an AABB doesn''t seem like a good idea, since obviously you''re terrain might not be axis-aligned, so you could get some weird effects. Just my two cents.

Share this post


Link to post
Share on other sites