0
$\begingroup$

I have added a camera with a spherical empty to my model to view all angles, but the problem is that when I look up (during gameplay), the camera ends up below the floor (due to parenting), hence obscuring vision. Is there a way to prevent the camera from going through the floor? Thanks.

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

You can prevent the camera view from being obscured by sending a raycast from the camera to check if any object/mesh is in-front of, or behind the camera view, which is the Z-axis of the camera.

Here's a great tutorial exampling how to create and implement such a camera raycast for camera collision.

Tutorial

https://www.youtube.com/watch?v=Jim9W8B1KhU

$\endgroup$
2
  • 1
    $\begingroup$ I have actually tried this one in the past but it didn't work for some reason. I found another file with a setup that works for me anyways. Thanks. $\endgroup$
    – Minato
    Commented Jan 5, 2022 at 20:43
  • $\begingroup$ Ah I forgot that Cotaks already gave you that blend on BA. My mistake. $\endgroup$
    – RPaladin
    Commented Jan 6, 2022 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .