Making sure camera does not move behind certain entity

Hi all,

How do you make sure the camera does not move behind an entity like a wall? I really need the script for that :grimacing:

Thanks.

I just need to make sure that the camera, child of a car main entity, does not move behind the wall. Should I activate rigidbody and collision for the camera?

That won’t really work as then you make the camera part of the physics simulation.

I would make the camera not a child and write some logic that follows the car.

Part of that logic is to perform raycasts in the direction it needs to move in for that frame and if it hits a wall/physics object etc that is too close, not move that frame.

Or something similar.

Can you send the script to perform raycasts and follow the car?