Menu
CoddyTech

Recap: Launch Pad

Part of the Physics and Gameplay section of Coddy's Unity journey. Lesson 7 of 71.

This recap puts the chapter together: a velocity set in FixedUpdate(), an impulse that counts the mass, and a key read in Update() so no press is lost.

challenge icon

Challenge

Easy

Walk the player to the launch pad and launch it.

  1. In Update(), set a bool launchPressed on Input.GetKeyDown(KeyCode.Space).
  2. In FixedUpdate(), set rb.linearVelocity from the raw Horizontal axis times speed, keeping its y.
  3. When launchPressed is set, add Vector3.up * launch with ForceMode.Impulse only if x is less than 1 from pad.position.x, then clear it.

Press Play, walk onto the pad and press Space. Then Check.

Try it yourself

using UnityEngine;

public class Jumper : MonoBehaviour
{
    public float speed = 4f;
    public float launch = 16f;
    public Transform pad;
    private Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Physics and Gameplay

Practice on your own: Unity playground