How to dynamically scale an object to a fixed, predefined size at runtime?
I have a situation where game objects are spawned at run time, and these game objects can all be very different sizes. They're all scale 1 when they spawn, but their meshes and mesh renderers are different sizes.
Now I would like to implement a script that takes the spawned object, and makes sure that it is a fixed, predefined size after spawning, preferably by scaling it so that both colliders and meshes follow.
For example, both an apple and a horse can be spawned, and I don't know which it is until after it has spawned since it is random. They appear very differently, due to the large difference in their mesh and collider sizes. In this specific scenario (but not always, so I don't want to resize the original objects), I would like the apple and horse to be the same size, in Unity units, in the scene after spawning.
What is the best approach to specifying this size? A mesh? A collider? And what is the best approach to resizing the spawned object to this fixed size?
Thank you!
Your answer
Follow this Question
Related Questions
Colliders position and scaling are misaligned with object meshes 0 Answers
object has no mesh 0 Answers
Why are my Physics.RayCast not showing the collsion with the Ground? 0 Answers
How to fix Unity 5 Mesh Collider Convex Problems? 1 Answer
Content Size Fitter should scale only in one direction 0 Answers