Hi, I'm getting an error from this code can anyone tell me what I need to change? This is the error I am getting Assets/Scripts/Score.cs(15,17): error CS1525: Unexpected symbol `{' using UnityEngine; using System.Collections; public class Score : MonoBehaviour { public GameObject Hoop; public int scoreValue = 1; // Update is called once per frame void Update () { if(transform.position.x = Hoop.transform.position.x) & (transform.position.y == Hoop.transform.position.y || transform.position.y == (Hoop.transform.position.y + 2 || transform.position.y == (Hoop.transform.position.y -2) { UpdateScore() } } void UpdateScore() { Score.text = "Score: " + scoreValue; } }
Code (csharp): using UnityEngine; using System.Collections; public class Score : MonoBehaviour { public GameObject Hoop; public int scoreValue = 1; // Update is called once per frame void Update () { if(transform.position.x = Hoop.transform.position.x) & (transform.position.y == Hoop.transform.position.y || transform.position.y == (Hoop.transform.position.y + 2 || transform.position.y == (Hoop.transform.position.y -2) { UpdateScore() } } void UpdateScore() { Score.text = "Score: " + scoreValue; } } Use [ code ] tags to format your code, since it makes it easier to read and identify specific lines. Anyways, double check your brackets in the if statement at line 14, since everything needs to be inside the if statement.
In your if statement you are setting the first value not comparing it. Also you should use && not just &.