Recap: Drive the Cube
Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 6 of 67.
Challenge
EasyPut the chapter together in one script:
- When the game starts, place the cube on the ground at x = -3 and z = 0 (it is 1 unit tall).
- While the right arrow is held, it drives right along x at
speedunits per second. - While Space is held, it spins around its y axis at
spindegrees per second.
Press Play to drive it, then Check.
Try it yourself
using UnityEngine;
public class Driver : MonoBehaviour
{
public float speed = 3f;
public float spin = 180f;
void Start()
{
}
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