Forum rules - please read before posting.

Came back to a scene and come back in the same position

Hi everyone,
AC 1.70.0 + Unity 2019.2.17f1 on a 2d game.

I have this kind of situation: my player is in a scene (it's not a fixed scene, my player can be in any scene), he examines an object and then then I switch scene (two scenes for a couple of cutscenes in other locations). At the end of this two cutscenes I have to come back to the original scene, and the player has to be in the exact point before the cutscenes start.

Here my issues:
1. How can I come back to the original scene (I see "switch to previous", but not two scenes before. And I haven't a specific number for the scene, because my player can be in any scene)
2. How can I put the player in the exact position of the original scene?

Thank you very much.

Comments

  • What's the context of the cutscene that plays? Is it a cutaway scene that involves other characters, or is the player character also on-screen?

    If the former, you're probably best off by switching the actual player-character to one that's present in the new scenes, and then switch back to the original player afterwards. That way, the old player's position is the same because they technically never moved.

    Otherwise, you'll have to rely either on some custom scripting, or Marker trickery whereby you teleport a Marker to the Player's position before running the cutscene, save its position with Remember Transform, then teleport the Player back to it afterwards.

    I'd recommend the player-switching method if appropriate, but upgrade to the latest first. AC's Player-switching workflow has been overhauled in the current release - see this video - though you'll need to take care to back up your project first because of this.

  • Hi Chris, thank you very much. The first cutscene is a video while, in the second one, there's another character but, in all, there isn't the player. I'll try with the marker trick.

    But how can I tell to AC in which scene return after the two cutscenes? The original scene (before the two cutscenes) can be any room in the game, not a particular scene.

  • You'll need to use scripting to set an Integer global variable's value to the original scene's index before leaving it. Create a new variable named e.g. OriginalSceneIndex and paste this code into a new C# script:

    public void UpdateSceneIndexVariable ()
    {
        AC.GlobalVariables.GetVariable ("OriginalSceneIndex").IntegerValue = AC.SceneChanger.CurrentSceneIndex;
    }
    

    Then attach the script to a new GameObject and make it a prefab. You can then trigger this function by referencing the prefab in the Object: Call event Action.

    Make sure that the variable's being correctly set, and you can then use the following function to place the player back in the original scene:

    public void LoadOriginalScene ()
    {
        AC.KickStarter.sceneChanger.ChangeScene (AC.GlobalVariables.GetVariable ("OriginalSceneIndex").IntegerValue, false);
    }
    

    This too can be placed in the same C# file and triggered with the same Action type.

  • Thank you Chris. Now I solve the change of scene, but I have the issue of the the player's position when he comes back.
    I tried with the teleport of the marker, but how can teleport it on player position? I can set the object to move, but in the filed "Teleport to:" I haven't the player.
    Thank you very much.

  • Attach the Marker component to your Player.

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.