Camera Pass through objects in the Scene

Hey there,

How can I avoid passing the camera thought objects in the scene?

You can use a Raycaster to determine if there’s any intersection between the camera and controlled actor (in 3rd person) or the distance between the camera and closest intersection (in 1st person) - then either block the movement when intersections happen (between the actor and camera or just too close to the camera).

Alternatively, for 3rd person camera you can also move the camera closer to the actor whenever you get an intersection (ex. that how World of Warcraft camera ensures that your character is always in sight in corners / complex envs.)

Raycasting is not necessarily good for collision detection. I would wrap the camera into a bounding volume and make intersection tests between bounding volumes. This is much more reliable than working with rays.

4 Likes

I have tested one possibility for certain scenarios there.
Circular control used for walkable areas control
see https://hofk.de/main/threejs/showroom/AreaControl

thanks.Can you give me source ? how can i do this ?

Sorry, but I can’t provide you a complete solution for this. I suggest you invest more time in studying the related topics (e.g. bounding volumes, collision detection). The book Real-Time Collision Detection by Christer Ericson is a very good literature in this context.

1 Like

Okey thanks for your help guys