Forum rules - please read before posting.

Remembering visibility and position of NPC

Hi

I have an NPC which is a robot. The story is that you're given the robot (he appears in your inventory as an inventory item) and he follows you around.

The workflow is that I have a script that monitors for the presence of the inventory item then runs an asset that Adds the Object to the scene, then makes the newly Added object follow the player and sets a global variable to say that the robot is present.

The robot has a remember NPC component attached.

This all works. However when I load a save game, the robot doesn't appear. This is, I'm assuming, because the Remember NPC component doesn't remember the presence of the NPC, it assumes that it is present in the scene.

I also tried adding a Remember Transform component to the NPC with Save Presence set, and the NPC in a Resources folder. However when I do that it seems to break the Follow Player and the robot sits there doing nothing.

Is a better way to approach this to have an NPC present in every scene, but have its Remember Visibility set to not show at start, and then if the robot is in the inventory, and the player enters a scene, have the robot move to the player, set it to visible? Would this be a more reliable way to get the NPC position saved and have the Load mechanism replace the drone on a Load event?

Olly

Comments

  • You could rely on the Inventory: Scene item Action to have an in-scene representation of the item (see this tutorial).

    However, as the robot (presumably) remains in the Inventory, and can be used in different scenes, I'd say the better approach would be to make him another Player.

    If you enable Player-switching in the Settings Manager, you can assign as many Player characters as you need. These don't literally need to be characters that the Player controls: uncontrolled Players will be considered NPCs, but AC will keep track of their current scene and position automatically.

    You can convert an NPC to a Player via its cog Inspector icon - a tutorial on AC's Player switching system can be found here.

  • So, if I enable player switching, and convert my NPC to a player, and add it to the player list in the Settings, I can still treat it as an NPC (move it around, give it instructions etc) but the only real difference will be that AC will save it's state and location? I don't need to switch players when giving it commands or moving it around?

  • Yes, exactly.

    As an added bonus, you can then any check "Is Player?" in any character Action to get a drop-down of which pre-assigned Player you want to affect.

  • edited May 15

    Thanks Chris.

    I think I have this working now. However what I seem to have found is that neither the Remember NPC or the Player compoment itself seems to remember the Follow Player status. Can you take a look?

    If I save the game with the NPC/Player following the active player, it doesn't go back to the same state on a game load.

    As a quick additional feature request, it would also be great if the Player and NPC component showed the current Follow Player status, as they do with inventory items.

    Olly

  • What's your AC version?

    You don't need Remember NPC - Players are saved automatically, and this will create a save-data conflict.

    Remove this component and save again. Then, go through the data for it in the Save-File Manager, and locate the "Player data" section for that character. Copy it to Json / post a screenshot, and I'll take a look.

  • edited May 17

    Hi Chris

    I've been chasing my tail on this for a few days (only get a small window of time each day on this at the mo). It would appear that the inactive player that is my drone robot isn't spawning at the spawn point, but rather wayyyyy out of scene. As a result it appears not to be present. This only happens when I make it a player and Teleport the inactive player.

    If I set to an NPC and have it present on the scene, but then teleport it to the right location when the game dictates, then it works as expected. However as an NPC it doesn't save the position on save.


    I've included above the actionlist that is teleporting the inactive player (and thus instantiating it) but the same thing happens whether I specify the default start or specify the actual start point.

    AC 1.80.5

    Any ideas? I feel I'm so close.

    Olly

  • What are the Drone's starting data, as set in the Settings Manager, and do any related messages appear in the Console? I'll attempt a recreation.

    One thing to try is an additional Object: Teleport Action, which also has a Player dropdown, to move them to the specific PlayerStart, afterwards.

  • Right. If I set the action to Object: Teleport and choose the player Drone NPC then that player is never spawned.

    If I choose Player: Teleport and choose the Drone NPC, then the drone is spawned, but at some very distant location.

    I've tried setting the Start Data of the Player 1 entry in Settings to both default start and the chosen start point. However, this player will be used in multiple scenes so not sure how that will work. But, either way, it doesn't seem to have any impact.

  • Sorry, I misread your post above. If it use Object: Teleport after the Player: Teleport then yes, it seems to work.

  • Good, leave it at that for now.

    If you set the Player's starting Scene index to -1, I'll include a fix in the next update to have the "Base On Previous" PlayerStart react to your settings.

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.