Forum rules - please read before posting.

Remember character switch across scenes with instance

Hello! I've recently started using Adventure Creator and it's been an amazing tool so far! I'm using Unity 18.3.5 and AC version 1.67.5.

Right now I am having issues with character switching. In my game I have 2 playable characters. In the first scene, the player starts off as a specific character, Gwen, and can switch to another character, Lucas by clicking on a Switch Character button. For this scene, Lucas should be a visible NPC when the scene starts. When I add an instance of the Lucas_NPC and move on to the next scene with him as the player, Gwen becomes the playable character automatically and Lucas is still stuck in the previous scene.

Of course, if I remove the instance of Lucas_NPC and just have him appear when the player switches and then try to go to a different scene he stays playable into the next scene. (Gwen is still stuck in the previous scene though).

Ideally, no matter which character is Player, when you switch scenes both the NPC and Player should be present.

I'm a little unsure of what I need to do to get this to work like I need it to. Does anyone have any recommendations?

Comments

  • Welcome to the community, @lacey_lansaw.

    I'm not sure on what you've done so far, because you haven't shared details or screenshots about what Actions you're running, or how your NPCs and Players are set up. Have you seen this tutorial on player-switching?

    Generally speaking, however, you want to make a prefab out of each NPC, and assign them as their respective Player's "Associated NPC". This NPC will then be swapped with this Player (both ways) when using the Player: Switch Action.

    Getting an NPC to appear in the next scene is a little more tricky, because an NPC won't travel across a scene with the Player. What you need to instead do is use a Player: Check Action in your new scenes OnStart cutscene to determine which NPC should be present, and then place them correctly.

    This is best done by placing both NPC prefabs in the scene file itself, and then using the Object: Teleport Action to place them in/out of view as appropriate.

  • Thanks for your response! I have followed that tutorial. I've created NPCs and assigned them to their respective players.

    I have the switching using the Player: Switch action and that works perfectly so the only issue is when we switch scenes.

    Currently, I do have a Player: Check Action in my new scene OnStart cutscene and that works as well. If I come in as one player, the other NPC is placed in the new scene. Right now I just have the NPCs added to the scene by using the Object: Add action so I'll try it with the Object: Teleport Action instead because even with that I've been running into issues.

    https://imgur.com/a/lgaoXVJ

    The issue we have been running into is that when we go to the new scene and try to switch players again, it automatically switches the NPC from the previous scene to the player so it loads the previous scene and ignores the NPC in the new scene. Do you believe using the Teleport Action will prevent this?

  • If Restore position? is checked in your Player: Switch Action, then the game will return to wherever that player last was when active - regardless of where their associated NPC may be.

    To set which scene the new player appears in, you need to uncheck this and set the New Player position field to Replace Associated NPC.

    However, I am currently working on a way to move an inactive Player to the current scene, so that restoring their position results in them appearing in the current scene instead. This will likely be in the form of a new Action, but at the very least made available through code - expect to see this in the upcoming v1.68.0 update.

  • Got ya, that was where the issue was. Thank you for catching that!

    I'm excited for new update. Adventure Creator has been amazing so far.

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.