[SOLVED] Raycasting to any object in a scene

Hi guys! Does anyone know how I can raycast from a point on the screen, and detect any collisions with any object on the screen?

Use rayCastFirst();

rayCastFirst API documentation

rayCastFirst with Collision Example code

u need screenToWorld from your camera :


this.cameraEntity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.cameraEntity.camera.farClip, ray.direction);

where screenPosition is your 2D click on the screen & where Ray.direction is the vector u get as return in your 3D world.

or just look at point&click tutorial.

1 Like

Thanks guys! I have figured this out now! Thanks for all the help :smiley:

1 Like