hey
I’m quite new to JME and am only starting to understand some of the concepts.
I’m trying to create a box at wherever i click, i have a floor and am trying to use a ‘ray’ produced from the camera to find the collision point on the floor and create a box at those coordinates!
can someone please help? my game just freezes when i right click.
this is my ActionListener method:
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals(“shoot”) && !keyPressed) {
makeCannonBall();
}
if (name.equals(“place”) && !keyPressed) {
public int y;
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
CollisionResults results = new CollisionResults();
ray.collideWith(rootNode, results);
results.getCollision(y);
}
}
};
The thing I can see when I look at the tutorial is:
ray.collideWith(rootNode, results);
should be
shootables.collideWith(ray, results);
Where shootables is the node in which you have everything you want to collide with, I’d recommend not having rootNode there since I think you’ll hit the camera when you try (if I remember correctly).
Hope that’s all there is to it
2 Likes