- Home /
Can you scale a Mesh independently of it's Collider?
Hey there guys,
My objective is to scale an active rigid body's size (perhaps only the mesh renderer?!) without affecting it's collider. The scaling is intended to be minor, very brief and usually whilst the object is in the air and not contacting any other objects. There will be times when this object is in contact with the ground though and I'd obviously like to avoid physics abnormalities.
Ideally I'd like to use iTween's punchScale function, unfortunately this automatically sets the object to kinematic whilst in operation. This causes obvious glitching.
The only way around this that I can think of is scaling the collider down first, immediately followed by scaling the object's transform up so that effectively the collider remains relatively the same size. I don't like this solution as not only is it only possible on objects with a few of the simple unity colliders (sphere - radius, box, maybe capsule), it seems messy, hacky and unnecessarily expensive!
Can anyone throw me a bone?
Many thanks in advance,
Rowley
Answer by whydoidoit · Jul 19, 2012 at 10:44 AM
Have the collider attached to a different branch or object in the hierarchy from the object with the renderer. Then just scale the object with the collider and leave the other object/branch alone.
Player -------> Player Rendering Object
|----> Player Colliding Object
Wow, I can't believe I didn't think of that slaps forehead. I'll blame it on a brain-fart! Thanks $$anonymous$$ike, you're a legend!
Thinking about it a little whilst at work, I'm guessing the rendering object needs to be the child of the actual colliding object and not the other way around. If the colliding object is a child of the rendering object (which I am scaling) the collider would inherit the rendering object's scale no? Regardless I have some testing/experimenting to do when I get home! Thanks again.
Your answer
Follow this Question
Related Questions
Scaling the Mesh Collider 4 Answers
Scale collider independent of gameObject. 1 Answer
Set Colliders at same size 2 Answers
Why attach a kinematic rigidbody to a collider that moves a lot? 1 Answer
Catapult question 2 Answers