Here is the code -

using UnityEngine;
using System.Collections;

public class MoveEnemy : MonoBehaviour {

    private GameObject Road1;
    public Sprite NE;
    [HideInInspector]
    public GameObject[] waypoints;
    private int currentWaypoint = 0;
    private float lastWaypointSwitchTime;
    public float speed = 1.0f;
    public string  waypoint;
    void Start () {
        lastWaypointSwitchTime = Time.time;
        Road1 = GameObject.Find("Road_1");
    }

//~~~~~ some code here which isnt relevant. Update calls the method //RotateIntoMoveDirection. ~~~~~~~~


    private void RotateIntoMoveDirection()
    {
        waypoint = currentWaypoint.ToString();
        Debug.Log(waypoint);
        Road1.Find("waypoint");
    }
}

This code calls out the error - ‘‘Assets/Main Project/Scripts/MoveEnemy.cs(67,15): error CS0176: Static member `UnityEngine.GameObject.Find(string)’ cannot be accessed with an instance reference, qualify it with a type name instead’’

My search has found out that i have to use GameObject instead of gameObject, but i AM using it!

I am trying to find which waypoint is currently passed. I get the number of it and convert it into string and try to find the child with the name same as the index of the waypoint.

If waypoint is 1 then i find child with index of 1 in the GameObject. Then i will find get its name and change other gameobjects sprite to its name. If it’s taxi_NE i will change it to sprite taxi_NE and so on

I’m afraid GameObject.Find doesn’t quite work like that. I’d imagine the line with

Road1.Find( "waypoint" );

is line 67 in your code as specified in your error message. What you’re doing here is looking for a method in a local instance of the GameObject class, identified as a gameObject when you write code (note the difference in the uppercase and lowercase G’s). Using the GameObject class is kind of like having a mold that you use to make gameObjects. These are the objects that actually appear in your game. The GameObject is an abstract concept where a gameObject is a concrete instance. The latter inherits the general features of a GameObject such as having a Transform component. However, some methods such as Find cannot be accessed through a gameObject that you made from the GameObject “mold.” This is why you are able to say Road1.SetActive(), but not Road1.Find(). Some features are inherited by the gameObject, but others are not.

Instead, you need to use the class GameObject. Change that line to :

GameObject.Find( "waypoint" );

and it should work as long as you don’t have multiple game objects in your scene labelled “waypoint.” It will only work in this case because GameObject.Find will search the entire scene for objects with that name. However, if you would need to specifically access objects that are children of Road1, you could use:

Road1.transform.Find( "waypoint" );

Since children are actually controlled by the transform component of a gameObject. That may have been a long explanation but I hope it helps!

@dan5071 your answer is perfect, but there is a little problem…

transform.Find only finds immediate children. What should I use in order to access a child that is deeper inside the parent and not just first tier children?