跳转至

Module 4: Camera Manipulations and Multiple Views

Basic Camera Controls

Run Behavior

Text Only
1
2
3
4
N: Move camera by (x, y) values (from X/Y slider bars)
M: Move camera to (x, y) values (to Dye's location)
H: Zoom with respect to center (zoom factor slider)
J: Zoom with respect to Dye (zoom factor slider)

Scene Setup

Text Only
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
MainCamera:
    - Has CameraSupport

UI-Canvas:
    - X/Y/Zoom sliders (connected to UserControlLogic)

TheWorld:
    - Has UserControlLogic
    - Background: Z=1 (larger than hero and egg)
    - Hero and Egg components

Core Components

UserControlLogic - Central object for receiving/parsing user input - Connects to UI sliders and game objects - Transmits input to cause changes

Camera Support - CameraSupport: includes ClampToWorldBound() - CameraSupport_Manipulate: handles camera operations - MoveBy - MoveTo - Zoom (towards center) - ZoomTowards (point) - PushCameraByPos()

Lerp Implementation

Run Behavior

Text Only
1
2
3
4
Z: Trigger Lerp effect
    - Increases to double size
    - Gradually lerps back
    - Can compound if triggered repeatedly

TimedLerp Class

Text Only
1
2
3
- Performs lerp over fixed duration
- Rate measured in seconds
- Rate and Duration controlled via UI sliders

HeroControl Integration

Text Only
1
2
3
- BeginLerp() initiates lerp
- LerpIsActive() monitors lerp status
- SetLerpParms() optional for known values

Camera Manipulation

Enhanced Features

Text Only
1
2
3
4
- Position Lerp
- Size Lerp
- Automatic Update() checking
- Damping effects on movement

Shake Implementation

Text Only
1
2
3
4
- X key triggers camera shake
- Uses DampedHarmonic function
- Configurable cycles and duration
- Returns to original position after shake

Viewport and Hero Cam

Small Camera Setup

Text Only
1
2
3
- Projection: Orthographic
- Depth: > 0 (Main Camera at -1)
- Configurable viewport settings

CameraSupport Functions

Text Only
1
2
3
- SetViewportMinPos(x, y)
- SetViewportSize(w, h)
- Viewport manipulation controls

Scene Management

Scene Transition

Text Only
1
2
3
- L key loads new scene
- Maintains lerp and shake information
- Uses UnityEngine.SceneManagement

Persistence

Text Only
1
2
3
- GameState class implements Singleton Pattern
- DontDestroyOnLoad() functionality
- Level-specific organization in folders

Project Organization

Text Only
1
2
3
4
- Level-Specific folders
- Utility folder for camera components
- Separated level behaviors
- Centralized game management