Waypoint.isPlaceable' is inaccessible due to its protection level

hello there!! im getting the error message “Assets/Scripts/CoordinateLabeler.cs(34,22): error CS0122: ‘Waypoint.isPlaceable’ is inaccessible due to its protection level” im at 7:39 Realm Rush Debugging Tools, here’s my script :arrow_down:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

[ExecuteAlways]
public class CoordinateLabeler : MonoBehaviour
{
[SerializeField] Color defaultColor = Color.green;
[SerializeField] Color blockedColor = Color.red;
TextMeshPro label;
Vector2Int coordinates = new Vector2Int();
Waypoint waypoint;

void Awake()
{
    label = GetComponent<TextMeshPro>();
    waypoint = GetComponentInParent<Waypoint>();
    DisplayCoordinates();
}

void Update()
{
    if (!Application.isPlaying)
    {
        DisplayCoordinates();
        ColorCoordinates();
        UpdateObjectName();
    }
}

void ColorCoordinates()
{
    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.z);

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

void UpdateObjectName()
{
    transform.parent.name = coordinates.ToString();
}

}

You should be using Waypoint's public bool IsPlaceable rather than the private bool isPlaceable

Very easy to miss!

Thank You !!

1 Like

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

Privacy & Terms