Error CS0030

Hi, i got a strange error like:
Assets\Scripts\Path\PathFindingGridDebugObject.cs(17,20): error CS0030: Cannot convert type ‘UnityEngine.Object’ to ‘PathNode’
the error code is followed:

  pathNode = (PathNode)gridObject;

In your SetGridObject() method, is the parameter

object gridObject

or

Object gridObject

The Pathnode class does not inherit from any other class, meaning that (by definition) it inherits from object - the generic building block of all C# classes, structs, values, etc, but not Object which is a UnityEngine specific class serving as the building block for Unity specific classes.
This means the method declaration should use the parameter

object  gridObject

If this isn’t the solution, paste in your PathFindingGridDebugObject.cs and your PathNode.cs script and we’ll take a closer look.

it is working ,thank you very much!

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

Privacy & Terms