Gamestudio Physics - Frequently Asked Questions

Q: How can I learn about using physics?

A: Workshop 19 of the tutorial gives an introduction into physics functions. Also, look into the earthball8.c and physXtest.c samples for simple physics, and into the car.c script for vehicle physics.

Q: How do I move a physics entity ?

A: Apply a velocity, force or torque to it. Don't attempt to change its position or orientation directly by altering his x,y,z coordinates or angles, or by c_move or c_rotate - this won't work for physics entities.

Q: My objects vibrate strangely.

A: Physics engines apply small vibrations to dynamic objects. They can become noticeable when physics properties like mass or elasticity have bad proportions. You can also use pX_setautodisable for automatically putting objects to sleep.

Q: My objects fall through the floor, or penetrate walls.

A: This happens when objects or walls are smaller than the distance covered in one frame cycle. Either make them bigger, or use continous collision detection.

Q: I'm letting a ball roll over a course made of models, but sometimes the ball strangely jumps or stops where the models touch.

A: This is due to small gaps between the models. Let them overlap a little, or adjust the penetration depth (pXent_setskinwidth).

Q: After setting up constraints, my game is running very slowly. What's wrong?

A: The constrained objects penetrate each other at the time of creation, or the constraint parameters are set up incorrectly.

Q: How can I restrict movement to two dimensions?

A: Call pXent_setbodyflag with NX_BF_FROZEN_POS_Z for limiting the movement to the x and y axis.

Q: How can I create a chain or rope?

A: Use fixed length segments with PH_BALL joints. For winding and unwinding the rope, add or remove segments at the end. For simple ropes without segments, use a PH_ROPE joint.

Q: How can I create a ragdoll?

A: Use PH_CAPSULE entities for the limbs, connect them with PH_HINGE joints, and call ent_bonerotate and ent_bonemove to update the ragdoll model according to the limb entities' positions and orientations. There's an example code on the user forum.

Q: How can prevent the collision of a certain physics object with another object?

A: Use pXent_setgroup to set both objects to the same group. Objects of the same group don't collide with each other.

Q: Why can't I detect a physics entity with c_move or c_trace - even after unregistering it?

A: pXent_setgroup sets the entity's group to the given number. Depending on the collision groups you're using, you might need to set it to a different value or back to 0 for using c_trace or c_move functions with the entity.

Q: How can I directly move a physics object (instead of applying a force)?

A: Use pXent_move.

See also:


► latest version online