I'm making my first ever game, and I got this error:
"error CS1525: Unexpected symbol `offsetX'"
Can you tell me how can I fix it, answer as fast as possible, please. (:
The script:
using UnityEngine;
using System.Collections;
public class CameraTracksPlayer : MonoBehaviour {
Transform player;
float offsetX;
// Use this for initialization
void Start () {
GameObject player_go = GameObject.FindGameObjectWithTag ("Player");
if (player_go == null) {
Debug.LogError ("Couldn't find an object with tag 'Player'!");
return;
}
player = player_go.transform;
offsetX = transform.position.x - player.position.x;
}
// Update is called once per frame
void Update () {
if(player != null) {
Vector3 pos = transform.position
pos.x = player.position + offsetX;
transform.position = pos;
}
}
}
↧