11 KiB
11 KiB
Airplane Minigame - Unity Setup Quick Reference
Scene Hierarchy Setup
1. Game Manager (Empty GameObject)
- Name:
AirplaneGameManager - Component:
AirplaneGameManagerscript - Configure:
- Person Queue: Assign PersonQueue GameObject
- Camera Manager: Assign AirplaneCameraManager GameObject
- Launch Controller: Assign AirplaneLaunchController GameObject
- Target Validator: Assign AirplaneTargetValidator GameObject
- Spawn Manager: Assign AirplaneSpawnManager GameObject
- All Targets: Assign all AirplaneTarget components in scene
2. Person Queue (Empty GameObject)
- Name:
PersonQueue - Component:
PersonQueuescript - Configure:
- People In Queue: Assign Person GameObjects in order (index 0 goes first)
- Shuffle Duration: 0.5f (time for people to shuffle when someone succeeds)
- Shuffle Distance: 2f (how far people move during shuffle)
3. People (Create one per participant)
- Name: Person's name (e.g., "Alice", "Bob", "Charlie")
- Component:
Personscript - Add Child: TextMeshPro - Text component for debug messages
- Configure Person Component:
- Person Name: Auto-fills from GameObject name
- Target Name: The target this person needs to hit (e.g., "TargetA")
- Debug Text: Assign the TextMeshPro child component
- Show Debug Logs: Optional, for debugging
- Position: Place in scene where you want people to stand
4. Camera Manager (Empty GameObject)
- Name:
AirplaneCameraManager - Component:
AirplaneCameraManagerscript - Configure:
- Intro Camera: Camera for game introduction
- Next Person Camera: Camera for person transitions
- Aiming Camera: Camera for aiming/launching
- Follow Camera: Camera that follows airplane (should have FollowTarget component)
- Blend Duration: 1.0f (camera transition time)
5. Launch Controller
- Name:
LaunchController - Component:
AirplaneLaunchControllerscript (inherits from DragLaunchController) - Configure:
- Airplane Prefab: Assign airplane prefab with AirplaneController
- Launch Point: Where airplane spawns
- Max Drag Distance: Maximum slingshot pull distance
- Launch Force Multiplier: Strength of launch
- Trajectory Preview: Assign TrajectoryPreview component
6. Trajectory Preview (Attach to Launch Controller or separate)
- Component:
TrajectoryPreviewscript - Component:
LineRenderer(auto-required) - Configure:
- Trajectory Points: 50
- Time Step: 0.1f
- Ground Level: Y position where trajectory stops
- Line Color: Yellow (or preferred color)
- Line Width: 0.1f
7. Target Validator (Empty GameObject)
- Name:
TargetValidator - Component:
AirplaneTargetValidatorscript - No configuration needed (targets are set at runtime)
8. Spawn Manager (Empty GameObject with child containers)
- Name:
SpawnManager - Component:
AirplaneSpawnManagerscript - Create Children:
SpawnedObjects(empty, for organization)GroundTiles(empty, for organization)
- Configure:
- Target Prefabs: Array of target key/prefab pairs
- Key: Must match Person's Target Name (e.g., "TargetA")
- Prefab: Target prefab with SpriteRenderer (for icon)
- Positive Object Prefabs: Array of collectible/good prefabs
- Negative Object Prefabs: Array of obstacle/bad prefabs
- Ground Tile Prefabs: Array of ground/platform prefabs
- Target Display UI: Assign TargetDisplayUI component
- Spawned Objects Parent: Assign SpawnedObjects child
- Ground Tiles Parent: Assign GroundTiles child
- Target Prefabs: Array of target key/prefab pairs
9. Target Display UI (Canvas child)
- Name:
TargetDisplayUI - Component:
TargetDisplayUIscript - Create Children:
TargetIcon(Image component) - Shows target spriteDistanceText(TextMeshProUGUI) - Shows distance remaining
- Configure:
- Target Icon: Assign TargetIcon Image component
- Distance Text: Assign DistanceText component
- Distance Format: "{0:F1}m" (or preferred format)
- Update Interval: 5 (frames between updates, 0=every frame)
- Position: Top corner or preferred UI location
10. Targets (Create multiple)
- Name: Target identifier (e.g., "TargetA", "TargetB")
- Component:
AirplaneTargetscript - Component:
Collider2Dwith "Is Trigger" enabled - Component:
SpriteRenderer(required for icon extraction) - Configure AirplaneTarget:
- Target Name: Unique identifier (e.g., "TargetA")
- Show Debug Logs: Optional
11. Airplane Prefab (Create as prefab)
- Component:
AirplaneControllerscript - Component:
Rigidbody2Dset to Kinematic mode (physics calculated manually) - Component:
Collider2Dwith "Is Trigger" enabled - Configure AirplaneController:
- Drag Coefficient: 0.01f
- Timeout Duration: 10f (auto-stop after this time)
- Show Debug Logs: Optional
Settings Configuration
Airplane Settings Asset
-
Open Settings Window:
Tools > Settings > Airplane Settings -
If not visible: Add
AirplaneSettingstoSettingsEditorWindow.cs(see Settings README) -
Configure:
Slingshot Settings:
- Max Drag Distance: 5f
- Launch Force Multiplier: 10f
- Min Launch Force: 2f
- Drag Speed: 5f
- Mass: 1f (projectile mass for trajectory calculations)
Flight Settings:
- Airplane Mass: 1f
- Max Flight Time: 10f
Spawn System (NEW):
- Dynamic Spawn Threshold: 10f (X position where spawning begins)
- Target Min Distance: 30f
- Target Max Distance: 50f
- Object Spawn Min Interval: 1f (seconds between object spawns)
- Object Spawn Max Interval: 3f
- Positive Negative Ratio: 0.5f (0=all negative, 1=all positive)
- Spawn Distance Ahead: 15f (how far ahead to spawn objects)
- Ground Spawn Interval: 5f (distance between ground tiles)
Timing:
- Intro Duration: 1f
- Person Intro Duration: 1f
- Evaluation Duration: 1f
Testing Checklist
Pre-Flight Check
- All Person components have Debug Text assigned
- PersonQueue has all people assigned in correct order
- Each Person has a unique Target Name assigned
- Matching Targets exist in scene with same names
- Camera Manager has all 4 cameras assigned
- Launch Controller has Airplane Prefab assigned
- AirplaneGameManager has all systems assigned
- Spawn Manager has target prefabs with matching keys
- Spawn Manager has positive/negative/ground prefabs assigned
- Target Display UI is created and assigned in Spawn Manager
- All target prefabs have SpriteRenderer components
Test Flow
- Start Game → Should blend to intro camera
- Introductions → Each person should display greeting message
- First Turn → Should blend to aiming camera
- Target Spawned → Target appears at configured distance
- UI Display → Target icon and distance shown
- Aiming → Drag to aim, trajectory preview should show
- Launch → Airplane should fly along predicted path
- Threshold Cross → Dynamic spawning begins
- Objects Spawn → Positive/negative objects appear ahead of plane
- Ground Spawns → Ground tiles appear at intervals
- Distance Updates → UI distance decreases as plane approaches
- Hit Target → Person celebrates, gets removed, queue shuffles
- Cleanup → All spawned objects destroyed
- Miss Target → Person shows disappointment, stays in queue
- Next Turn → New target spawned, repeat
- Game Over → When queue is empty
Common Issues
Trajectory doesn't match flight path
- Ensure airplane prefab has Rigidbody2D with correct mass
- Verify Slingshot Settings mass matches projectile
- Check gravity scale in Rigidbody2D settings
People don't show messages
- Assign TextMeshPro component to Debug Text field
- Check that text GameObject is a child of Person
Camera doesn't follow airplane
- Ensure Follow Camera has FollowTarget component
- Verify AirplaneCameraManager has Follow Camera assigned
Targets not detected
- Ensure both airplane and targets have Collider2D components
- Set "Is Trigger" on both colliders
- Check layer collision matrix in Project Settings
Launch doesn't work
- Verify Input Manager is properly configured
- Check Launch Controller is enabled
- Ensure Airplane Prefab is assigned
Target doesn't spawn
- Check Person's Target Name matches Spawn Manager key exactly
- Verify target prefab is assigned in Target Prefabs array
- Ensure target prefab has SpriteRenderer for icon
Wrong target icon displayed
- Verify target prefab has SpriteRenderer component
- Check SpriteRenderer has sprite assigned
- Try adding SpriteRenderer as direct child of root
Objects spawn too early/late
- Adjust Dynamic Spawn Threshold setting
- Check plane transform is passed to StartTracking
Positive/negative ratio not maintained
- Algorithm self-adjusts after first 5 spawns
- Verify Positive Negative Ratio is 0-1
- Spawn more objects to see ratio converge
Distance not updating
- Check Target Display UI is assigned in Spawn Manager
- Verify Update Interval is not too high
- Ensure UI is shown when tracking starts
Script References
Core Scripts
AirplaneGameManager.cs- Main game orchestratorPersonQueue.cs- Manages person queue and transitionsPerson.cs- Individual person data and reactionsAirplaneSpawnManager.cs- Dynamic spawning system (NEW)
Gameplay Scripts
AirplaneLaunchController.cs- Handles aiming and launchingAirplaneController.cs- Airplane flight behaviorAirplaneTarget.cs- Target collision detectionAirplaneTargetValidator.cs- Validates hits vs expected targets
UI Scripts
TargetDisplayUI.cs- Target distance display (NEW)
Camera Scripts
AirplaneCameraManager.cs- Camera state management
Common/Shared Scripts
DragLaunchController.cs- Base slingshot mechanicsCameraManager<T>.cs- Generic camera state systemTrajectoryPreview.cs- Visual trajectory prediction
Settings
IAirplaneSettings- Settings interfaceAirplaneSettings.cs- Settings implementation
Next Steps
- Visual Polish: Replace debug text with proper animations
- Audio: Add sound effects for launch, hit, miss, celebrations, spawns
- VFX: Add particle effects for launch, flight trail, hit impact, spawns
- UI: Add score display, turn counter, success rate, combo meter
- Targets: Add visual feedback when hit/missed
- People: Add character models and animations
- Airplane: Add proper airplane model with flight animations
- Spawned Objects: Add collision/scoring logic to positive/negative objects
- Ground Tiles: Add seamless scrolling ground system
- Power-ups: Add special spawned objects with unique effects
Additional Documentation
For detailed information about the spawn system:
- See
docs/airplane_spawn_system_guide.mdfor complete spawn system documentation - See
docs/person_integration_summary.mdfor person queue system - See
docs/airplane_implementation_summary.mdfor overall architecture