How does Unity's Collider.Bounds work?

From waht I understand, Collider.Bounds are the sides or bounds of the collider of the GameObject (at least for a cube with a BoxCollider). But I got a result that I wasn't expecting when I tried moving a cube continuously downwards and drawing the bounds with lines. While moving frame by frame, the collider bounds seemed to be not bounding the cube (or at least that's what my test is showing, if my test is correct).

Here's 3 frames of screenshot:

What I did for this is create a new 3D project, add a Cube, then added a single script and then added this script to the Cube. The whole script is:

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
Vector3 velocity;

// Start is called before the first frame update
void Start()
{
velocity = Vector3.zero;
}

// Update is called once per frame
void Update()
{
velocity.y += -0.5f;
transform.Translate(velocity);

Bounds bounds = GetComponent<Collider>().bounds;
Debug.DrawLine(new Vector3(bounds.min.x, bounds.min.y, bounds.min.z), new Vector3(bounds.max.x, bounds.min.y, bounds.min.z), Color.red);
Debug.DrawLine(new Vector3(bounds.max.x, bounds.min.y, bounds.min.z), new Vector3(bounds.max.x, bounds.max.y, bounds.min.z), Color.red);
Debug.DrawLine(new Vector3(bounds.max.x, bounds.max.y, bounds.min.z), new Vector3(bounds.min.x, bounds.max.y, bounds.min.z), Color.red);
Debug.DrawLine(new Vector3(bounds.min.x, bounds.max.y, bounds.min.z), new Vector3(bounds.min.x, bounds.min.y, bounds.min.z), Color.red);
Debug.DrawLine(bounds.min, bounds.max, Color.red);
}
}


Am I not understanding something or am I doing something wrong?

• I notice you're moving this collider with the object's Transform component, rather than using the physics system that's responsible for managing colliders. Have you tried notifying the physics system that you've moved its stuff using eg. Physics.SyncTransforms or keeping the movement in the control of the physics system throughout? Jun 17, 2019 at 22:59
• @DMGregory I believe that is the answer OP is looking for :) Jun 17, 2019 at 23:34
• @DMGregory: Ok, I guess I'm misunderstanding something. I thought Physics only applies when your GameObject has a RigidBody attached? And I thought the Collider is just a property that always bounds the object and is only detected/used by Physics when there's a RigidBody as well. If that's not the case, then maybe I shouldn't use Bounds to draw the lines.
– g_b
Jun 17, 2019 at 23:51
• You should use colliders when you want physics collisions, including physics.raycast, etc. Everything involving colliders is a physics effect, even if you don't use rigid body dynamics. If you just want the bounds of the visible object, you can use renderer.bounds instead. Jun 17, 2019 at 23:53
• OK, thank you. Also, your suggestion Physics.SyncTransforms worked. I would like to mark it as the answer if you'll put it as an answer.
– g_b
Jun 17, 2019 at 23:55