Reputation: 25
I've been coding with javafx recently and I've rendered a cube and another cube, one cube is connected to the camera which moves when the user presses 'w', (connected as the cube moves when the camera moves). I'm trying to detect when one node collides with the other, I've tried taking the translation of 'x' on the cube connect to the camera and the translation of the other 'x' on the other cube which works but the 'z' doesn't work because the world moves and rotates instead of the camera so i cannot do that.
How can I use the attribute intersects of one javafx box to another javafx box to detect the collision. I've tried multiple ways of detecting collision, most seemed to have intersects to be the answer but they had 2d shapes instead of 3d boxes. This is what I have, either they never execute or they execute when the statement is called (getbBoundsInParent, getBoundsInLocal, getLayoutBounds). This isn't all the code, I put what I thought was relevant. How can i detect collision with intersect of a 3d javafx box?
if(eyes.getBoundsInParent().intersects(cube.getBoundsInParent())){
System.exit(0);
}
Upvotes: 1
Views: 32