Quantcast
Channel: Questions in topic: "performance"
Viewing all articles
Browse latest Browse all 173

Performance: Addcomponent BoxCollider in update method

$
0
0
Hello, I have 10000 GameObjects (non-moving objects) that I instantiate in unity. Which is better in terms of performance: 1. Add a BoxCollider to all objects when instantiated 2. Add BoxCOllider to the objects when the camera is close to the object using the update method private void FixedUpdate() Vector3 CameraPos = mainCam.transform.position; Collider[] colliders = Physics.OverlapSphere(CameraPos, radius); foreach(Collider hit in colliders) { if (hit.gameObject.GetComponent() == null) { hit.gameObject.AddComponent(); } } } I need BoxCollider because the camera should not go through these gameobjects. - Target platform: Mobile phones - Performance concerns: 1. Ram: adding multiple components 2. CPU: adding BoxCollider component at runtime Which one is better? Thank you very much.

Viewing all articles
Browse latest Browse all 173

Trending Articles



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