Hey so I loved this lecture (added something to an previously existing feedback section) but wanted to say it again. I’m sorry to hear many folks didn’t like it, but to people like me this was absolutely wonderful.
EDIT: I’m referring to the lecture on race conditions that comes after the saving system lectures. This is tagged in two spots.
So here’s my “race condition”. Using quotes since I’m not sure that’s what it really is. Within the Save and RestoreState of Mover, it seems to function two different ways for the Player.
- Reloading the last scene - does what it is supposed to here
- Restoring state after a portal - does weird stuff
public object CaptureState()
{
return new SerializableVector3(transform.position);
}
public void RestoreState(object state)
{
SerializableVector3 serializableVector3 = (SerializableVector3)state;
navMeshAgent.Warp(serializableVector3.ToVector());
GetComponent<ActionScheduler>().CancelCurrentAction();
}
On point 2. What is happening is that we are saving the position of the player in Scene X and then restoring that same position that was valid in scene X in scene Y. Since the player exists between scenes, it makes no sense in Scene Y. Now in our simple game, this doesn’t cause much of a problem because the code in Portal fixes it.
But for a moment what’s happening is the player is ending up in a completely intended location after portaling and this may cause some weird unintended effects as the game gets more complex. At the very least I get warnings like this “Failed to create agent because it is not close enough to the NavMesh” popping up.
Are others having this issue? What do you all think? I am hesitant to fix it with some hack within RestoreState and have been living with it since I think the hack would be worse.