Hi, I got triangle based collision detection implemetation working in my game, I now want to add realistic movement behavior. For that I first added gravity (9.81 * gravityNormal each second to my players velocity) and movement (I move him by setting the XZ values of his velocity according to his movement direction).

Gravity works as planned, he accelerates, falls, and hits the ground (though it's a bit slow). The movent works as well, he climbs over smaller bumps and hills.

The problem I have, is that he's able to climb really steep hills and buildings, provided they're at an slight angle. I know this is due to the fact that I reset the velocity at an collision. When the player hits the ground there can't be any Y movement anymore, so it gets set to 0. Then, with e.g. an X velocity of 3 the player is easily able to climb a hill (his sliding plane makes him slide up) beacuse the gravity didn't have time to build up enough vertical movement.

I thought I'm correct with the math behind my 'accurate' physics approach, but the hillclimbing thing got me thinking I might be wrong.

I tried to overcome this by ignoring approaching walls with too steep angles, but this meant that ground debris (usually visualized as simple boxes) was to steep (since player collides with side and the side of a box has a steep angle).

My collision code (without triangle test):

private void ComputeMovement(ref Vector3 position, ref Vector3 velocity, Vector3 radius, int recursive) { if (recursive > 8 || velocity == Vector3.Zero) return; // Ellipsioid space conversion position = position / radius; velocity = velocity / radius; float t = 1; Vector3 collisionPoint = Vector3.Zero; Vector3 planeNormal = Vector3.Zero; // Compute trianle collision detection (t = factor at wich collision occurs) CalculateCollision(position, velocity, radius, out t, out collisionPoint, out planeNormal); Vector3 newPosition = position + t * velocity; if (t < 1) { // Create sliding plane Vector3 collisionNormal = Vector3.Normalize(position - collisionPoint); Vector3 destinationPosition = position + velocity; Plane slidingPlane = GeometryMath.PlaneFromPointNormal(collisionPoint, collisionNormal); Vector3 newVelocity = (destinationPosition - slidingPlane.SignedDistance(destinationPosition) * slidingPlane.Normal) - collisionPoint; // Check for steep hill float normalDotVelocity = Vector3.Dot(collisionNormal, velocity); if (Math.Abs(planeNormal.Y) < 0.707f && normalDotVelocity < 0) newVelocity.Y = 0; // Compute recursive function position = newPosition * radius; velocity = newVelocity * radius; ComputeMovement(ref position, ref velocity, radius, recursive + 1); return; } position = newPosition * radius; velocity = velocity * t * radius; }

There really must be something wrong, can't be that I can only have one or the other.

Would really appreciate any help on this.