using { /Verse.org/SceneGraph }
using { /Verse.org/SceneGraph/KeyframedMovement }
using { /Verse.org/Simulation }
using { /Verse.org/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Bolt this onto an entity with a Keyframed Movement component to make it
# PATROL: walk out to a far point, then back, forever — like a guard pacing
# a hallway or a security drone sweeping a vault.
patrol_component := class<final_super>(component):
# How far the patrol walks before turning back, in units.
@editable
var PatrolDistance<public>:float = 600.0
# Seconds for ONE leg (out OR back).
@editable
var LegSeconds<public>:float = 3.0
OnBeginSimulation<override>():void =
(super:)OnBeginSimulation()
if (Mover := Entity.GetComponent[keyframed_movement_component]):
# The single outbound leg: glide PatrolDistance to the left,
# easing in and out so each turn feels like a real pause-and-go.
Outbound := keyframed_movement_delta:
Duration := LegSeconds
Easing := ease_in_out_cubic_bezier_easing_function{}
Transform := transform:
Translation := vector3:
Verse Library
verse
02 Standalone
Enables continuous back-and-forth patrol movement for entities using keyframed transforms.
verse-library/verse-anim-patrol-sequence/02-standalone.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.