how i need to activate colliders/riigidbody to make camera collision only with walls?

Good day.

In my game, the camera is a “flying camera” (like Counter strike when you are dead), so you cna move everywhere. In the scene there are multiple objects.

Now camera can pass everything, and I limit the area where the camera can move by simple camera position restrictions with …

void Update(){
if (Camera.transform.position.x > 800)
Camera.transform.position = new Vector3(800, Camera.transform.position.y, Camera.transform.position.z);

This code 6 times (for each axis positive/negative). It seems is working, but is not working 100%, sometimes the camera pass that 800 during a second, right before coming “inside” again… MAybe i need to do that camera movign in other method ?

I think will be a great idea to make the camera collision with the external walls, so it can not corss them. The problem is that i have units moving with NavMesh Agents, colliders and rigidbodies. so the problem is…:

How can i make the camera collision with external walls, but not with Units?

How i need to configure the colliders? Trigger? ¿RigidBody?..

Thanks in advaaance! :smiley:

Instead of transform wich is a teleport, you could use a character controller with the method Move() wich will detect collisions and won`t let it pass through walls