Sign in to follow this  
Triad_prague

How did he do it?

Recommended Posts

Hi, right now I'm trying to make a complete game and I'm at the stage where I have to do some math/physics so the char can walk on the levels. I had been using heightmap and things was simpler that time (just compare char.y with height at the char's xz loc and adjust height accordingly). But now I'm not using terrain anymore, and then I got confused on the collision detection between player and the levels.

Basically the game I'm building now is pretty much inspired by this game by Aaron Bishop
[url="http://www.youtube.com/watch?v=_yBxnGDe_Hs"][Soulfu Video][/url]
I wonder how he did the collision part, it's quite awesome. stand on inclined plane without slipping, automatically move above small step (like stairs)...and please don't tell me to use a physics engine or such, I'm trying to grasp the basic concept here, yes I'm learning. Can anyone give a hint on how he did that? a link to a paper or sites, cause my google-fu is predictably weak :huh:

Thanks before btw :lol:

Share this post


Link to post
Share on other sites
When implementing my collision detection (which I no longer use as physics engines are so much better) I based it around this: http://www.peroxide.dk/papers/collision/collision.pdf which currently doesn't seem to work but this is similar: http://www.three14.demon.nl/sweptellipsoid/SweptEllipsoid.pdf

No reason why you can't also use a heightmap/terrain, I can see the two working together with very minimal effort and it would bring a speed saving.

Share this post


Link to post
Share on other sites
You can accomplish what you want by using rays cast against geometry to determine intersection points. Consider you have your player standing on the ground. You can cast a vertical ray downward and determine the intersection of that ray and the ground to find the spot to place the player object. This is basically what you are doing when you determine the elevation in a heightmap. But the same principle applies to non-heightmap geometry. For example, now say that your player takes a step. You can cast a ray downward at the location of where the step would take him, and calculate again the Y height (ray/polygon intersection calculation is fairly simple). This time, the ray intersects a ramp. The difference in Y between the player's current location and the new location is compared. If the difference is too large, then the player can not step there since it would require climbing too high. If the step is deemed to be allowed, then the player is moved to the new location.

In one of my older projects, I would perform movement and interaction in this way. Each time the player took a step, I would calculate the new X/Z location for the player, and calculate the new Y as the player's current Y plus his maximum Step-Up height. I would then use this new point as the origin of a downward ray, and calculate the Y intersection. If no intersection was found, this indicated that there was no geometry underneath the new point (which could occur if the new point was inside a wall and there was no floor below it), and the movement was disallowed. If an intersection was found, then I would construct a collision volume at the new location, and test the volume for any collisions. If there were collisions (which could occur if the new point lay inside a piece of geometry) then the move was disallowed.

As an aside, in later iterations I used the [url="http://code.google.com/p/recastnavigation/"]Recast and Detour[/url] library to simplify the process by constructing a navigation mesh. The navigation mesh is constructed with parameters representing agent maximum Step-up and agent Height, and locations in the mesh where an agent could not possibly get to based on its height and step-up value are automatically excluded from the final mesh. The result is a mesh that is a sub-set of the original level area, representing all areas the agent can possibly get to, with functionality to determine the height location of a given input point, as well as built-in pathfinding functionality to determine a path between any two connectable points. Doing the agent-height culling of areas in the nav-mesh generation eliminates many of the agent->world collision tests, since if a location has too little headroom for the agent to stand there, that location is culled from the final nav-mesh.

Share this post


Link to post
Share on other sites
@Nanoha I read the paper, and coded a demo on that. unluckily, it's quite "heavy" (recursive), and basically I still can't solve the "stand on inclined planes" problem :huh: I'll try to see if I can "merge" heightmap with the customized mesh levels...altho I'm not quite sure

@JTippets that sounds good, I'll try to grasp the concept first. but I think if I do it that way, the player would look "ugly" when it stands on a steep hill (since raycast is done from its center aka a single point), in soulfu I think it worked that way, but instead of single point, it seems to raycast a bounding volume (a cylinder? I dunno). I'll study this method first, since I guess it's not recursive and quite light than other methods...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this