Forum rules - please read before posting.

Teleporting PlayerStart when returning to original scene

edited November 2021 in Technical Q&A

Hello Adventurers!

First, using AC 1.74.3, and Unity 2021.2.3f1. And all of the menus are Unity UI.

In the game there's a drag and drop puzzle located in its own scene, using the AC drag and drop puzzle template.

Since the puzzle is in its own scene, I was looking for a way for the Player's position to remain the same as the original scene, entering the puzzle, then exiting the puzzle and returning to the original / previous scene.

I noticed this following thread describes a similar situation: The advice given was to use "Object: Teleport" on a new (separate) PlayerStart to teleport this PlayerStart to the player's current position -- which has its last Player position saved by a "Remember Transform" component attached to it:
https://www.adventurecreator.org/forum/discussion/8963/remember-player-position

I followed the advice there, though the Player doesn't seem to be teleporting to this new PlayerStart created in the original / previous scene. The new PlayerStart (with the Remember Transform component added) also doesn't seem to be teleporting to the Player's previous position in the original scene after exiting the Puzzle scene.

The Object: Teleport Action was used just before switching to the new scene.
To supply some additional details, the Object: Teleport Action also has "Position Relative To" set to "Relative To Player" -- as it's my best understanding that this is how the PlayerStart gets teleported to the original / previous position of the Player.

Would much rather use this method of teleporting the PlayerStart position, as it feels like its the most straightforward and logical way to approach this (Noted from the aforementioned thread, Player-switching sounds like another option, though it feels much more involved).

Any assistance would be greatly appreciated!

Comments

  • To supply some additional details, the Object: Teleport Action also has "Position Relative To" set to "Relative To Player"

    Leave this as "None" - the relative options cause the final position to factor in its original position, whereas you only need the PlayerStart to appear at the same place as the Player.

    Player-switching sounds like another option, though it feels much more involved

    This would be my approach. The process shouldn't be that involved: just create a new Player prefab (can be an empty with the Player component), assign it in the Settings Manager as an additional Player, give it a starting scene of the puzzle scene, and then switch to it using "Player: Switch" instead of "Scene: Switch".

  • edited January 2022

    Thank you for that!

    Decided to enable Player-switching as I'm using it to switch scenes to a Puzzle closeup (using the AC drag and drop puzzle template); Then return back to the original scene.
    And I may have a use for Player-switching to switch to another Playable character later in the game.

    After implementing Player-switching, I encountered a small issue in regards to the "Puzzle" scene. The switched-Player spawned in the Puzzle scene is moveable when clicking in other areas of the scene (other than the draggable objects).

    Here's a screenshot of an example of the movement in the scene:
    https://imgur.com/a/lqO1xjq

    In that Puzzle scene's "OnStart" ActionList, I tried setting Engine: Manage systems; with both Movement: Disabled, and Player: Disabled.
    Though the switched-Player continues to move when clicking in any other areas of the Puzzle scene (other than the draggable objects).

    Some other details that are important to share:

    • The Player spawned into the "Puzzle" scene is indeed the new Player-switched Player created just for this scene.
    • If another previous scene is loaded before the Puzzle scene, the switched-Player is able to move about (When running in "Play" mode).
    • If running in "Play" mode in the same Puzzle scene, the same switched-Player remains in place, and doesn't have an ability to move when clicking in the scene.

    Any further assistance is very much appreciated!

  • What is your game's "Movement method", and are you using any custom motion controllers / scripts that affect character motion?

    If you're sticking with AC's motion features, then using the Action Engine: Manage systems Action as you mention should be enough. An alternative would be the Player: Constrain Action. Does re-running either of these Actions manually once the scene has loaded cause them to work?

    Though, even with this issue there should be a couple of "hacks" to bypass it:

    1. Make the Player invisible (remove their sprites/graphics) so that their position is irrelevant
    2. Set their starting position to off-screen and remove any NavMesh.
  • edited January 2022

    Thank you!

    The "Movement method" is just set to "Point and Click" and using AC's motion features.

    Originally, the Engine: Manage systems Actions were running in the "OnStart" ActionList in the same Puzzle scene.

    Moving the Engine: Manage systems Actions to occur before that Puzzle scene (to the ActionList for an Inventory items' "combine event") worked to disable movement.

    In other unrelated scenes in the game, I'd used Engine: Manage systems before in scenes' "OnStart" ActionLists to disable and enable movements, and it always appeared to work that way.
    That's why the Action was previously placed in the "OnStart" ActionList of the Puzzle scene.

    Not completely understanding what leads to this with 2D Puzzle template integrated scenes. Perhaps some more details can be shared there.

    Though in any case, moving the Action to occur before the Puzzle scene appears to work, so will keep this workflow in mind to disable the switched-Player's movement when creating other "closeup" puzzles in the future.

  • Ah, I see.

    If you switch player, then the state of scene the new player is being restored - rather than initialised. Its OnLoad cutscene is run, not OnStart.

    Assigning your OnStart cutscene into the OnLoad field should resolve it, but preceding your Player: Switch Action with Engine: Manage systems is just as valid.

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.