Forum rules - please read before posting.

Scene Switch & Reload Player(s) multiple players

edited June 2018 in Technical Q&A
Hi Chris,

I am using the Scene Switch and also via script:

        AC.SceneInfo mySceneInfo = new AC.SceneInfo (ChooseSceneBy.Number, "", lvl);
        AC.KickStarter.sceneChanger.ChangeScene (mySceneInfo, true);

The problem I have however is with the player, I am unsure how to Reload the Player.

The reason I have to re-load the player because it has PM and Other scripts that gather certain intel on objects etc and store it in variables,

Once the scene is changed it remembers the last scene's variables which now are null, reloading the player(s) will help solve this issue.

I also think that perhaps the best way to do this for my scenario is to completely remove the player before loading a new scene, so when the new scene starts it starts with the player freshly?

If you can please let me know how I can do this via script and also via an action if it exists,

I tried using a Cutscene on Load and Start using the Player Switch action and replace player, however it does not solve anything, (Cannot switch player - already controlling the desired prefab.
I need your expertise

Thank you,



  • If you want a fresh player in each scene, don't rely on a Player prefab assigned in your Settings Manager.  That's just for convenience, anyway.

    Instead, just keep a local copy of the Player object within each scene file.  If a local player is present in the scene file, it'll override whatever you've assigned as the default.
  • Okay,

    I'm just trying to wrap my head around as how to know which out of the 4 characters the player is using, I can have them all in the scene disabled, and on load of the scene depending on which char was played last by setting a variable int maybe activate the corresponding character?

    Example if Scene 1 the player is now swapped to character#3 and loads Scene 2 how do I make sure the new character#3 is loaded in Scene 2 and the current one disabled?

    or is there a better way

  • This is the first you've mentioned the need for multiple players.  If you were just using a single player prefab, a local instance in each scene would be enough.

    If you had no need for "local" PM/other scripts then you could assign all as prefabs in the Settings Manager, and rely on the Player: Switch Action - which handles scene switching etc automatically.

    That would not be compatible with your idea of "resetting" the player, however.  I would recommend instead looking into finding a way for the player to update itself if it detects a scene change / unable to detect the local scripts it needs.  The OnSetPlayer and OnAfterChangeScene custom events may be able to help here.

    Otherwise, may well have to rely on a Global Variable to determine which player to load.
  • Sorry Chris I've no idea how to work delegates and tried this:

    AC.EventManager.OnAfterChangeScene += SceneChanged()

    in my start void but I get an error,

    How do I listen for this trigger, then I can try telling it what to do, I would love to know for future use as I can see there are many triggers that I can use in the event manager, what is the difference between that one and kickstarter event manager?

    Also, is there a function or something I can call that will 'reload / restart' the player?


  • See this tutorial (as well as the Manual) for info on how to use custom events:

    AC.EventManager.OnAfterChangeScene += SceneChanged;

    KickStarter.ResetPlayer can reset the player - look inside ActionPlayerSwitch for an example on its usage.

  • @kici I was in a similar position last night. I used -

    And was up and running in minutes. Hope it helps!

  • Thanks @Temmy & Chris 

    I was looking for that as it wasnt linked previously

    This helps a lot
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.