How would I scale and rotate any type of collider in 3D with the current scale and rotation of the transform the collider is currently attached to WHILE playing the game? This makes it useful for when I need to do a slide under a wall in my game.
It can use either bounds size / rotation or anything else related to that as well.
Can you show me a picture? I don’t think I quite understand what you mean. Mesh Colliders already match the transform’s changes that they’re on during Play mode, so you must mean something else from what I’m imagining.
CharacterController always acts as an upright capsule. Capsule and other simple colliders also do not react to non-even scaling, as they’re optimized for the simplest possible math instead of general-purpose matrix math.
But you can change the general parameters they offer (radius, bounds, etc.) at runtime, just like any other component public parameters.
Or you could have a different set of colliders which are more appropriate for when your character is in an odd situation like sliding under a wall, and enable/disable them as required.
You can only adjust radius and height for a capsule. That’s what I’m saying. You cannot adjust the transform independently, as that requires a lot heavier math for the physics system. I have seen similar games just set the radius really large and the height really short, for an approximation of the graphical character parts when they’re prone.
Like I said, Colliders already try to match their object’s transform values. The simple colliders won’t fit perfectly with scale, but will still rotate to match your object. If you want it to match the player perfectly, you’re going to want to use a Mesh Collider and put in a Mesh of a Capsule, as the simple colliders use very minimal calculations to create their shapes.
@AnimalManUK : I did that. It’s Convex and has a rigidbody, but it’s still not taking the shape.
Here is a screenshot of what SHOULD be happening. “JammoPrefab” has the Mesh Collider but as you can see, it is not shown in the Mesh Collider Shape list.
@AnimalManUK : That’s what I’m saying… JammoPrefab is not showing up in the list. I clicked the bottom right button… It’s not letting me select “JammoPrefab”.
Imported models are in essence, prefabs, with multiple meshes assets as sub objects. If your model is made of many multiple smaller mesh objects… have fun with that.
A better question is why you want to be scaling and rotating a complex collider (answer, you don’t). You should just use a capsule collider and change the height and radius as needed in your code.