Quantcast
Channel: Answers by "brunopava"
Viewing all articles
Browse latest Browse all 64

Answer by brunopava

$
0
0
I have a script that can be aplied to this. private float _clampingAngle = 90f; public bool isVisible = false; private Camera _mainCamera; private Transform _itSelf; private Transform _cameraTransform; private void Awake() { _mainCamera = Camera.main; _cameraTransform = _mainCamera.transform; _itSelf = transform; } private void Update() { if (Vector3.Angle (_itSelf.position - _cameraTransform.position, _cameraTransform.forward) > _clampingAngle) return; Vector2 screenPosition = _mainCamera.WorldToViewportPoint(_itSelf.position); if(screenPosition.x >= 0 && screenPosition.x <=1 && screenPosition.y >=0 && screenPosition.y <=1) { isVisible = true; } else { isVisible = false; } }

Viewing all articles
Browse latest Browse all 64

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>