Roaming NPCs - Living Cty Build Jam


Description

Quickly populate your environments with NPCs that roam around waypoints and perform configurable actions or activities.

Instructions

  1. Go to the Community Tab and search “Roaming NPCs”
  2. Install the package by “itsjacky7”
  3. Drag the “NPC Spawner” template into the world
  4. Add additional/modify the positions of the “NPC Waypoints”
  5. Modify the properties of the “NPC Waypoints” (see below for more details)

Example Scene

  • Included in the package is a “Roaming NPCs Example Scene” template that can be dragged into the world for a demo of the functionality of the Roaming NPCs package (feature in the preview video above).


Template Properties

NPC Spawner

  • Spawn on Init

    • Spawner will start spawning NPCs immediately when the entity is created.

  • Max NPC

    • Maximum number of NPCs that will be spawned. Spawner will stop spawning once this number is reached and will be spawning again once an NPC has been despawned.

  • Spawn Interval

    • The time interval in seconds in which NPCs are spawned in at.

  • Waypoints

    • A locator entity which holds all the NPC Waypoints as children. This property is already set in the default NPC Spawner. Note that NPC Waypoints needs to be direct children of this Waypoints locator.

      Waypoint Hierarchy
  • NPC Templates

    • List of NPC templates that the NPC Spawner will randomly pick from to spawn NPCs.
    • To customize the NPCs spawned, simply duplicate the “NPC 01” template and then modify the Customization properties (for appearance) or any other NPC property (e.g. Collision Preset). Click the Stop Editing Template button to save the template and then drag the NPC template into the NPC Spawner’s NPC Templates property.

  • NPC Pool Location

    • NPC Spawner uses object pooling for NPCs. Set property to a locator where NPCs will be positioned when they are inactive.
    • This property is already set in the default NPC Spawner template. You will find an NPC Pool locator with a child voxel mesh for encasing NPCs, simply hide the NPC Pool somewhere in the world that won’t be visible to players.

NPC Waypoint

  • Targets

    • List of NPC Waypoints that the NPC can move to when they reach this waypoint. NPC Waypoints are linked together using this property.
    • Multiple target waypoints can be set. In this case, the NPC will move to a random available waypoint from the list.
    • Two waypoints can have each other as their target to create a 2-way path.
    • Example setup for a waypoint T-Junction.

  • Max NPC

    • Max number of NPCs that can move to this waypoint at any point in time.

  • Is Spawn Point

    • If enabled NPCs can be spawned at this waypoint.

  • Is Endpoint

    • If enabled NPCs will be despawned at this waypoint.

  • Movement Modes

    • Sets the movement mode of the NPC when they enter this waypoint (Walk, Run, Sprint).
    • If set to Random, additional options will be displayed that allows you to set the weighted percentage for each movement modes.



  • Activity

    • If enabled NPCs will perform the configured activity/action when they enter the the waypoint.
    • Additional properties will become available when this is enabled.

    • Activity Duration
      • Duration in seconds that the NPCs will stay at this waypoint.

    • Action
      • None no action is performed.
      • Emote NPC will activate the selected emote.
      • Roll NPC will roll.
      • Jump NPC will jump.
      • Crouch NPC will crouch.
      • Launch NPC will be launched with the impulse of the Vector set.

    • Look At Location
    • Lotier Locations
  • Sound & Effects

    • These properties become available when the properties Is Spawn Point/Is Endpoint/Action is enabled.
    • Spawns a sound and/or effect at the NPCs position when the NPC spawns/despawns/performs an action.
      • Sound/Effect Duration duration in seconds after which the sound/effect will be destroyed.
      • Effect Position Offset vector amount to offset the spawn position of the effect.
      • Effect Rotation Offset rotation amount to offset the spawn rotation of the effect.

  • Waypoint Size

    • NPC Waypoints are Triggers that can be scaled/resized.
    • The size of waypoints matters as NPCs will move to a random point in the Trigger volume.
    • E.g. increase the Trigger size to create an open area that NPCs will roam around or decrease the Trigger size to make NPCs move to a precise position.

NPC

  • maxPathLength
    • Limits the max amount of waypoints for NPCs when generating their paths.
    • This property is added to handle waypoint loops and for performance.
    • This property is not made editable, but if required it can be modified by changing the default value in the NPCScript file.




NPC Waypoint Navigation Logic

  • When NPCs spawn they will generate path by requesting from the NPC Waypoint for available target waypoints without backtracking.
  • This is repeated until a dead end is found and they the NPC will begin navigating the generated path.
  • Once the NPC has reached the end of the path, if they have reached an endpoint they will be despawned. Otherwise, they will generate a new path to navigate.

4 Likes

This is so cool. Love to see if we could combine the flocking / crowds stuff I’ve done in my package (“Living City - Living NPC Crowds and Flocks’”). Really nice documentation and polished showcase also - great job!

1 Like

Hey! I know you! :wave: :smile:

I love this package and the instructions are spot on!
fantastic job!
This NPC package is so so beneficial for everyone that may be a first-timer coming across waypoints.
Thank you for explaining the steps clearly, where a creator can make use of the animations and photos to match are awesome :heavy_heart_exclamation:

2 Likes