s&
About
The Project
info
About s&box
map
Roadmap
monitoring
Metrics
Engine startup and usage numbers
Updates
newspaper
Latest News
published_with_changes
Changes
Release-by-release changelog
Games
Browse Games
Discover Games
gamejams
Workshop
Playable
sports_esports
Games
Standalone games and gamemodes
Assets
landscape
Maps
view_in_ar
Models
texture
Materials
apparel
Clothing
apps
Everything
Every asset type in one list
Forum
Learn
Documentation
rocket_launch
Getting Started
docs
Documentation
api
API Reference
Resources
school
Tutorials
manage_search
Code Search
Get s&box
Sign in with Steam
Api
Classes
SensesLayer
chevron_left
Classes
class
SensesLayer
Constructors
functions
SensesLayer
Properties
data_object
Disturbance
data_object
FieldOfView
data_object
HearingRange
data_object
QuietSpeed
data_object
SightRange
data_object
Targets
data_object
VisibleHostiles
data_object
VisibleThreats
Methods
functions
FindBestTarget
functions
FindNearestVisible
functions
GetPushingPlayer
lock
OnDisabled
lock
OnStart
SensesLayer
Environmental awareness and target detection for an NPC. Disabling the layer clears its results.
class
Sandbox.Npcs.Layers
.
account_tree
extends
BaseNpcLayer
Sandbox.Engine
build
Constructors
1
SensesLayer
(
)
data_object
Properties
8
Disturbance
Nullable`1
The nearest disturbance (gunshot, death, etc.) this NPC currently senses, if any.
FieldOfView
float
Total horizontal field of view in degrees. Targets outside this cone aren't seen (they can still be heard, or noticed if they're right next to the NPC).
HearingRange
float
How far the NPC can hear.
QuietSpeed
float
Hostiles moving slower than this can't be heard -- creep (crouch-walk) to sneak up on someone.
SightRange
float
How far the NPC can see.
Targets
SenseTargets
Which agents the NPC scans for. This is just the broad-phase filter -- disposition decides who counts as hostile.
VisibleHostiles
IReadOnlyList`1
Visible entities this NPC is disposed Hostile toward.
VisibleThreats
IReadOnlyList`1
Visible entities this NPC is disposed Fearful toward (things to flee from).
functions
Methods
5
FindBestTarget
(
)
GameObject
Find the visible hostile this NPC should engage first: highest relationship priority, nearest breaking ties.
FindNearestVisible
(
tag
)
GameObject
Find the nearest visible object with a specific tag. May perform visibility traces for unchecked candidates.
GetPushingPlayer
(
)
GameObject
A player inside our personal space who was moving toward us at the last scan -- they're trying to get past and we're in their way. Returns null when nobody is barging in.
OnDisabled
(
)
OnStart
(
)
Inheritance
Component
BaseNpcLayer
SensesLayer
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.