I am trying to create a script that will make the camera follow the player, but just on the x and z axis.
Here is the whole script, and the error it gives me:
using UnityEngine;
using System.Collections;
public class FollowPlayer : MonoBehaviour {
public static Transform myCamera = Camera.main.transform;
public static GameObject player = GameObject.Find("Player");
public static float cameraX = Mathf.Round(player.transform.position.x);
public static float cameraZ = Mathf.Round(player.transform.position.z);
// Update is called once per frame
static void Update () {
myCamera.position += new Vector3 (cameraX, 0, cameraZ);
}
}
and
I don’t understand what is going on, so any help is appreciated.