- Home /
Scale GameObject to Fit inside a Box Collider?
So in my project, I allow users to import their own GLTF models at runtime. (I'm using Piglet to do this, awesome asset!). BUT, when they get spawned into the scene they often are way too large to be usable.
So I want to scale the object down (without squishing or stretching) to fit inside a set area (Box collider). How would I do this? I've seen answers in the past, but they all set the scale to some uniform Vector3/Squish the model, rather than multiply or divide by the correct value.
I'm just not sure how to do that properly.
EDIT This needs to be done via C# at runtime with an instantiated object.
Answer by ChillFire · Dec 24, 2020 at 08:23 PM
-Hello I did a google search for your problem and found this : Scaling Object to fit inside a boxcollider bounds.size
someone mentioned using Encapsulate()^^
I hope it helps!...if not..well good luck!
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How to Position the object perfectly with the Screen Bounds 0 Answers
Syncing localScale 0 Answers
Multiple Cars not working 1 Answer
Crouch Script/ Scaling transform from one side only 1 Answer