Forum rules - please read before posting.

Can I let an NPC follow the player to an other scenes?

Hello everyone,

I have a couple of scenes in which an NPC has to follow the player. This works in the corresponding scenes as it should.
But also there are scenes in which the NPC has to follow the player to the next scene. Here I work with triggers. When the player enters this the scene is changed. Until here The NPC follows the the player, but not up to the next scene. How can I send the NPC with the player to the next scene? Is that possible?

Greets
Martin

Comments

  • I would probably use a Gvar to verify if the player is being "followed". When the NPC first starts to follow I would set the Gvar to true. Then, I would have a variable check on all the On Start cut scenes on all the scenes where the NPC can follow the player. If the Gvar is set to true, I would then have the cut scenes spawn the NPC and set him to follow, creating the illusion that he "followed" the player. If needed I would add a Variable Set to change the state of the Gvar to "false" on all the scenes where the NPC can't follow the player (always on the On Start cut scene). Then, if the player goes the wrong way, you could give the player a warning that the NPC left because the player was dawdling. Then If the player goes back to the NPC, he could get a different dialogue and try again.

    Anyways,  that's just an idea, you can always elaborate to your specific needs.
  • Sounds like a good method to me.  You could also move the Actions that check the variable and act accordingly to an ActionList asset so that you can recycle it whenever needed.  Have a look at parameters as well, but I'd recommend getting one scene working with Cutscenes first before moving onto that.
  • Hi Alverik, hi Chris,

    thank you for your isea Alverik. I testet it last Night and it works fine!
    First of all, I tested it with three scenes. I think that it should work for other scenes as well.

    Now I try the next step as you described it, Chris.

    Thank you both for your Help.

    Greets
    Martin


  • Hello, I'm bringing back this topic 'cause I've a similar problem but I haven't found a solution (even if I tried to follow your hints).
    Basically on my game I've all the time 2 switchable players. When they are not selected, the NPC is replaced and follow the player.
    Everything works perfectly on a single scene (switching, positions, etc... all good!), but can't manage to make the NPC follow properly the player on a new scene (and back).
    Basically I tried to follow what Alverik was suggesting, but rather than having a variable, I've a simple "Check Player" Action. Entering a scene, I've an OnStart Cutscenes: If my player is A I'll "spawn" NPC B and viceversa.
    The thing is... I'm probably missing the "spawn" part. How do you spawn the NPC?!
    I though it was a "Object Teleport", but for some reasons it's not working properly (and, by the way, if a scene has 3 entrances, should I give 3 actions "Check Previous Scene" then spawn the NPC to 3 different markers according to that?).
    Isn't there a way to spawn it always next to Player?
    And when going back to a previous scene, what should I do to avoid the old NPC that I left there for being in the wrong place? Use teleport again?
    Example... I'm going to Scene2 with Player A. On Scene2 I switch to Player B, then I go back to Scene1 and I don't want to risk to find NPC B there like a doppelganger! I tried different methods (like Remove Object selecting the NPC, but I can't make it work). Is something related with having the NPC on scenes? Can I call the NPC from Assets/Resources even if the NPC is not placed in scene? I tried but it's not working...

    Maybe there's a very simple way to do it but I'm missing something...?

    THANKS A LOT!

  • If you wish to spawn an object into the scene, use the Object: Add or remove Action. Once present, you can then use Object: Teleport to correctly place them.

    However, it would make things more manageable to have both NPCs present in both scene files, and simply hide the one that you don't want to show. You then don't have to worry about what's present, what needs to be removed, etc.

    You're on the right track with Scene: Check and Player: Check Actions to work out where to place the NPC - just precede all these with two "teleport" Actions to hide both of the NPCs out of the way before correctly placing one of them.

  • Ok, thanks! I'll give it a try...
    With "hide" you simply mean to teleport the NPCs out of the camera?

  • I cannot make it work... there's something weird with the "NPC Follow", because if I "hide" a NPC sending it out of screen, then when moving back and forth the two scenes and/or swapping characters, something trigger the "hidden" NPC to follow the Player so I'll have two... Even if it's sent out of screen at the beginning and there's nothing calling him back into the scene.

    For example I'm using A, going from Scene01 to Scene02. On Scene02 I switch to B, then I go back to Scene01 and after a bit NPC B that was hidden is crawling the screen and starts to follow Player B... (that has never been set as a condition, NPC B cannot follow Player B, because the NPC follow is always triggered by first checking who's the player)

    Should I change something on my Swapping Characters Action List? Or on my OnStart?

    At the moment I'm working with two simple entrances as a test. Here a screenshot of my OnStart actionlist https://ibb.co/mtp9Yx2

    And here of my Switching Character one (triggered by a button and by TAB input) https://ibb.co/y5t66G3 (note that I removed some "beauty" things to make it short, like camera fade, switching inventory graphic and things like that).

    I will try now using the Add/Remove method...

  • UPDATE
    Looks like I fixed it by removing the NPCs from the scene and using an Add/Remove method. Changing the OnStart actions this way
    https://ibb.co/q70W6BN

  • Teleporting an NPC won't affect his "follow" state.

    If he has a Remember NPC component, then his follow state will be resumed upon re-entering the scene.

    If you've fixed it by adding/removing then fine - but I'd imagine the original method could be fixed by using the "Stop following" command at the same time you hide both NPCs out of the way,

  • I'd try the "Stop Following" and see if it works that way...
    Anyway, the add/remove works fine, even if the console give me the error "can't delete asset, bla bla...".

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.