V1.01
Description:
The Sentinel is a package consisting of an NPC that walks or runs around, randomly going from point to point and spotting any player that enters its field of view and is not hiding behind an obstacle. A trigger is used to define the zone inside which the NPC will look for players. Once spotted, a player is teleported to a location with a fade to black effect, with a sound and a message on screen. Advanced users can also broadcast a server wide event to apply custom logic to a player when spotted.
Here is a remixable example game with a few sentinels so you can see how they are used (updated for v1.01):
If you find any bug, or have a comment or a suggestion to make, reply here or find me on discord: Czinczar#3046
Update 1 (v1.01):
- Removed _G. global table use and replaced with script property for keeping track of players crouching.
- Added optional ordered destinations: now you can set a path made of nodes that the NPC will follow instead of destinations being random. Read instructions below at point 5 on how to setup.
- Added optional timer override for each individual node. You can even set a wait time of 0 which will in effect transform the node into a 'passing by node" only. See below at point 7.
- Players that spawn inside a sentinel trigger are now taken into account.
- Updated remixable example game.
How to use:
-
Search for âThe Sentinelâ in the community tab and install the package.
-
From the Library tab, bring one âSentinelâ into your game world:
Drop the NPC Sentinel entity on the NPC property like so:
-
From the Library tab, bring one âSentinelUserâ and attach it to the User template:
-
From the Library tab, bring one âSentinelPlayerâ and attach it to the Player template:
-
To customize the possible positions the NPC can walk to, look under the âDestinationsâ folder: for each position you want to add, add a locator under that folder, then another locator under the locator you just added which the NPC will look at once the position is reached. You donât need to give these locators any particular names but itâs clearer if you do:
Since v1.01, you can setup a list of ordered positions: the NPC will move from node to node in numerical order, then it will reverse and go back to the first node, and so on. To set this up, first you have to check the âOrdered Destinationsâ checkbox as follows:
Then the names of your destinations MUST BE numbers, like so:
And thatâs all. Now, the NPC will start by going to destination 1, then to 2, then 3 and so on until 6, then it will go back to 5, then 4 and so on until 1, and it will start over from 1. Simply uncheck the âOrdered Destinationsâ checkbox if you want to go back to random destinations. -
Select the sentinel in the game world and look at its properties:
-
Timer
is the minimum and maximum time the NPC will stay at each position before walking to another position. A random number of seconds will be picked between these numbers. -
RunOrWalk
letâs you decide if the NPC should walk or run: 1 = Walk, 2 = Run, 3 = Sprint. -
NPCFoV
is the field of view of the NPC and must be a number between 1 and -1. The lower the number, the wider the field of view of the NPC will be: 0.9 is very narrow, 0 is 180° in front, -1 is 360° all around and itâs as if the NPC has eyes on the back of the head. A value between 0.1 and 0.4 is recommended to simulate human peripheral vision. -
Ordered Destinations
will make the NPC move from node to node in the order you want. If you check this, the names of your destinations MUST BE numbers. -
Default Spot Logic
will lock input and teleport the spotted player to the SpottedRebirthPosition with a sound, a fade to black effect and a big âSPOTTED!â message on screen, if checked. Use CustomEventName to apply custom logic if you decide to uncheck this, otherwise nothing will happen at all. Warning: if you disable the default spot logic and apply your own logic, make sure to teleport the player outside of the zone trigger, otherwise some things might break. -
Custom Event Name
is the name of the event that will be broadcast server wide using âBroadcastToScriptsâ when a player has been spotted. The broadcast will contain the player entity as first parameter. Leave blank if not in use. -
SpottedRebirthPosition
is the position the player will be teleported to when spotted by the NPC. Can be any entity. -
DestinationsFolder
is simply the Destinations locator that contains all the possible NPC destinations. You should not need to touch this. -
NPC
is the NPC entity itself under the sentinel template. Sometimes you need to drag and drop the npc on this property again, even if the property shows that itâs already done. -
ZoneTrigger
is the trigger which will be used by the NPC to spot players. Any player outside this trigger will be ignored.
-
Since v1.01, you can override the time the NPC will wait at each individual node. To achieve this, simply place a locator as a child of the LookAt locator and rename it to the number of seconds you want the NPC to wait at this node, like so:
This will effectively override the global timer that has been set in the template properties.
By setting it to 0, you can use this feature to turn a node into a simple transit point that the NPC will cross without waiting and then move to the next node:
-
You can change the sound that plays when the player is spotted and the color of the fade to black effect by looking at the SentinelUser template that is attached to the User template:
Updates to expect:
-
Make the npc listen for sound: when the player is running, sprinting or jumping, the npc might have its fov to a full 360° for a short time to force players to adopt a stealthy approach.
-
Make it so that multiple triggers can be used in order to adapt the shape of the zone to different shaped rooms for example.