Quick question with a Camera Following script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform CameraTr;
public Transform PlayerTr;
Vector3 CameraStartingPos = CameraTr.position;
void Start () {
}
// Update is called once per frame
void Update () {
CameraTr.position = PlayerTr.position + CameraStartingPos;
}
}
So the error comes in the "Vector 3 line" and I'm guessing Unity doesnt think of the position argument as a Vector and that's why I can't set CameraStartingPos as CameraTr.position. Could anyone explain me if I'm doing anything wrong or It's just not done this way? Thanks :D.
Comment
So you were on the right track for a simple camera follow. Just a small tweak will set you right.
public class CameraFollow : $$anonymous$$onoBehaviour {
public Transform CameraTr;
public Transform PlayerTr;
Vector3 CameraStartingPos;
void Start () {
CameraStartingPos = CameraTr.position;
}
Answer by sergih123 · May 15, 2017 at 06:17 PM
Anyone please? It just would make it easier for testing the best camera position.