In the tick function, we need to check for collision between the sphere and the enemy, as well as the sphere and the ground. Follow these steps to do so:
- To check the number of contacts between objects, we will use the getNumManifolds property of the dynamic world object. The manifold will contain information regarding all the contacts in the scene per update cycle.
- We need to check whether the number of contacts is greater than zero. If it is, then we check which pairs of objects were in contact with each other. After updating the enemy object, add the following code to check for contact between the hero and the enemy:
int numManifolds = dynamicsWorld->getDispatcher()->
getNumManifolds(); for (int i = 0; i < numManifolds; i++) { btPersistentManifold *contactManifold = dynamicsWorld->
getDispatcher()->getManifoldByIndexInternal...