Why doesn't script "remember" GetComponent object?

I made script to enemy in my game which tells enemy which way to look/go. Script is attached to prefab. Another script instantiates prefab while playing.

public Vector3 direction;

public float speed = 5.0f;

public CharControl GetCharPosition;

void Update ()

{

    direction = GetCharPosition.lastPosition - transform.position;

    float enemySpeed = speed;       

    enemySpeed *= Time.deltaTime;

    transform.Translate(direction.normalized * enemySpeed, Space.World); 

    transform.LookAt(GetCharPosition.lastPosition);                      
    transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y ,0);   

}

I had to grab my character from hierarchy and drop it into inspector. It works fine, but everytime I reload the scene it disappears and I have to put it back again. This also happens if I make a build from the game so I can't make a proper build. Is this a bug or am I doing something wrong?

Did you press the Apply button after dropping the character into the inspector?

This function updates the source Prefab with the new values.

So script A and the character are one the scene graph then script A loads a prefab with script B that depends on the character? I think the problem is that every time you load the scene, you get a new character gameobject/transform in the engine. If the script and the character are related you either have to soft bind using GameObject.Find or make the script and the character as part of the same prefab. I do this sometimes where I have a simple hierarchy of game objects that have scripts that depend on one another. The are all in the prefab so they can cross reference one another. Sounds like you want to Find() the character in the start method of script B.

This is not a bug.