Best way to "freeze" all character input/activity/processing until world is ready?

Upon scene load, I have a number of things which need to finish processing, such as the procedurally generated world. I'd like to totally disable the character initially, then enable the character after everything is ready. I can think of a few ways to do that -- setting character time scale to 0, disabling the actual game object, setting gravity to 0 and disabling input, etc. -- but what is the recommended way to do this? Thank you
 
Best not to disable the gameobject or any component on it and just let it do all of its Awake/Start stuff like caching references. Disabling input is probably the way to go. If it's possible for other objects to interact with your character in some way during this phase, you may want to take extra precautions against that based on what those are, e.g. setting its time scale to 0.
 
I think Andrew is asking how to delay the spawning of the character in reality. In dealing with a procedural world he's probably waiting for the terrain most likely to complete it's thing and then have the character spawn in. Would the best way to do that be listening to the OnSpawn event and override it and/or listening to the OnAttachLookSource event? I think the question warrants a more detailed answered as there are many ways to do this, especially if your also using multiplayer/pun, etc..

I as well am looking to incorporate a delayed spawn of the character until the terrain is completed within a radius of where the actual spawn will take place. What is the best approach here. Using PUN2 as well
 
Last edited:
I am attempting to freeze the input and set timescale to 0 in the Start() method, but it causes my entire game to just freeze when playing, with no progress at all.

Is there some other way to be setting these? Could it be script execution order or such? I was expecting this to be very straight-forward, but it caused everything to lock up when running without any error or feedback in any way.

The only thing I can do after pressing "play" is to use Task Manager to manually kill the Unity Editor.

Andrew
 
You should freeze input by setting the OnEnableGameplayInput event, no need to set the timescale.
 
In case it's useful for others:

I wrapped the Opsive API in these two methods:
Then during "Start" I disable player's input and gravity and set the position to something very high so there's no chance of colliding with the generating game world (e.g. 0, 1000, 0).

Then, when complete, I re-position the player to the appropriate starting position and re-enable input and gravity.

Works for me.
 
I think Andrew is asking how to delay the spawning of the character in reality. In dealing with a procedural world he's probably waiting for the terrain most likely to complete it's thing and then have the character spawn in. Would the best way to do that be listening to the OnSpawn event and override it and/or listening to the OnAttachLookSource event? I think the question warrants a more detailed answered as there are many ways to do this, especially if your also using multiplayer/pun, etc..

I as well am looking to incorporate a delayed spawn of the character until the terrain is completed within a radius of where the actual spawn will take place. What is the best approach here. Using PUN2 as well
As Justin said, freezing input should be enough for most cases, but if there's something that will take place over several frames you may want to think about using a callback from whatever that setup is and instantiating your character only after it's done.
 
Top