I can't get my code to find out exactly where I click and place a ball

Hey @spookelix, so if you’re looking for the X,Y,Z vector for a point that you click in a 3D space, you’ll need a PickingInfo object. Off of the top of my head, you can get this by doing something like this:

scene.onPointerObservable.add((eventData) => {
    // If there's a hit on some mesh
    if (eventData.pickInfo.pickedPoint) {
        // Do something with the pickedPoint vector
    }
);

In this modified form of your PG (zaxis | Babylon.js Playground), depending on where you click on the green plane, your sphere will appear. It should also be noted that with onPointerObservable, you will need to account for the type of event that you want to do things for because it handles everything from movement to button presses.

1 Like