Hi everyone! I’m trying to run a simulation with a hundred of agents generated with random features with UMA. But even though i call the function to create them inside the Start() and make them move in the Update(), they start moving while they’re still generating. To avoid this, i made this if statement inside the Update() function if ( frame_numb > avatar_numb) { …code for moving… } frame_numb++; .My idea was to prevent them from moving before all of them were created, assuming that every frame generates an avatar. But using the Debug.Log() and running the simulation i noticed that some avatars take two frames to be created. Also, when the editor gets around 70-80 avatars in play mode, it stops working. Could it be my laptop is not strong enough to support this simulation? Because the code seems ok.
Hmm, if I’m not mistaken (and forgive me if I am) you’re assuming Start() is called once per frame? It is only called once (like a constructor). If it’s creating other GameObjects their Update() methods will start to fire as soon as they’re created because they’ll be on a different thread (if I’m not mistaken – caveat: I’m no expert).
You might want to keep your agents deactivated until they’re all done generating? Then you wouldn’t have to do any ugly checks during Update().
@crisis-sheep has the right idea I think with not enabling the objects until all are completely ready. In your create object method finish it with something like:
avatarObject.enabled = false;
Then add at the beginning of update a check to see if the full quantity are ready then loop through them enabling them all.
I’m on my phone atm so can’t be more specific really