Question by
AceShoeLace · May 28, 2016 at 04:59 PM ·
errorerror messageunexpectedsymbolunexpected-symbol
error CS1525: Unexpected symbol `offsetX'
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;
}
} }
Comment
Best Answer
Answer by TBruce · May 28, 2016 at 05:16 PM
In the future when posting errors could you do something like this
//<---- error here
to let us know where the error occurs?
In the meantime I see two things that you need to do
Transform player = null;
and
pos.x = player.position.x + offsetX;
If this does not fix the error then plese give more information to help
Your answer
Follow this Question
Related Questions
Unexpected symbol 1 Answer
C# unexpected symbol error 1 Answer
error CS1525: Unexpected symbol `)', expecting `(' 1 Answer
Unexpected symbol `1' ?? 1 Answer
Unknown error 0 Answers