Help with Waypoint

I copied code from lecture and got this error
The type or namespace name ‘Waypint’ could not be found (are you missing a using directive or an assembly reference?)
Here’s my code
Preformatted textusing System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class EnemyMover : MonoBehaviour

{

[SerializeField] List<Waypoint> path = new List<Waypoint>();

void Start()

{

    PrintWaypointName();

}

void PrintWaypointName()

{

    foreach(Waypoint waypoint in path)

    {

        Debug.Log(waypoint.name);

    }

}

}Preformatted text

Hi,

Welcome to our community! :slight_smile:

Does the error message mention ‘Waypint’? If so, there must be a typo somewhere in your script because the type is spelt Waypoint. Double click on the error message. To which line in your code does it refer?

Yes, all parts in List<>, where i use Waypoin.

It refers to this line
[SerializeField] List path = new List();
and this one
foreach(Waypoint waypoint in path)

There does not seem to be a typo in those lines.

Is the Waypoint class inside the Waypoint.cs file? If so, go to Edit > Preferences > External Tools (in Unity) and click “Regenerate project files”. Maybe that’ll fix it.


See also:

1 Like

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

Privacy & Terms