Play mode Paused due to error

Due to the null reference error 7:20 my unity play mode is stuck in paused mode

error is prompted on the lie stating - if (waypoint.IsPlaceable)

COORDINATE LABELER

[SerializeField] Color defaultColor = Color.white;

[SerializeField] Color blockedColor = Color.grey;

TextMeshPro label;

Vector2Int coordinates = new Vector2Int();

Waypoint waypoint;





 void Awake()

{

    label = GetComponent<TextMeshPro>();

    DisplayCoordinates();

}

void Update()

{

    if (!Application.isPlaying)

    {

        DisplayCoordinates();

        UpdateObjectName();

    }



    ColorCordinate();

}



void ColorCordinate()

{

    if (waypoint.IsPlaceable)

    {

        label.color = defaultColor;

    }

    else

    {

        label.color = blockedColor;

    }

}



void DisplayCoordinates()

{

    coordinates.x = Mathf.RoundToInt(transform.parent.position.x / UnityEditor.EditorSnapSettings.move.x);

    coordinates.y = Mathf.RoundToInt(transform.parent.position.z / UnityEditor.EditorSnapSettings.move.x);

    label.text = coordinates.x + "," + coordinates.y;

}



void UpdateObjectName()

{

    transform.parent.name = coordinates.ToString();

}

Hi,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Ohk i found the mistake and i was missing to call the method on awake the error is still in consol but the play mode is working

this was the code line in
void Awake()
waypoint = GetComponentInParent();

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms