I have a gameobject that uses transform.Translate() to move. It has a collider and a rigidbody, but it never detects collision with the terrain. I can see it pass through the terrain, but with this code
Well, first thing is, is the rigidbody dynamic? If so, you shouldn’t use transform.Translate to move it. Change rigidbody’s velocity or use forces (e.g., rigidbody.AddForce) to move it. It is possible that from the perspective of physics engine, the game object did not move anywhere due to you moving it via transform.
If the rigidbody is kinematic, it will not collide with static colliders as shown in the collision matrix on this page: Unity - Manual: Introduction to collision
Check if you don’t mix collider2d and colllider, if you terrain has collider2d on it and you rigidbody has collider, the collision will not be registered.