Unity Ver: 2019.4.18f1
AC Ver: 1.73.2
I've had a test scene I've been using for ages with no problems, however tonight I went and added the scene to Unity's build settings as scene 0. As soon as I did I'm getting an AC warning:
Cannot find suitable PlayerStart for Player ID = 1 in the current scene
-> AC debug logger
UnityEngine.Debug:LogWarning(Object, Object)
AC.ACDebug:LogWarning(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:33)
AC.PlayerData:UpdatePosition(Int32, TeleportPlayerStartMethod, Int32) (at Assets/AdventureCreator/Scripts/Save system/PlayerData.cs:288)
AC.PlayerPrefab:SetInitialPosition(PlayerData) (at Assets/AdventureCreator/Scripts/Character/PlayerPrefab.cs:160)
AC.SaveSystem:GetPlayerData(Int32) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:587)
AC.SaveSystem:AssignItemsToPlayer(InvCollection, Int32) (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:1881)
AC.RuntimeInventory:AssignStartingItems() (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:1113)
AC.RuntimeInventory:OnInitPersistentEngine() (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:99)
AC.StateHandler:Initialise(Boolean) (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:97)
AC.KickStarter:SetPersistentEngine() (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:183)
AC.KickStarter:Initialise() (at Assets/AdventureCreator/Scripts/Game engine/KickStarter.cs:1139)
AC.MultiSceneChecker:Awake() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:43)
The scene has a playerstart. I've never had any issues with running the scene in play mode before.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I have two players setup in AC settings with switching enabled. AC seems to be spawning both players into the scene:
Here's the player start:
My apologies. I've fundamentally misunderstood something here. According to the manual, having multiple players requires they all spawn somewhere. I thought it was a case only one would be present and then when doing **Player:Switch ** the player would get replaced. I think I know why I'm experiencing this problem now.
By adding a new scene to build settings index 0, and playing it, I believe for the first time I'm seeing the non-default characters, which are told to start in scene index 0. All other scenes I've been testing were scene ID 1+....so they didn't have the problem of non-default characters in the scene.
Inactive Players will only spawn in the scene that they're recorded as being in. The default stating scene index of all non-default Players is 0. If you haven't configured this to be otherwise, this is where they'll start the game from.
You can set the starting scene of all non-default Players in the Settings Manager. A tutorial on managing multiple Players can be found here.
Thanks Chris. Certainly a lesson for me on not researching / learning things before using them.
If I disable player switching, is it best practice to let AC spawn the player into scenes, or, is it totally ok to have a local player placed in each scene?
Totally fine. Having a local Player can have an affect on scene load times, if they have a lot of assets/data associated with them, but there are times when it's necessary if they depend on custom scripts / third-party assets.
Yeah. Very much that. Basically my player has lots of components that I need to turn off for some moments, and it's easier to get references if they're already in the scene. I thought having a 'lite' version of the player and switching to that might be the solution but if two are present in a scene the custom scripts fall over each other.
I'll just stick to one for now and modify the bits that need to change via actions. Thanks Chris.
Needs vary between projects, but I was talking more about the case when a custom component itself needs to be in the scene file - e.g. to reference other scene objects in its Inspector.
If you're just needing to record references to components attached to your Player, you can hook into the OnSetPlayer event:
This'll be always be triggered every time the Player character is assigned, regardless of the circumstance.