Collision and body for a "character"

AndroidAdam

22-10-2008 05:11:58

Hi, I'm having a bit of a problem with my player characters (the model that the player controls.)

My problem is with the character "bouncing" too much. While the physics are great for things like wooden barrels and balls, the only thing that I want from my character is to make sure that it doesn't go through walls or the floor.

Here's my code. (sorry it's in C# using MOGRE and MOGREnewt. If it's too much trouble I'll rewrite it in c++)

Entity steven = sceneMgr.CreateEntity("SteveMain", "Stephen.mesh");
SceneNode steveNode = sceneMgr.RootSceneNode.CreateChildScene();
steveNode.AttachObject(steven);

Collision steveCol = new MogreNewt.CollisionPrimitives.ConvexHull(world, steveNode);
Body steveBody = new Body(world, steveCol);
steveCol.Dispose();

steveBody.IsGravityEnabled = true;
steveBody.AttachToNode(steveNode);
steveBody.SetMassMatrix(mass, Vector3.ZERO);
steveBody.SetPositionOrientation(stevePos, steveOrient);


I'm new to both OGRE and Newton and any help would be appreciated!

BardockSSJ

22-10-2008 22:40:01

steveBody.SetMassMatrix(mass, Vector3.ZERO); <-- i gueess not good!

Also u can set material pair with 0 elasticity ...

AndroidAdam

23-10-2008 04:19:02

actually that worked out exactly as if I had given it inertia.

Anyway thanks for your reply, I'll try your suggestion when I get home.

micken

23-10-2008 23:17:31

You also might try using a primitive collision object. The convexhull is very complex and can be affected by physics in many ways. If you just want to keep it from going through walls and floors it's much more efficient and easy to think about to use a primitive shape like a box or ellipsoid. My favorite is the ellipsoid because it has no straight edges. Straight edges will cause you grief if your walls and floors are not also straight.

AndroidAdam

26-10-2008 14:31:34

Alright, thanks for the tip!