- Home /
Camera movement in a Third Person Shooter Game
I limited the camera movement to stop when it hits colliders other than self but it still able to see beyond some slim colliders like terrain, Whats the solution for such a thing? I tried using hitpoint.normal
to move the camera away from the collider but the distance needed is big enough that it ruins the camera view. Is there any thing I can do to limit the view and make the camera at-least Black instead of seeing outside the terrain?
Answer by Harinezumi · Feb 20, 2018 at 08:03 AM
I usually put a SphereCollider and kinematic Rigidbody on the Camera with the radius slightly larger than the near plane of the camera, so that when it collides with something I can stop the movement. However, you will have to mitigate for the stuttering that following a physical object causes in the position of the Camera.
what will that kinematic Rigidbody do to the camera mvt?
It is used to detect if you collide with something...
Hmmm, maybe I was using a normal Rigidbody and setting its velocity in FixedUpdate... I will check my code and get back how I did it.
But the main point is to use a SphereCollider at least as big as the near plane of the camera, so that you avoid clipping into objects.
Answer by Zodiarc · Feb 20, 2018 at 08:55 AM
Make a raycast form the character to the camera. if the ray hits anything other than the camera (collider required), move the camera to hit.point.
yeah i did that but the camera being on the hit.point , it can see cause of the viewport, the other side of the terrain even if I stopped the camera on the terrain's collider