playMaker

Author Topic: Load Level Action  (Read 4008 times)

Nog

  • Playmaker Newbie
  • *
  • Posts: 47
Load Level Action
« on: February 04, 2015, 09:58:45 PM »
Hello,

I am trying to use the Load Level action to load a menu screen that I created in another Unity scene.

From what I understand, with additive and Don't Destroy On Load turned on, the original level will still exist in the background while the menu level scene can function in the foreground. However, when the user pushes the button that moves to the state that removes the menu scene and loads the original level back, the level starts all over instead of continuing where the player left off.

I have Don't Destroy On Load attached to my character's FSM and its camera's FSM, and I have Reset On Disable turned off on all FSMs. However, when the original level loads, the player and camera do remain in the scene and in their correct positions, but the level starts all over and recreates the player and camera again in the scene where the level starts. As a result, there are two players and two cameras.

Is there a way to fix it so the menu level unloads, and the player can simply continue where they left off in the game?

Thanks for any help.

Nog

user42

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Load Level Action
« Reply #1 on: February 05, 2015, 10:25:23 AM »
hmm
i didn't use the load level action so much.
But why do you want to use it for a menu screen?
Why not just activate the menu screen when you press pause.
Or create and destoy it from a prefab.

Nog

  • Playmaker Newbie
  • *
  • Posts: 47
Re: Load Level Action
« Reply #2 on: February 05, 2015, 11:14:24 PM »
Thank you for your suggestion user42. I will look into prefabs.

Using Load Level to load a scene for a the player's menu is probably not the most elegant way to do it, but I wanted to try it out.

However, I did get it to work. I created an empty game object and a I called it Scene Manager.

Inside the Scene Manager, I created two FSM's called Player Exist and Remove Objects. Inside the Player Exists FSM, I have a Game Object Compare Tag action and a Set Tag action that re-tags the player and its camera with the tag Main Player.

Inside the Remove Objects FSM, there is a Game Object Compare Tag action and a Destroy Object action.

When the user hits the menu button to load the Menu scene, a Send Event action tells the Player Exists FSM to start. It labels the objects that I want to keep in the current scene with the label Main Player.

When the user hits the menu button to exit the Menu scene and re-load the original scene, a Send Event action tells the Remove Object FSM to start. It looks for the objects with the labels from the original scene and destroys them.

The system needs some refinement, but it works for now. Is the prefab method better? I know that the Unity GUI can be used for menus, but I do not know that much about using them for full fledged menus. Would that be a better solution? Any other ideas?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Load Level Action
« Reply #3 on: February 09, 2015, 03:18:40 PM »
Load Level actually changes the scene. Unity erases all of the current scene data and loads in the target scene data to effectively change the level.

Dont Destroy On Load just flags a specific object to not be erased when the scene is changed.

So that means you can place some menu in the first level, flag it as Dont Destroy On Load and have it survive through level loading...
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D