Forum rules - please read before posting.

Possible [BUG]: Player Switching does not handle inventory properly?

So, here's the issue I'm having:
+ Start a scene with default player that has inventory items -- In this case, it's revisiting a scene that the player has already been to
+ Do a variable check at scene load to see if default player has finished a task
+ If the player has, then play a small cinematic (dialogue and camera transition) and switch to a different player
+ Play as the 2nd character and finish task (which would set a new variable when you reload the scene to determine which starting character it would be)
+ Switch to 1st character
Result: 1st character no longer has inventory items that he started with (I did not transfer inventory on any of the player switch actions) 


  • Excellent, thanks for the detailed steps.  I'll look into it and will let you know if I need more info.
  • Thank you, sir!
  • Can't recreate the problem from the steps given.  As I read them, this essentially boils down to the following (the Variable: Check seems irrelevant, unless I'm missing something):

    -Start Player 1 in scene A with some items (either carried on start, or given via a Cutscene)
    -Switch to scene B and back to A
    -Run a Cutscene that switches to Player 2, then back to Player 1 within the same scene

    Following those, the Player 1 continues to have the inventory he began with - for me, at least.  Do those steps sound correct to you?  Which version of Unity and platform?
  • Latest Unity & AC.

    I'm not switching scenes like you are in the second step (in this context).  Just starting the scene with the variable check (variable check is in place since it's a scene that you come back to and it needs to know what all the player has achieved so it can switch to the appropriate character when necessary).

    I've been able to repro it in two separate scenes, so it's at least consistent to me...I'll look at each setup again this evening to see if I'm doing something dumb, but I've tried pretty much every option on the Player Switch action at this point to no avail... 
  • But which platform?  Unity has a lot of platform-specific caveats when it comes to saving data.

    Without the scene switching, it essentially boils down to switching player, waiting a moment, then switching back in one cutscene, correct?  If you can make a test scene that does without everything that doesn't contribute, it may help us isolate the source of this.  At the moment, I'm still thinking that the Variable: Check is an aside.
  • I'm on MacOSX.  

    Okay, so I was able to repro pretty quickly.  I setup a test map where I had two NPCs and my default player.  I started the map, went over to the 1st NPC and did a player switch, this one replaces the current player in the level.  Then walked over to the 2nd NPC (which has a player check and if it's not the default player then it moves onto the player switch), activated the player switch and everything is fine.


    After I got that working, I setup a test variable that I'm checking on the OnStart cutscene for the scene.  If the variable is set to "TRUE" then I'm switching to the Non-Default character and running through the whole cycle again.  After I try to switch back to the default character after starting as the non-default, the inventory is all messed up (ie: it doesn't show up at all).  So it looks like the issue for me is when you start a scene as the non-default character, it'll repro my issue.
  • OK.  And does the default player get the inventory before, or after the scene is started?
  • Before - I have certain inventory items set to "Carry on Start".
  • I'm afraid that this is proving impossible for me to recreate.  You will have to PM me a .unitypackage of an example scene, Managers and Player prefabs that can be used to show the exact problem.
  • Okiedoke - I've sent you a PM with a link to a .unitypackage and steps to repro.  Hopefully, it'll work for you (or not work for you in this case)!
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.