Fencerotator
Based on game build 714014 | Last updated: 2026-03-03
Overview
Fencerotator is a lightweight component that rotates a given target entity by a specified angular delta. It is typically used in scenarios where fence-like structures need to be reoriented dynamically. The component does not maintain internal state beyond the instance reference and delegates the actual rotation logic using either SetOrientation (if available) or Transform:SetRotation. After rotation, it fires the fencerotated event and spawns a localized particle effect (fence_rotator_fx) at the target's position for visual feedback.
Usage example
local inst = CreateEntity()
inst:AddComponent("fencerotator")
-- Rotate the target entity by the default fence angle
local target = TheWorld.entities["fence_01"]
inst.components.fencerotator:Rotate(target)
-- Rotate by a custom angle
inst.components.fencerotator:Rotate(target, math.rad(45))
Dependencies & tags
Components used: None
Tags: None identified
Properties
No public properties
Main functions
Rotate(target, delta)
- Description: Rotates the provided
targetentity's orientation bydeltaradians (or a default value fromTUNING.FENCE_DEFAULT_ROTATION). Then pushes thefencerotatedevent and spawns a rotation effect prefab. - Parameters:
target(entity instance ornil) – The entity to rotate. Ifnil, the function returns early.delta(number, optional) – The angular increment to apply, in radians. Defaults toTUNING.FENCE_DEFAULT_ROTATIONif omitted.
- Returns: Nothing.
- Error states: Returns immediately if
targetisnil. No error is thrown otherwise.
Events & listeners
- Listens to: None
- Pushes:
fencerotated– Fired after successful rotation of the target entity.
Data: None.