Forum rules - please read before posting.

Retain Character Switch Through Scene Change?

Hey guys,

Sorry if this is a silly question but I seem to be struggling a bit with this and i can't seem to find a solution. I have a game where i switch characters and they can go from scene to scene. When I do, however, it keeps resetting to the default character every time I go to a new scene. 
So for example, if I start with Character A, switch to B in the same scene, and then go to (load) a different scene, the player in this new scene is Character A.

I can solve this through an OnStart cutscene, but I wanted to see if there was a much cleaner solution that was eluding me. Thank you!

Comments

  • I've got a similar arrangement in that I'm using four different characters as "costumes" for the player, but it retains them as expected in mine. Is Character A the one set as default in the AC Settings menu? Just making sure, have you set player switching to "Allow" in that menu?
  • Are you using the very latest version?  Some recent bugfixes were made regarding this.  Your player prefab shouldn't change if you're just switching scenes - no OnStart fixing necessary.

    So long as your Players are defined as prefabs within the Settings Manager, all should be OK.  The exception to this is when you make use of local Player objects in a scene, which will override whichever prefab is currently active.  If you have Player objects in your scene(s), remove them and rely just on prefabs if you want to be able to survive scene changes.
  • edited August 2016
    Hey guys thanks for the replies! I'll respond below.

    Technocrat: 
    I have! Character A is set as default. It works within the scene where the switch occurs, just not in the next scene.

    ChrisIceBox:
    I just updated my version but the problem seems to persist. Every time I go from one scene to the next, Player A appears... a new Player A might I add. If I look at the hierarchy this is what I see.

    This is when I'm supposed to be Player B as well. I make the switch and go to a new scene but all that's happening is Player As keep appearing. I should mention that if I go from one scene to another without switching at all, there are now two Player As in the hierarchy.

    First scene where I switch
    image

    Go to a new scene
    image

    If I keep going back and forth between scenes...
    image

    Thanks for your help! 
  • edited August 2016
    Weird... It would be a good idea to check the actions you are using on your onload and/or onstart actionlists in the new scenes (also check the one that actually changes the scene). Somehow it looks as if the PlayerA prefab is being instantiated on the beginning of every scene. Are you sure you haven't misplaced a prefab in the scene? Or do you have any custom scripts which may be spawning the prefab for some reason? or an actionlist which may be spawning the prefab through an action? You should probably use some dummy scenes to test if the issue also happens when switching between those, just to make sure. Just setup an empty scene where you switch the character and an empty scene to travel to, and see if the issue happens in those too.
  • Thanks for the suggestion, Alverik. It's the strangest thing. I tried moving the player into a new totally blank scene as Player B and it still happened.

    image

    You're right, something is definitely instantiating PlayerA, but I can't figure out what it is.
  • Just tested it by making Player B the default. This time they are the one appearing multiple times in every scene. Whatever problem I have, it's instantiating another default player every time i enter a scene.
  • Hey guys, 

    I solved it! Thanks to everyone for your help! I realize now that I didn't give the player prefabs the "player" tag. Such a simple mistake but it was throwing it all off.

    Again, thanks to everyone for the advice. Best!
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.