- Home /
UnityEngine.Component.transform' is a `property' but a `type' was expected
hii,I was trying to make a camera follow the character, i also follow a tutorial there he done exactly the same thing as mine but he is using a Mac and I'm on windows and unity 2017.1. when i saved the script it says "Assets/chaseCamera.cs(7,12): error CS0118: UnityEngine.Component.gameObject' is a
property' but a `type' was expected" please see the code blow and let me know what I'm doing wrong. using System.Collections; using System.Collections.Generic; using UnityEngine;
public class chaseCamera : MonoBehaviour {
public transform target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
transform.LookAt (target);
}
}
Answer by tanoshimi · Aug 20, 2017 at 02:26 PM
Transform is a class. transform is a "shortcut" for GetComponent<Transform>()
- i.e. the instance of the Transform class attached to this object.
So:
public Transform target; // must be cap T
transform.LookAt (target); // must not be cap T
Answer by BlackHack_ · Aug 20, 2017 at 02:22 PM
Replace public transform target;
with public Transform target;
Your answer
Follow this Question
Related Questions
2d camera movement with Lerp problem 0 Answers
Cardboard Camera Movement 1 Answer
Targets option in Inspector is missing... 0 Answers
player moves relative to camera? 1 Answer
Slight camera stutter with Cinemachine 2D (Video inside) 1 Answer