Recap: Orbiting Moon
Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 28 of 67.
Challenge
MediumThe moon is already a child of the planet, 3 units out, and it gets no code: whatever happens to the planet happens to it. Write the planet's script:
- The planet spins around its y axis at
spindegrees per second, carrying the moon around it. - While Space is held, the planet grows evenly on every axis: its scale rises by
growper second, from 1 up to 2, and stops at 2.
Watch the moon while the planet grows. Press Play, then Check.
Try it yourself
using UnityEngine;
public class Planet : MonoBehaviour
{
public float spin = 40f;
public float grow = 0.5f;
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