Hi,
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm1. In Intro Cutscene, I switched from using a script to using the OnClick() function select for LevelManager.LoadLevel(string) on a button. The LevelManager.LoadLevel string argument doesn't parse my input "Demo_Test_01,GameStartTrigger" properly like it does in your example (Boss Scene,Spawnpoint From Scene 1) and says that this scene doesn't exist in build settings. Demo_Test_01 or (3. Scene 1) is a scene in my build settings and I want GameStartTrigger to be the player start point but its not working for some reason. I had to make a script that takes 2 values or parses a string and builds a DialogueManager.Instance.PlaySequence("LoadLevel(scene,location)"), and this doesn't use the level manager correct? How can I get this OnClick() to work properly?
In Demo_Test_01, the player GameObject should have a
Persistent Position Data component. When the Dialogue System tells Persistent Position Data to retrieve the player's position from the Dialogue System's data, this component looks for an actor field named "Spawnpoint", such as:
The
LoadLevel(scene,location) sequencer command does two things:
1. It sets Actor["Player"].Spawnpoint = "
location".
2. Then it calls
LevelManager.LoadLevel(scene).
If you want to see the code, the sequencer command script is Assets /Dialogue System / Scripts / Supplemental / Sequencer Commands / SequencerCommandLoadLevel.cs.
The LevelManager.LoadLevel() C# method does not set the spawnpoint to
location. It only loads
scene and tells the persistent data components in
scene to apply their state from the Dialogue System's data.
Can you write a small script that does both steps above? Then add this script to the button and configure OnClick() to call LoadLevelUtility.LoadLevelWithSpawnpoint. For example:
LoadLevelUtility.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class LoadLevelUtility : MonoBehaviour // Add to your button.
{
public void LoadLevelWithSpawnpoint(string s) //<-- Assign to OnClick().
{ // Example: Set OnClick()'s string to: Demo_Test_01,GameStartTrigger
string[] fields = s.Split(',');
string levelName = fields[0];
string playerSpawnpoint = fields[1];
DialogueLua.SetActorField("Player", "Spawnpoint", playerSpawnpoint);
FindObjectOfType<LevelManager>().LoadLevel(levelName);
}
}
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm2. After the Intro cutscene, you are taken to the Demo_Test_01 which is equivalent to your (3. Scene 1). At the start of this, the player is supposed to start on a trigger named GameStartTrigger. This is fine the first playthrough, but when I come back the second time through it doesn't work and the player just stands still. The issue is because we use a FootCollider object (not tag) to activate the Sequence Trigger. When we load in the second time, the reference is Missing. This happens for all objects that refer to an object. I tried adding persistent active data to the Trigger point and the footcollider as well but none of that has worked. How might we go about fixing this so that the object references can also be restored?
Is your player set to "DontDestroyOnLoad"? If so, you'll have to use tags (in the trigger's Accepted Tags list), not GameObjects (in Accepted GameObjects). Or don't make the player DontDestroyOnLoad.
The Dialogue System doesn't have anything built in to restore object references. You could
write your own persistent data component to do this, though.
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm3. What's the difference between loading via script/regular LoadLevel and using load manager's load level exactly? What does the level manager provide that the normal LoadLevel doesn't already do?
Before leaving the old scene, the Level Manager tells the old scene's persistent data components to record their state into the Dialogue System. For example, if NPC1 has a Persistent Position Data component, it records the NPC1's current position in the old scene.
After entering the new scene, it tells the new scene's persistent data components to retrieve their state from the Dialogue System. For example, if NPC2 had previously recorded its position in the new scene, it will move NPC2 to the recorded position.
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm4. What is default starting level on the level manager do?
LevelManager has a method RestartGame() that restarts the game by resetting the Dialogue System's data and loading the Default Starting Level.
LevelManager also has a method LoadGame(string savedData) that loads a saved game. Normally the savedData string records the name of the scene in which the player saved the game. If the savedData string doesn't have this information, it loads Default Starting Level instead.
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm5. Also can I just add a persistent data/position component to a parent "Triggers" folder and have it apply to everything in the folder? Just trying to save time here since it looks like adding this to every component could be very tedious since we have a lot of very specific scenarios and conditions set up.
Yes. That's a very common thing to do.
n_hagialas wrote: ↑Wed Dec 13, 2017 6:28 pm6. Whats difference between using the restart function to restart the game and using the loading function for returning to the main menu? Originally I thought it might be easiest to serialize the game state at the main menu and then keep loading that again at the start with everything in tact, but it seems like it doesn't quite work that way right?
LevelManager.RestartGame() resets the Dialogue System's runtime database information and then loads the Default Starting Scene.