Skip to main content
Version: 0.4.1

Launch pad

Step onto the pad and you're thrown up and forward. Put it on an object with a trigger collider and a TextMeshPro label, and point the object's forward axis where players should fly. Click the pad to go back to the world's spawn point. The label shows how fast you are moving. See Movement.

LaunchPad.cs
using StageTime.SDK;
using TMPro;
using UnityEngine;

/// <summary>
/// A launch pad: step onto its trigger collider and you're thrown up and along the pad's forward axis. Put it on an
/// object with a trigger collider. Click it to go back to the world's spawn point. The label shows your speed. Shows
/// <c>SetVelocity</c>, <c>GetVelocity</c> and <c>Respawn</c>.
/// </summary>
public class LaunchPad : StageTimeBehaviour
{
public TMP_Text label;
public float upSpeed = 12f;
public float forwardSpeed = 8f;

private int launches;

public override void OnPlayerTriggerEnter(StageTimePlayer player)
{
if (!player.isLocal) return;
player.SetVelocity(Vector3.up * upSpeed + transform.forward * forwardSpeed);
launches++;
}

public override void Interact()
{
Networking.LocalPlayer?.Respawn();
}

private void Update()
{
if (label == null) return;
StageTimePlayer me = Networking.LocalPlayer;
float speed = me != null ? me.GetVelocity().magnitude : 0f;
label.text = "Launches: " + launches + "\nSpeed: " + speed.ToString("0.0") + " m/s";
}
}