Platform API¶
Move a ridable platform — an airship, boat, lift — from a script, with motion that stays in sync for everyone and keeps riders attached. Put a script on an object that has an SSPlatform set to Drive mode = Script, and move it with Platform.* from your FixedUpdate.
public class Elevator : NexusBehaviour
{
float _t;
public void FixedUpdate()
{
_t += Time.deltaTime;
float y = Mathf.PingPong(_t * 2f, 6f); // ride up and down between 0 and 6
Platform.MoveTo(transform.position.x, y, transform.position.z);
}
}
Moving the platform¶
| Call | What it does |
|---|---|
Platform.MoveTo(x, y, z) |
Move to the world position (x, y, z). |
Platform.Move(dx, dy, dz) |
Move by an offset from where it is now. |
Platform.SetVelocity(vx, vy, vz) |
Advance this physics step as if travelling at (vx, vy, vz) metres/second. Call every FixedUpdate for steady motion. |
That's the whole API — three ways to say "put the platform here." Rotation follows from your motion if the platform's Sync rotation is on; combine with the object's transform reads to steer.
Two rules¶
Move platforms only with Platform.*
A ridable platform carries players because it moves the right way under the hood. Moving it with Transform.position, Transform.Translate or Player.Teleport teleports it — it desyncs and throws standing players off. Always use Platform.MoveTo / Move / SetVelocity.
Call from FixedUpdate
Platform motion is physics motion, so drive it from FixedUpdate (the physics step), not Update. Platform.SetVelocity assumes a per-FixedUpdate call.
Where it runs¶
Platform motion is server-authoritative: your script runs on the server (the authority) and the movement replicates to every player — you don't wire anything up, and clients never fight the sync. Because it runs on the server, local-player and camera APIs return nothing inside a platform script (there's no single local player on the server) — read positions from the objects and players you're moving toward instead, or from networked state.
Keep each FixedUpdate light — it runs on the shared server, so heavy per-step work is capped for you.
Riding a platform (NPCs & objects)¶
The other side of a moving platform: make an NPC — or any networked object — ride it to a destination and step off, deciding when from your own script or a trigger. This is ordinary Unity‑AI / script logic; it's a generic capability (any object can ride, not just NPCs) and is separate from the AI NPC conversation layer.
Ride.Start(lift); // this object boards the platform — carried along, in sync for everyone
// … later, when the lift has arrived (your trigger / logic decides) …
Ride.Stop(); // drop off onto the ground here, then navigate on as normal
| Call | What it does |
|---|---|
Ride.Start(platform) |
This object rides platform (pass the platform GameObject) — carried with the deck and kept in sync for every player. A NavMeshAgent on the object pauses while it rides. |
Ride.Stop() |
Stop riding and drop back onto the ground where it is now, re‑enabling its NavMeshAgent so your script can navigate it off. Call this once the platform is docked / level with the floor. |
Movement is the ordinary navigation API
Ride.* only adds the ride and the step‑off — walking the NPC around a level is the normal NavMeshAgent navigation, and Ride.* doesn't replace it.
Pass the platform as an object
Ride.Start takes the platform GameObject (e.g. a cross‑script reference to it), not a name or an id.
Quick reference¶
| Group | Calls |
|---|---|
| Move (platform) | Platform.MoveTo(x,y,z) · Platform.Move(dx,dy,dz) · Platform.SetVelocity(vx,vy,vz) |
| Ride (rider) | Ride.Start(platform) · Ride.Stop() |
→ No scripting needed? A platform can also follow waypoints, a Tween path, or an Animator with no code.