Movement Park
A playground for player movement: a speed track, a super-jump pad up to a high platform, a moon-gravity zone with floating platforms behind an arch, a freeze pad, a reset button and a panel with sliders for your own walk speed, jump and gravity.
Get it from the StageTime-Worlds-Examples repository: copy the Worlds/MovementPark folder into a Unity
project that has the StageTime World SDK, and open its scene.
Movement only changes for the local player, so nothing here is synced: every player runs these scripts for themselves. StageTime puts everything back to normal when a player leaves the world.
Zones
A trigger collider with a MovementZone applies its settings while the local player is inside. The speed track, the
jump pad (jump while standing on it) and the moon zone are all zones with different values.
using StageTime.SDK;
using UnityEngine;
/// <summary>
/// An area that changes how the local player moves while they are inside it: a running track, a moon-gravity dome, a
/// trampoline floor. Needs a trigger collider on the same GameObject. Leaving the area puts StageTime's defaults back
/// (StageTime also does that when the player leaves the world). Keep zones apart: leaving one resets everything.
/// </summary>
public class MovementZone : StageTimeBehaviour
{
[Tooltip("Walking speed in m/s (StageTime's default is 3).")]
public float walkSpeed = 3f;
[Tooltip("Jump impulse in m/s (StageTime's default is about 5.4; 0 = no jumping).")]
public float jumpImpulse = 5.42f;
[Tooltip("Gravity strength: 1 = normal, 0.2 = the moon.")]
public float gravityStrength = 1f;
public override void OnPlayerTriggerEnter(StageTimePlayer player)
{
if (!player.isLocal) return;
player.SetWalkSpeed(walkSpeed);
player.SetJumpImpulse(jumpImpulse);
player.SetGravityStrength(gravityStrength);
}
public override void OnPlayerTriggerExit(StageTimePlayer player)
{
if (player.isLocal) player.ResetMovement();
}
}
The panel and the reset button
using StageTime.SDK;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// A control panel for your own movement: sliders for walk speed, jump and gravity, and a Reset button. Each player's
/// panel changes only their own movement, so nothing is synced; the sliders show the local player's current values.
/// </summary>
public class MovementPanel : StageTimeBehaviour
{
public Slider walkSlider;
public Slider jumpSlider;
public Slider gravitySlider;
public TMP_Text readout;
private void Start()
{
Show();
}
/// <summary>Any slider → On Value Changed.</summary>
public void OnSliders()
{
StageTimePlayer me = Networking.LocalPlayer;
me.SetWalkSpeed(walkSlider.value);
me.SetJumpImpulse(jumpSlider.value);
me.SetGravityStrength(gravitySlider.value);
Show();
}
/// <summary>Button: StageTime's defaults.</summary>
public void ResetAll()
{
Networking.LocalPlayer.ResetMovement();
Show();
}
private void Update()
{
// Zones and pads change the values too: keep the panel in step (cheap: three reads).
if (Time.frameCount % 15 == 0) Show();
}
private void Show()
{
StageTimePlayer me = Networking.LocalPlayer;
if (me == null) return;
float walk = me.GetWalkSpeed(), jump = me.GetJumpImpulse(), gravity = me.GetGravityStrength();
walkSlider.SetValueWithoutNotify(walk);
jumpSlider.SetValueWithoutNotify(jump);
gravitySlider.SetValueWithoutNotify(gravity);
if (readout != null)
readout.text = "Walk " + walk.ToString("0.0") + " m/s\nJump " + jump.ToString("0.0") + " m/s\nGravity x" + gravity.ToString("0.00");
}
}
using StageTime.SDK;
using UnityEngine;
/// <summary>
/// A big button that puts your own movement back to StageTime's defaults (walk speed, jump, gravity). Click it (or
/// press it in VR); the cap dips while pressed.
/// </summary>
public class ResetButton : StageTimeBehaviour
{
[Tooltip("The part that moves down when pressed.")]
public Transform cap;
public AudioSource clickAudio;
private Vector3 upPosition;
private float releaseAt = -1f;
private void Start()
{
upPosition = cap.localPosition;
}
public override void Interact()
{
Networking.LocalPlayer.ResetMovement();
cap.localPosition = upPosition + Vector3.down * 0.018f;
releaseAt = Time.time + 0.2f;
if (clickAudio != null) clickAudio.Play();
}
private void Update()
{
if (releaseAt < 0f || Time.time < releaseAt) return;
releaseAt = -1f;
cap.localPosition = upPosition;
}
}
The freeze pad
using StageTime.SDK;
using TMPro;
using UnityEngine;
/// <summary>
/// A stasis pad: stepping on it holds the local player in place for a few seconds (they can still look around), with a
/// countdown, then lets them go. Needs a trigger collider on the same GameObject.
/// </summary>
public class FreezePad : StageTimeBehaviour
{
[Tooltip("Seconds the player is held.")]
public float holdSeconds = 3f;
public TMP_Text countdown;
[Tooltip("Shown while someone is held (a glow or a ring).")]
public GameObject activeEffect;
private float releaseAt = -1f;
public override void OnPlayerTriggerEnter(StageTimePlayer player)
{
if (!player.isLocal || releaseAt >= 0f) return;
player.Immobilize(true);
releaseAt = Time.time + holdSeconds;
if (activeEffect != null) activeEffect.SetActive(true);
}
private void Update()
{
if (releaseAt < 0f) return;
float left = releaseAt - Time.time;
if (countdown != null) countdown.text = left > 0f ? Mathf.CeilToInt(left).ToString() : "";
if (left > 0f) return;
releaseAt = -1f;
Networking.LocalPlayer.Immobilize(false);
if (activeEffect != null) activeEffect.SetActive(false);
}
}