Recap: Elevator
Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 11 of 67.
Challenge
EasyWrite the elevator's script from scratch:
- Two fields,
speedandtop, that the Inspector sets (it says 2 and 5) and no other script can change. - The elevator rises at
speedunits per second until its y reachestop, then stays there.
Press Play to watch it, then Check.
Try it yourself
using UnityEngine;
public class Lift : MonoBehaviour
{
// speed and top: private, set in the Inspector
void Update()
{
}
}
All lessons in Unity Scripting Basics
1Your First Script
Hello, UnityPlace the CubeMove Every FrameTurn Every SecondSteer with the KeysRecap: Drive the Cube4Vectors
Adding VectorsDirectionsLocal and World SpaceDiagonal SpeedDistance Between ThingsVector3 Is a StructRecap: Drone Pilot7Project: Catch the Star
The CatcherA Falling Star5Transforms and Hierarchy
Parents and ChildrenScaleLook At ThingsMove Toward a PointRecap: Orbiting Moon