Name: Idle NPCs
By AdamO on Discord
The Idle NPCs package provides logic for NPCs to idly walk (or jog, or run) around points in your game, look at points of interest, and optionally interact with each other, or players, by watching or emoting.
This logic is used for the NPCs in the Hub.
- Add the template “IdleNPCs” to your game.
- Adjust the TravelNode locators under “Nodes” to change where the NPCs travel to and their points of interest.
- Adjust the IdleNPC template to change NPC behaviour, like their chance of emoting on an encounter, or what speed they travel at.
- Travel nodes are the locators that NPCs will travel between.
- The connectedNodes property is all other nodes that an NPC can go to from this node, and you must set this up for each new travel node you add.
- The nodeRadius property defines how “loosely” the NPC can go to that point, i.e. a radius of 100 means if the NPC chooses to go to this node, it can go to a point anywhere within a 100cm (1m) radius of the actual locator. A bigger radius will mean NPC travel can feel more “natural”.
- The interestPoint property is optional - set an entity in here for the NPCs to look at when they’re at this node. E.g. if your NPCs are walking around a sports bar, and there’s a node in front of the TV, you could set this node’s interest point as the TV so your NPCs will “watch” the TV when standing at this point. You can use moving points of interest.
- The Idle NPC template is the NPC that’s set up to travel between nodes and interact with other NPCs, or with players.
- It’s worth setting up the usual NPC properties, like their look and outfit, to suit your game.
- The startNode property is the first node your NPC will try to travel to.
- The nodeWaitTime property is a random range for how many seconds the NPC will wait at a node before moving on.
- The travelLookTime property is a random range for how long the NPC will take to look at its next destination before travelling there.
- The moveMode property defines how NPCs will travel between nodes. For a busy crowd you may want to set this to random!
- The defaultInterestOffset defines how high an NPC will look if no interest point is set at a node.
- The npcEncounterInterestChance property is a percentage chance for this NPC to interact if it encounters another NPC.
- The playerEncounterInterestChance property is a percentage chance for this NPC to interact if it encounters a player.
- An encounter means the NPC will stop and look at the other player / NPC it’s interacting with, with a chance of emoting.
- The encounterInterestTime property is a random range for how many seconds an encounter will last.
- The encounterEmoteChance property is a percentage chance for this NPC to play one of its encounter emotes during an encounter. Note when two NPCs have an encounter, this chance is SHARED, which means either neither NPC will emote, or both will.
- The emoteWaitTime property is how long the NPC will wait in an encounter before playing its emote.
- The encounterEmotes property is an array of possible emotes the NPC could play in an encounter.
- The encounterCooldownTime property is the number of seconds an NPC must leave between encounters, to stop it from constantly having encounters in a busy space.