Camera Collision Problem
hey guys i'm trying to avoid camera collision to walls and always want my camera to look at my player
so what i did is i made my character direction change based on mouse movement and made my camera change it's position based on players facing direction here is my camera rotation script using UnityEngine; using System.Collections;
public class camScript : MonoBehaviour
{
public bool LockCursor;
public GameObject myPlayerGameObject;
public float DistanceFromPlayer;
void Start ()
{
if (LockCursor)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
void Update ()
{
transform.position =myPlayerGameObject.transform.position - player.GetComponentInChildren<PlayerController>().GetPlayerFacing() * Distance;
transform.LookAt(myPlayerGameObject.transform);
}
}
it works perfectly fine expect when my player near walls and there is a wall in between my player and camera. I tried using ray but i was not getting a desired result. Can anyone sugget anything?
sorry for my Bad English
Your answer
Follow this Question
Related Questions
Camera always behind player 0 Answers
Fixed Camera rotate to follow player 2 Answers
How do i keep the camera at a fixed position without rotating with the mesh 0 Answers
How to fix player camera shaking 0 Answers