Skip to content

format

typescript
Camera.ViewportPointToRay(point)

class: Camera

description

Returns a ray from the camera through a viewport point.

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

parameter

param_nametypedescription
pointVector3The viewport coordinates used to emit the ray.

reture

typedescription
Ray

code example

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