Forum rules - please read before posting.

How an NPC follower can remember Conversation toggles across scenes?

edited April 23 in Technical Q&A

In part of my game I have an NPC following the player from scene to scene and you can engage in conversation with this NPC. The Dialog/ToggleOptions need to be remembered across scenes. I've looked through the forum and am now exploring an approach I hope is in the right direction. :D

So far I've made the NPC's Conversation Logic into a prefab, added a 'Survive Scene Changes' component and ticked the box 'Retain in prefab?'. In the Events Editor I've set up an OnBeginGame event that triggers an asset actionlist with an Object/Add pointing to the Conversation Logic prefab. When I start the game the OnBeginGame event runs as expected, but walking between scene A and B, if I toggle any dialog option it only remembers the change within the current scene, it doesn't carry over to the next.

But even if I get this approach to work, how do I point the Dialog/PlaySpeech to the NPC? Asset actionlists seems to only be able to point to the active player and not the prefab of the NPC, as it's not an actionlist within the scene.

I'm using:
Unity 6000.4.1f1
AC v1.86.1

Comments

  • For NPCs that move between scenes, I'd recommend converting them to an inactive Player. An inactive Player is treated like a regular NPC, only AC will handle their presence in the scene automatically. A tutorial on this can be found here.

    An NPC can be converted to a Player via their Inspector's cog menu. Enable Player-switching, and assign their prefab in the list of Players. You can then edit their starting scene/position beside this field.

    To reference this character in Actions, you can then check the Is Player? (or equivalent) box, and then select the specific Player character from the dropdown.

    For the Conversation: yes, it'll need to be a persistent object across scenes. If you use the above technique for your NPC, however, you can just attach it to your NPC's prefab.

    The technique you've described, however, ought to work so far as option changes go. Have you also attached the Remember Conversation component, and are you referencing this Conversation, rather than the original prefab, in your ActionList?

  • edited April 24

    I've watched the video and I think that is the right approach, but it do get a few problems. Lets start with this one:
    I've got the NPC setup as a player character, but I run into an issue when ticking the 'Is Player?' and selecting the character from the drop down. The character is completely unresponsive. This goes for any action, like following the Player, walking to markers and even speaking dialog where the text and portrait simply doesn't show, with the game pausing as if there were dialog. I can still mouseclick to progress the dialog until the actionlist comes to an end, so it doesn't crash the game.

    https://imgbox.com/dUA5oPsr

    Ignore the warning in the image, it doesn't play a role.

  • When using the Player-switching feature, you need to remove the character from the scene files. AC will place them in automatically - use the "Edit start data" button, and the Player: Teleport inactive Action, to set their scene.

  • edited April 26

    Thank Chris, I got it all sorted now.
    The NPC prefab lives outside the scene with the conversation prefab as its child, and the Events Editor Object/Add's the conversation prefab in the BeginGame event. Everything clicked into place.

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.