Forum rules - please read before posting.

Return to previous scene at specific position

edited April 2017 in Technical Q&A
Hi everyone,

I'm using the following script command to load the previous scene in a custom action:

AC.KickStarter.sceneChanger.ChangeScene(AC.KickStarter.sceneChanger.previousSceneInfo, true);

My inventory is a scene, so I change scene each time I need to open my inventory. And when I close the inventory, I return to the previous scene. The problem is that the character start everytime at the playerstart marker. Is there a way to keep the transform position of the character ?

Thanks for any help !

Comments

  • edited April 2017
    if you are scripting anyway, you could try recording the player's position Vector3 in a static variable (just create your own Globals script and a static LastPlayerPosition). Then record the position right before switching to the Menu scene. Then, when switching back to the previous scene, you can just use tranform.position=Globals.LastPlayerPosition. Then, you could make a second action just for closing, which checks if the name of the previous scene matches the menu before changing the playr's position (that way you can call it on your OnLoad actionlist). 

    In hindsight, it would be pretty cool if AC had that kinda of option in the load action (like, position player at last know location "if available", which would not trigger if the newly loaded scene is not the previous scene).
  • Thanks Alverik!
    It works perfectly :)
  • FWIW, the SceneChanger script has a LoadPreviousScene function.

    An alternative solution would be to rely on player-switching, in that you use a separate player prefab just for the inventory, so that instead of swtiching to the previous scene afterwards - you just switch back to the original player.

    Player switching can be enabled in the Settings Manager, and then done with the Player: Switch Action.  Just create a dummy Player prefab with no graphics for the "inventory" player, and be sure to check All players share same Inventory?.
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.