Some objects with some code I have made will have waypoints attached to themselves and some without. Those with waypoints should interact differently to those with, and to access these different functions, I hoped that the following if statement could work:
if (waypoints != null)
{
//Do stuff
}
The above does not work for my needs, as if a prefab has 0 waypoints set, they still technically aren’t null. Everything believes it has waypoints. To get around that, I tried the below:
if (waypoints.GetLength(0))
{
//Do stuff
}
Again, the above has not worked, as I am pulling an int where a bool is expected.
I tried to change the if statement, to look for whether a prefab has 0 waypoints, but trying to set an int where a bool is expected has caused even more problems.
I would appreciate some help on how to stop objects with 0 waypoints being able to call this, as it is a bool requirement and not an int requirement, I am not sure how to go about this.
@Matt-Roper 's reply is probably the correct one. You could replace .Length with .GetLength(0) as they’re equivalent, but it’s really only common to use the GetLength method of getting an array’s length if the array has more than one dimension.