Forum rules - please read before posting.

Change scene and keep coordinate

edited January 2018 in Technical Q&A
Hi
I want to switch between two scenes and player get the last coordinate
automatically and appear in new scene in same coordinate. For example
with press "F" in keyboard it change to scene 2 and stand in same previous coordinate from previous scene.

Comments

  • I'm by far an expert so I'd wait for someone to confirm if my post is the best way or not however I believe all you need to do is attached a 'RememberTransform' script on the object you want to keep in the same place (so the player). I've used this for NPCs and it works great however never for the player - the first problem I can foresee is if there is a conflict with how the scene will try to position the Player when first loaded, so just check if you have a 'PlayerStart' marker positioned (I believe it is always defaulted and may even always be required? Not sure about that) however either way I would imagine that the PlayerStart marker would trump the 'RememberTransform' script and move the player to the start marker when the scene is loaded? So you could simply remove the PlayerStart - or, a long winded version, would be to record the x,y,z coords of the players position at the end of the scene and store it in a Global Vector3 variable and then when the next scene is loaded move the player from the start marker immediately to the Vector3 position.
  • You can declare Vector3 variables in the Variables Manager - to avoid conflict with the save system / PlayerStart, it might be easier to record the player's position before the scene change, and restore it afterwards - using the variable as a copy buffer.

    However, you might also be able to do this by using the Scene: Add or remove Action to add in the second scene, and then use another one immediately after to remove the first scene.  When a scene is added, its PlayerStart is not used and the player will not be moved.
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.