Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Script can't find camera?

Discussion in 'Scripting' started by CodeWurm, May 21, 2016.

  1. CodeWurm

    CodeWurm

    Joined:
    Nov 8, 2014
    Posts:
    316
    Assets/Script/ThirdPersonCamera.cs(21,17): error CS0029: Cannot implicitly convert type `UnityEngine.Camera' to `ThirdPersonCamera'

    public class ThirdPersonCamera : MonoBehaviour {

    public Transform lookAt;
    public Transform CamTransform;

    private ThirdPersonCamera Cam;

    private float distance = 10.0f;
    private float currentX = 0.0f;
    private float currentY = 0.0f;
    private float sensivityX = 4.0f;
    private float sensivityY = 1.0f;

    private void Start()
    {

    CamTransform = transform;
    Cam = Camera.main;

    }
    }
     
  2. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Should be:
     
  3. CodeWurm

    CodeWurm

    Joined:
    Nov 8, 2014
    Posts:
    316
    Ah thanks, I think the editor added it by itself when I was typing, and I didn't notice it.
    Sometimes it's annyoing