Prevent a Character Model to pass through another object

I have a character model with a rigid body attached to it. How can I prevent this model passing through other objects in the scene. FYI, I’m moving the object by altering it’s transform. Also the movement of the model is influenced by mouse click, somewhat like LOL or DOTA.

Thanks in advance.

You should add colliders to it.

If it’s a character you’re controlling, you should drop the rigid body and use the character controller:

You can move it with collision detection using Move:

Something like this:

void Move()
{
	Vector3 dir = new Vector3(target.position.x, transform.position.y, target.position.z) - transform.position;
	float dist = dir.magnitude;		
	float move = speed * Time.deltaTime;
	
	if(dist > move)
		cc.Move(dir.normalized * move); // cc is reference to the character controller
	else
		cc.Move(dir);
}

You can download an example package I made here:

http://speedy.sh/XNZdT/move.unitypackage