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)
Enable the character’s kinetic behavior as shown in the snippet below.
//Line 6. Enable kinetics myAstronaut->enableKineticsBehavior();
Next, enable the character’s collision behavior to act on the character as shown below:
//Line 7. Enable collision myAstronaut->enableCollisionBehavior();
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);