Enable Collision Detection
Steps to enable Collision Detection
The steps to enable collision-detection to act on a 3D character are summarized below:
- Enable the character’s kinetics behavior
- Enable the character’s collision behavior
- Set Coefficient of Restitution for character (optional)
- Set Mass of character (optional)
Step 1. Enable Kinetic behavior
Enable the character’s kinetic behavior as shown in the snippet below.
//Line 6. Enable kinetics myAstronaut->enableKineticsBehavior();
Step 2. Enable Collision Behavior
Next, enable the character’s collision behavior to act on the character as shown below:
//Line 7. Enable collision myAstronaut->enableCollisionBehavior();
Step 3. Set the Coefficient of Restitution & Mass (Optional)
The Coefficient of Restitution determines the bounciness of the character. The value ranges from 0.0 to 1.0. A value of 1.0 represents a lot of bounciness and is set using U4DEngine::U4DStaticModel::initCoefficientOfRestitution().
Let’s set the Coefficient of Restitution to a medium level 0.5. And set the mass of the astronaut to 1.0.
//Line 8. Set Coefficient of Restitution myAstronaut->initCoefficientOfRestitution(0.5); //Line 9. Set Mass myAstronaut->initMass(1.0);