I have 3 scenes that I’m trying to move between; A Main Menu, A World map, and a Battle scene. I have no problem going between them in the typical order. The issue arises when I try to leave the battle scene onto the world map. I’m getting the following error.
NullReferenceException
map_nav+c__Iterator0.MoveNext () (at Assets/Scripts/map_nav.cs:190)
here is the function it is in.
public IEnumerator Charmove(Transform startSpot,Transform endSpot,float moveTime)
{
Debug.Log(startSpot+" "+endSpot);
var i = 0.0;
var rate = 1.0/moveTime;
ismoving = true;
while (i < 1.0)
{
i += Time.deltaTime * rate;
avatar.transform.position = Vector3.Lerp(startSpot.position, endSpot.position, Mathf.SmoothStep(0.0f, 1.0f,(float) i));
yield return new WaitForEndOfFrame();
}
ismoving = false;
curr = endSpot;
curr_name = curr.name;
Debug.Log("Move Complete");
}
The function is used to move the character’s avatar between nodes on the world map. It is called the exact same way when moving from the Main menu to the world map as it is coming from battle. For some added info, neither of my Debug.Logs that are in the function show up in the console and I know that all the variable used should be assigned.
The specific line is avatar.transform.position = Vector3.Lerp(startSpot.position, endSpot.position, Mathf.SmoothStep(0.0f, 1.0f,(float) i)); Other scenes aren't accessible during the duration of this function.
– Proggin_Barnes