Realot StudioDocs
Components

NavAgent2D

Realot Studio NavAgent2D component reference: fields, script API, behavior and examples.

View as Markdownllms.txt
ScopeThis page documents the NavAgent2D component in Realot Studio. Runtime fields are serialized scene data; the Script API section lists only members intentionally exposed to game scripts.
Where to find it in the editorInspector → Add Component → Nav Agent 2D. For radius and area painting, use the Nav toolbar after a Nav World 2D exists; Match Collider is in the Nav Agent inspector section.

#What it does

Per-agent navigation settings and current path state for NavWorld2D pathfinding.

Component setup & editor toolsNavAgent2D is the moving-agent side of Realot Studio navigation. It works with NavWorld2D and the navigation API.

#How to add and use NavAgent2D

Editor path: Select the target entity in the Hierarchy (left side) → look at the Inspector (right side) → click Add Component at the bottom of the Inspector → search for NavAgent2D → click the component row. The Add Component picker is a centered modal with a search box; it only lists components not already attached.

For components with a dedicated editor tool, the tool is opened or activated from the location described below. Do not assume that adding the component alone activates its editor; some systems require a separate window, panel, or viewport tool.

#Component setup & editor tools

  • Select the agent → Inspector → Add Component → Nav Agent 2D. Configure agent parameters, then use the NavWorld2D + navigation workflow before expecting paths. Runtime movement is driven by the NavAgent2D API.

#What you should see after adding it

The component appears as its own section in the Inspector. Its serialized settings are listed in the Component data table below. If a field is conditional, it appears only when the relevant mode/type is selected. If a field is a runtime state field (for example grounded or resolved velocity), treat it as read-only diagnostic state unless the API reference explicitly documents it as writable.

#How to read the settings

For every setting below, the documentation distinguishes type, default, meaning, and tuning direction where behavior is known. When a value represents a direction, use the engine's coordinate convention documented in Coordinate system; do not substitute Unity/Godot conventions.

#Component data

FieldTypePurposeDefault
radiusnumberAgent px clearance this agent needs from obstacles/other geometry.16
speednumberMovement px/s top move speed120
accelerationnumberpx/s^2 — how fast the agent speeds up toward `speed`800
decelerationnumberpx/s^2 — how fast the agent slows when arriving/stopping1000
stoppingDistancenumberpx from the final target that counts as arrived1
autoRepathbooleanPathfinding if true, the agent re-checks its path on a timer/ontrue
repathIntervalnumbertarget movement automatically (see repathInterval/ repathDistance below).0.35
repathDistancenumberworld units a moving target must shift before an4
avoidanceEnabledbooleanAvoidance — separate from pathfinding (see NavWorldSystem.js header: "Pathfinding answers how do I get there, avoidance answers how do I avoid this NPC directly in front of me").true
avoidancePrioritynumber0-100. Higher-priority agents yield less to50
collabEnabledbooleanCollaboration — separate from both pathfinding AND avoidance (see #5 above: "how do I get there" vs "how do I avoid the NPC in front of me").false
collabGroupRadiusnumberscripts behave exactly as before.96
vehicleLookaheadnumberCar + NavAgent2D local vehicle planner.72
vehicleCornerLookaheadnumberCorner lookahead.110
vehicleObstacleLookaheadnumberObstacle lookahead.120
vehicleObstacleWidthnumberObstacle width estimate.28
vehicleSteerSmoothingnumberSteering smoothing.7
vehicleSpeedSmoothingnumberSpeed smoothing.5
vehicleCornerSlowdownnumberCorner slowdown multiplier.0.72
vehicleObstacleBrakenumberObstacle braking factor.0.9
vehicleRecoveryTimenumberseconds of being stuck (pushing into1.35
vehicleRecoveryReverseTimenumbersomething with little progress, drifting off the planned lane, or on a collision course with something dead ahead) before the car commits to a recovery maneuver.0.9
areavalueNavigation — same model as Unity's NavMeshAgent.areaMask: a bitmask of which NavWorld2D cell areas (Ground, Water, Mud, ...) this agent is ALLOWED to path through at all — a route can never cross a bit that's off here, no matter how short a shortcut it would be.0xffff
areaCostsnullable valuePer-agent override of NavWorld2D.areaCosts, index-aligned with the same 16 area slots (see editor/state/NavAreas.js for the name registry both arrays share).null
currentPathnullable valueSet (transiently, for one movement step) by NavWorldSystem/ScriptAPI path-following helpers to hand a fresh path to this agent without NavAgent2D reaching back into the system itself — plain data, one- shot per repath, same pattern as CharacterController's requestJump.null
currentPathIndexnumberInspector field stored on this component.0

#Tuning behavior

These are the practical direction-of-change rules for the most important controls on this component.

SettingWhat changing it does
radiusThe clearance needed around this agent. Larger radius makes narrow passages become non-walkable for this agent.
speedTop travel speed in world units/second.
acceleration / decelerationHigher values make movement and stopping snappier; lower values make it softer.
stoppingDistanceLarger values let the agent stop farther from the final target.
repathIntervalLower reacts faster to changing routes/targets but costs more path queries.
areaHard allowed-area mask; excluding an area prevents the route from crossing it.

#Script API

MemberKindDescription
accelerationProperty (read/write)Acceleration.
areaProperty (read/write)Allowed area mask.
areaCostsProperty (read/write)16-entry area cost overrides.
autoRepathProperty (read/write)Auto-repath.
avoidanceEnabledProperty (read/write)Avoidance toggle.
avoidancePriorityProperty (read/write)Avoidance priority.
collabEnabledProperty (read/write)Collaborative vehicle avoidance.
collabGroupRadiusProperty (read/write)Group radius.
currentPathProperty (read-only)Read-only world-space waypoint array or null.
currentPathIndexProperty (read-only)Read-only current waypoint index.
decelerationProperty (read/write)Deceleration.
radiusProperty (read/write)Agent radius.
repathDistanceProperty (read/write)Target-move repath threshold.
repathIntervalProperty (read/write)Repath interval.
speedProperty (read/write)Preferred speed.
stoppingDistanceProperty (read/write)Stopping distance.
vehicleCornerLookaheadProperty (read/write)Corner lookahead.
vehicleCornerSlowdownProperty (read/write)Corner slowdown.
vehicleLookaheadProperty (read/write)Vehicle lookahead.
vehicleObstacleBrakeProperty (read/write)Obstacle brake factor.
vehicleObstacleLookaheadProperty (read/write)Obstacle lookahead.
vehicleObstacleWidthProperty (read/write)Obstacle width.
vehicleRecoveryReverseTimeProperty (read/write)Reverse recovery time.
vehicleRecoveryTimeProperty (read/write)Recovery time.
vehicleSpeedSmoothingProperty (read/write)Speed smoothing.
vehicleSteerSmoothingProperty (read/write)Steering smoothing.

#Examples

js
this.navAgent.speed = 180;
js
this.navAgent.autoRepath = true;
Need the full workflow?Components: complete workflow covers adding, configuring, testing, combining, and removing components.