Jump to content

A collision detection question~~


photo

Recommended Posts

i want to implenment collision detection between camera and a box mesh

in game scene i want to know what the object collided with camera's collision sphere..

if the box collided with camera then i disabled the box (don't render the box)..

how can i do?

Link to comment

1. First of all, you need to get all objects that your player has collided with during the physics simulation frame using player.getNumContacts().

2. Then what you need to do depends on whether your box is a simple static mesh or a physically simulated object:

  • If it is static mesh, go through all the contacts and check if it is the necessary box (box surface, to be exact) via getContactSurface().
  • If you want a physical box, you need to assign a body and a shape to it (see the tutorial for how to do it). Loop through the contacts and check for the box object via getContactObject().

3. If the player has collided with the box, disable the box node by calling box.setEnabled(0).

  • Like 1
Link to comment
×
×
  • Create New...