codeAPI Reference
s&box FuncMover: Moving and rotating objects
FuncMover Component API Reference
FuncMover is a Component that moves and rotates a GameObject with configurable linear and rotational movement patterns.
Type Signature
CSHARP
[Category("Gameplay"), Icon("open_with"), EditorHandle(Icon = "🚚"), Tint(EditorTint.Green)]
public sealed class FuncMover : Component
{
[Property] bool StartOn { get; set; } = true;
// Linear Move
[Property, FeatureEnabled("LinearMove", Icon = "🚀")]
public bool LinearMove { get; set; } = true;
[Property, Feature("LinearMove")]
public Vector3 LinearDistance { get; set; } = Vector3.Up;
[Property, Feature("LinearMove"), Sync(SyncFlags.FromHost)]
public float LinearSpeed { get; set; } = 10.0f;
[Property, Feature("LinearMove")]
public bool LinearLoop { get; set; } = true;
[Property, Feature("LinearMove"), ShowIf(nameof(LinearLoop), true)]
public float LinearPauseDuration { get; set; } = 0.0f;
// Rotate Move
[Property, FeatureEnabled("RotateMove", Icon = "🔄")]
public bool RotateMove { get; set; } = false;
[Property, Feature("RotateMove")]
public Angles RotationDirection { get; set; } = Angles.Zero;
[Property, Feature("RotateMove"), Sync(SyncFlags.FromHost)]
public float RotationSpeed { get; set; } = 10.0f;
[Property, ReadOnly, Sync(SyncFlags.FromHost), Group("Debug")]
bool IsOn { get; set; }
public void Toggle();
[Rpc.Host] public void TurnOn();
[Rpc.Host] public void TurnOff();
[Rpc.Host] public void SetLinearSpeed(float speed);
[Rpc.Host] public void SetRotationSpeed(float speed);
}Properties
Linear Movement
- bool LinearMove { get; set; } - Enable linear movement. Default is true.
- Vector3 LinearDistance { get; set; } - Distance to move from start position. Default is Vector3.Up.
- float LinearSpeed { get; set; } - Movement speed. Synced from host. Default is 10.0.
- bool LinearLoop { get; set; } - If true, loops back and forth. If false, moves to target and stops. Default is true.
- float LinearPauseDuration { get; set; } - Pause duration at each end when looping. Default is 0.0.
Rotational Movement
- bool RotateMove { get; set; } - Enable rotational movement. Default is false.
- Angles RotationDirection { get; set; } - Rotation direction per second. Default is Angles.Zero.
- float RotationSpeed { get; set; } - Rotation speed multiplier. Synced from host. Default is 10.0.
Control
- bool StartOn { get; set; } - Whether movement starts enabled. Default is true.
- bool IsOn { get; set; } - Current on/off state. Read-only, synced from host.
Methods
Toggle()
Toggles the mover on/off via RPC.TurnOn() / TurnOff()
Turns the mover on or off via RPC.SetLinearSpeed(float speed) / SetRotationSpeed(float speed)
Sets the movement or rotation speed via RPC.Usage
CSHARP
// Create a moving platform
var mover = go.AddComponent<FuncMover>();
mover.LinearMove = true;
mover.LinearDistance = Vector3.Up * 100;
mover.LinearSpeed = 50.0f;
mover.LinearLoop = true;
mover.LinearPauseDuration = 2.0f;Notes
- Runs in OnFixedUpdate for consistent physics timing
- LinearLoop with pause duration creates a back-and-forth movement with pauses
- Rotation is continuous when enabled
- All speed properties are synced from host
- DrawGizmos shows movement path in editor
Was this helpful?