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

6.4 Camera Management

The camera plays a critical role in determining how players view and interact with the game world.

Step 1: First-Person Camera

  • Attach a camera to the player object at head height.
  • Write a script to rotate the camera based on mouse input:
public float mouseSensitivity = 100f;
private float xRotation = 0f;

void Update() {
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    playerBody.Rotate(Vector3.up * mouseX);
}

Step 2: Third-Person Camera

  • Position the camera behind the player.
  • Use a script to make the camera follow the player smoothly:
public Transform player;
public Vector3 offset;

void LateUpdate() {
    transform.position = player.position + offset;
    transform.LookAt(player);
}

Step 3: Cinematic Camera

  • Use Unity’s Cinemachine package for advanced camera behaviors.
  • Create cinematic shots, such as cutscenes or dynamic zooms.

Activity: Implement and switch between a first-person and third-person camera system.


Summary of Module 6

By the end of this module, you will:

  • Be able to create immersive 3D environments using terrain, lighting, and skyboxes.
  • Understand the principles of level design and asset placement.
  • Build a 3D character controller with custom movement and animations.
  • Implement different camera perspectives for a more dynamic player experience.

With these skills, you’ll be prepared to create stunning and functional 3D games!