Question by
david_V · Aug 06, 2016 at 02:32 AM ·
tutorialvisualstudioroll a ball
UnityEngine.GameObject' does not contain a definition for position
so I'm starting out on unity and I'm trying the roll a ball tutorial but I get this problem.Assets/Script/cameracontroller.cs(10,46): error CS1061: Type UnityEngine.GameObject' does not contain a definition for
position' and no extension method position' of type
UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?) using UnityEngine; using System.Collections;
public class cameracontroller : MonoBehaviour { public GameObject Player; private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - Player.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = Player.position + offset;
}
}
Comment
Best Answer
Answer by TrueMaskss786 · Aug 06, 2016 at 05:17 AM
use: Player. transform. position instead of just Player. position offset=transform.position-Player.transform.position
and change this also in Lateupdate
this will work