Created
December 2, 2020 07:30
-
-
Save chengkehan/e6000f98396c31d8ee82da45f47d661c to your computer and use it in GitHub Desktop.
Check whether is in view frustum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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