Change scenes

Announcements, support questions, and discussion for the Dialogue System.
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Change scenes

Post by Arctichorse9 »

Hi. I'm using a Dialogue System Trigger with a sequence LoadLevel() and I load the new scene but do not land at the spawn point designated in the sequence.

The sequence has LoadLevel(Dungeon2, Spawn Point from D1).

I'm spawning not at that spawn point but where the Player Prefab is in that scene.

Am I right that you need a Player prefab in each scene?

Does that have to be positioned at or near the designated spawn point?

What if you want two spawn points in the scene (coming from different other scenes)?

Thanks for any help.
User avatar
Tony Li
Posts: 22871
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change scenes

Post by Tony Li »

Hi,

First make sure you've set up the save system.

Then make sure your player prefab in Dungeon2 (and all scenes in fact) has a Position Saver component with Use Player Spawnpoint ticked. Give it a unique key such as "playerPosition". The key can be the same for the Position Saver component on all instances of the player prefab in all scenes, but it should be different from other keys such as Animator Saver, Inventory Saver, etc.

If you do this and the player still doesn't appear at the position of the GameObject named "Spawn Point from D1":

1. Check the Console window for any errors or warnings.

2. Check your player control script(s). They may be locking the player into a specific position, preventing the Position Saver from moving the player to the spawnpoint.

Multiple spawnpoints in a scene are fine. For example, in Dungeon2 you could have another spawnpoint named "Spawn Point from D3" that comes from Dungeon3.
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Change scenes

Post by Arctichorse9 »

I gave the Position Saver a unique key. I checked the box Use Player Spawn Point. I also have box checked Save Across Scene Changes.

What is the key for on the Position Saver? Still no luck. I spawn where the player prefab is. Will leave it gir tonight and try again tomorrow. Thanks so much.
User avatar
Tony Li
Posts: 22871
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change scenes

Post by Tony Li »

Hi,

Are there any errors or warnings in the Console window?
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Change scenes

Post by Arctichorse9 »

No errors in Console window. Still searching for problem. I'm using More Mountains Inventory Engine. Not sure if that has anything to do with it Currently scouring the scripts arrached to the player and not finding anything that wouid affect the spawn Using Grid Controller.
User avatar
Tony Li
Posts: 22871
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change scenes

Post by Tony Li »

Grid Controller should work with Position Saver except (currently) it doesn't restore the player's rotation. I'll be working on a Grid Controller-specific position saver this week.
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Change scenes

Post by Arctichorse9 »

I noticed that about the player rotation. 😀 I thought it was something I had to do
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Change scenes

Post by Arctichorse9 »

I've tried using the demo Player which does not use the Grid Controller, tried replacing the object I was using as a teleporter. Tried script instead of using play sequence. Same result. Changing scenes ignores the designated Spawn Point. So it's not anything on the Player and not the Grid Controller. No error messages. It could be related to More Mountains Inventory.

What if I use a different method to change scenes? Will the dara still persist across scenes?
User avatar
Tony Li
Posts: 22871
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change scenes

Post by Tony Li »

Hi,

You must use one of these techniques to change scenes in order to tie the save system into the scene change.
Arctichorse9
Posts: 62
Joined: Wed Sep 25, 2024 11:26 pm
Location: New York City
Contact:

Re: Change scenes

Post by Arctichorse9 »

Thank you. I have this error message:

Dialogue System: Lua code '{"NumberOfRows":0,"NumberOfColumns":0,"InventoryName":"Inventory","InventoryType":0,"DrawContentInInspector":false,"ContentType":[],"ContentQuantity":[]}' threw exception 'Code has syntax errors:
Line 1, Col 1 '{': Failed to parse Letter of Name.
Line 1, Col 1 '{': Failed to parse Name of VarName.
Line 1, Col 1 '{': Failed to parse 'nil' of NilLiteral.
Line 1, Col 1 '{': Failed to parse Text of BoolLiteral.
Line 1, Col 1 '{': Failed to parse '0'...'9' of Digit.
Line 1, Col 1 '{': Failed to parse (Digit)+ of FloatNumber.
Line 1, Col 16 ':': Failed to parse '}' of TableConstructor.
Line 1, Col 1 '{': Failed to parse Name of VariableArg.
Line 1, Col 1 '{': Failed to parse firstTerm of OperatorExpr.
Line 1, Col 1 '{': Failed to parse Expr of ExprStmt.
Line 1, Col 1 '{': Failed to parse remaining input.
'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:252)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:131)
PixelCrushers.DialogueSystem.Lua:Run (string,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:141)
PixelCrushers.DialogueSystem.PersistentDataManager:ApplyLuaInternal (string,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:263)
PixelCrushers.DialogueSystem.DialogueSystemSaver:ApplyDataImmediate () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/DialogueSystemSaver.cs:81)
PixelCrushers.SaveSystem:ApplyDataImmediate () (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:1018)
PixelCrushers.SaveSystem/<LoadSceneCoroutine>d__135:MoveNext () (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:992)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
Post Reply