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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

error CS1061

Discussion in 'Scripting' started by ThreeCents, Oct 31, 2018.

  1. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    I was trying to make a fps view and this error showed up.


    Assets/CamFollowSmooth.cs(17,31): error CS1061: Type `UnityEngine.Component' does not contain a definition for `position' and no extension method `position' of type `UnityEngine.Component' could be found. Are you missing an assembly reference ?

    I tried but I can't find it :/

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class CamFollowSmooth : MonoBehaviour {

    [SerializeField] Transform target;
    Vector3 offsetCamera;

    void Start () {
    offsetCamera = transform.position - target.position;
    }


    void Update () {
    Vector3 cameraPosition = target.position + offsetCamera;
    transform.position = camera.position;
    }
    }
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    I think in the last line of your Update function
    camera.position
    should be
    cameraPosition
    .
     
    Kiwasi likes this.
  3. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    Yeah it worked ! Thanks man !