I\'m trying to play a sound and then destroy two objects of two different types when they collide using Sceneform. I see that Sceneform has a collision api (https://developers.g
The intersection methods you are trying to override do the math to calculate if two collision shapes are intersecting, I recommend against overriding them.
Currently, there is no listener or method you can override to detect when nodes overlap. However, there are functions you can call to test for overlapping nodes.
You can use Scene.overlapTest or Scene.overlapTestAll, which uses the CollisionShape from the Node.
By default, it will automatically use a collision shape based on the dimensions of the Renderable attached to the Node. You can use Node.setCollisionShape to override the collision shape for the node, or to set collisions on a Node that doesn't have a Renderable.
You can achieve the effect you are looking for by doing something like this:
private void onUpdate(FrameTime frameTime) {
ArrayList overlappedNodes = arSceneView.getScene().overlapTestAll(ballNode);
for (Node node : overlappedNodes) {
if (node instanceof PassiveNode) {
// May want to use a flag to check that the node wasn't overlapping the previous frame.
// Play sound if overlapping started.
}
}
}