Skip to content

Instantly share code, notes, and snippets.

@chengkehan
Created December 2, 2020 07:30
Show Gist options
  • Save chengkehan/e6000f98396c31d8ee82da45f47d661c to your computer and use it in GitHub Desktop.
Save chengkehan/e6000f98396c31d8ee82da45f47d661c to your computer and use it in GitHub Desktop.
Check whether is in view frustum
Vector3 pos = targetTransform.position;
Matrix4x4 vp = mainCamera.projectionMatrix * mainCamera.worldToCameraMatrix;
Vector4 porjPos = vp * new Vector4(pos.x, pos.y, pos.z, 1);
// projPos.xyz / projPos.w [-1, 1] in view frustum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment