Menu
CoddyTech

Moving Platforms

Part of the Building Real Games section of Coddy's Unity journey. Lesson 50 of 60.

challenge icon

Challenge

Medium

Make the blue platform glide over the gap. Riding it comes next.

  1. In MovingPlatform, add [SerializeField] floats distance = 3f and speed = 1.5f, and public Vector3 delta;.
  2. In Update(), glide from the start to distance units along +x at speed, back again, and repeat.
  3. Set delta to the position after the move minus the position before.

Press Play: the platform glides out and back. Then Check.

Try it yourself

using UnityEngine;

public class MovingPlatform : MonoBehaviour
{
    // A later lesson fills this in: a platform that glides back and forth.
}

All lessons in Building Real Games

Practice on your own: Unity playground