I want my code to increase the size of the box collider on one side only, as if I hit the bounding volume button and dragged the side out. How do I go about doing that? I’m trying to learn if either I can access that pivot via script or the algorithm required to properly change the box’s center as I increase the z size.
How to edit a box collider as if you were dragging the pivots of the bounding volume but via script?
You would need to manipulate both the .center
and .size
properties of the BoxCollider in order to achieve what you want.
For instance if you pulled a side out by unit 1, that dimensional axis of .size
would be increased by 1 and that position of .center
would be adjusted (up or down appropriately) by 0.5
Yep, center.z = size.z / 2. Thanks!