Module 1: Introduction to Game Development
Module 2: Unity Interface and Basics
Module 3: Introduction to C# Programming for Unity
Module 4: Physics and Movement
Module 5: 2D Game Development
Module 6: 3D Game Development
Module 7: User Interfaces and Game Mechanics
Module 8: Animation and Visual Effects
Module 9: Sound Design and Implementation
Module 10: Building and Deploying Your Game
Module 11: Advanced Topics and Next Steps

3.4 Making the Cube Move

Let’s make the cube move forward continuously.

Step 1: Modify the Script
Open the MoveCube script and update the Update() method:

void Update() {
    transform.Translate(Vector3.forward * Time.deltaTime * 5);
}

Explanation:

  • transform.Translate: Moves the object.
  • Vector3.forward: Moves the object forward on the Z-axis.
  • Time.deltaTime: Ensures smooth movement regardless of frame rate.
  • 5: The speed of movement.

Step 2: Test It

  1. Save the script (Ctrl+S or Cmd+S).
  2. Press Play in Unity and watch the cube move forward.