Skip to content

format

typescript
Camera.ScreenPointToRay(point)

class: Camera

description

Create a raycast from a screen point.

The generated ray is in world space, starting from the camera's near plane and passing through the specified pixel coordinates on the screen.

parameter

param_nametypedescription
pointVector3The screen coordinates used to cast the ray.

reture

typedescription
RayA ray from the camera's near plane, passing through the position (x,y) in pixel coordinates on the screen.

code example

typescript
let camera = this.gameObject.GetComponent<Camera>(Camera);
camera.ScreenPointToRay(new Vector3(1,1,1));