THE VR SCHOOL
  • Schools & Districts
    • License the academy
    • Free program for your students
    • Request a demo
  • Catalog
    • AI & Data
    • Cybersecurity & Web
    • Programming
    • Health Science
    • All Guilds
    • All courses
  • Families
  • Accreditation
  • Log In
  • Request a demo
  • Home
  • Courses

RLP Video Game Design B — Playtesting, Levels, Launch and the Capstone

Curriculum

  • 5 Sections
  • 23 Lessons
  • Lifetime
Expand all sectionsCollapse all sections
  • Unit 1: Digital Prototypes and Ethical Playtesting
    5
    • 1.1
      Prototypes: Paper, Digital and Hybrid
      50 mins
    • 1.2
      Build: A Greybox Prototype with Pickups, Hazards and a Win State
      50 mins
    • 1.3
      Running an Ethical Playtest
      55 mins
    • 1.4
      Bug Reports and the Iteration Log
      50 mins
    • 1.5
      Prototype v1 and Playtest Report
      50 mins
  • Unit 2: Level Design, Accessibility and Player Experience
    5
    • 2.1
      How Levels Teach: Pacing, Flow and Guidance
      50 mins
    • 2.2
      Build: A Tile-Based Level with Checkpoints and a Following Camera
      50 mins
    • 2.3
      Accessibility Audit: Designing for More Players
      55 mins
    • 2.4
      Build: Accessibility Options — Remapping, Game Speed and Readable Text
      50 mins
    • 2.5
      Level Map, Playtest and Accessible Revision
      50 mins
  • Unit 3: Balance, Monetization and Getting Games to Players
    5
    • 3.1
      Balance: Fairness, Difficulty and the Numbers Behind Fun
      50 mins
    • 3.2
      Build: A Tunable Health, Damage and Drop-Rate System
      50 mins
    • 3.3
      Monetization, Loot Boxes and Fair Design
      55 mins
    • 3.4
      Publishing and Marketing: Web Export, Ratings and the Store Page
      50 mins
    • 3.5
      Balance Chart and Launch Plan
      50 mins
  • Unit 4: Careers and the Capstone Playable Prototype
    5
    • 4.1
      Working in Games: Roles, Crunch, Unions and Contracts
      50 mins
    • 4.2
      Build: Menus, Pause and a Shippable Build
      50 mins
    • 4.3
      Milestone Self-Review: Scope, Schedule and SkillsUSA
      55 mins
    • 4.4
      Career Profile, Résumé and Mock Interview
      50 mins
    • 4.5
      Capstone: Playable Prototype, Showcase Pitch and Reflective Essay
      50 mins
  • Unit 5: Missouri Multimedia Supplement: Producing a Game Trailer
    3
    • 5.1
      Shooting the Trailer: Phone Filming Techniques and OBS Gameplay Capture
      50 mins
    • 5.2
      Editing the Trailer: Timeline Assembly, Clip Controls, Effects, Sound Sync and an Advanced Shot
      50 mins
    • 5.3
      Delivering the Trailer: Playback Testing, Codecs and Exports for Store, Social and Archive
      50 mins

Build: A Tunable Health, Damage and Drop-Rate System

Unit 3  ·  Technical Skills Lab  ·  Lesson 12 of 23

Build: A Tunable Health, Damage and Drop-Rate System

AME.D3.4RLP-GAMEB
Student tunes game sliders while testing enemy health, damage, and repeated item drops.
By the end of this lesson I can…

build a health and damage component and a random drop system with values exposed for tuning, and test the drop rate with a simulation of many trials.

Instruction

Balancing means changing numbers many times. The code should make that easy: every value a designer might tune should be visible in the Inspector, and the game should be testable faster than by playing for an hour. (Randomness follows the Godot documentation’s “Random number generation” page, CC BY 3.0.)

A health component. Instead of writing health code in every enemy and in the player, write it once as a node you can add to anything:

extends Node

signal health_changed(current: int, maximum: int)
signal died

@export_range(1, 1000) var max_health: int = 100
var current: int

func _ready() -> void:
	current = max_health

func take_damage(amount: int) -> void:
	current = clampi(current - amount, 0, max_health)
	health_changed.emit(current, max_health)
	if current == 0:
		died.emit()

@export_range(1, 1000) shows a slider in the Inspector limited to sensible values. clampi keeps health between 0 and the maximum. The component does not know what a health bar or a death animation is; it only emits signals, and anything can listen. A ProgressBar connects to health_changed and sets its max_value and value; the enemy connects to died and plays its defeat.

Random drops. A drop chance of 0.25 means each defeated enemy has a 25% chance to drop an item. randf() returns a random decimal from 0 to 1, so comparing it to the chance gives the right probability:

@export_range(0.0, 1.0, 0.01) var drop_chance: float = 0.25
@export var pity_limit: int = 8
var misses: int = 0

func roll_drop() -> bool:
	if misses >= pity_limit - 1 or randf() < drop_chance:
		misses = 0
		return true
	misses += 1
	return false

Why a pity rule? On average, a 25% chance gives one drop every 4 enemies. But averages hide unlucky streaks. The chance of no drop in 10 enemies in a row is 0.7510 ≈ 0.056, so about 1 player in 18 will defeat ten enemies with nothing to show for it, and that player may quit. A pity rule guarantees a drop after a run of misses: with pity_limit 8, no player ever goes more than 8 enemies without a drop. The average barely changes, but the worst case is capped. This is balance for how it feels, not only for what it averages.

Test with a simulation. You cannot playtest 1,000 drops by hand, but the computer can in a fraction of a second. Add a temporary test to a scene:

func _ready() -> void:
	var drops := 0
	var longest_streak := 0
	var streak := 0
	for _i in 1000:
		if roll_drop():
			drops += 1
			streak = 0
		else:
			streak += 1
			longest_streak = maxi(longest_streak, streak)
	print("Drops: ", drops, "  Longest dry streak: ", longest_streak)

Run it several times. Without the pity rule, expect about 250 drops per 1,000, and results between roughly 225 and 275 most of the time (the standard deviation is √(1000 × 0.25 × 0.75) ≈ 14). The longest dry streak will often be well above 10. With the pity rule, the drop count rises a little and the longest streak never exceeds 7 misses. Record both in your build log; this is balance evidence.

Separating data from code. Exported values mean designers tune in the Inspector without editing scripts. Professional teams go further and keep tables of values in spreadsheets or data files the game reads, so a designer can rebalance a hundred enemies without touching code.

📖 Read for this lesson

The reading opens over the lesson; close it to come back to exactly where you were. The checks below draw on it.

  • Drop Rates: Expected Values, a Health Walkthrough and a Filled Simulation LogSLS original; expected values computed for this course, run logs invented · about 2 min

    The values your simulation should produce, worked by hand for pity off and pity 8, a health-component walkthrough and a solo dice route if you cannot run Godot.

Vocabulary in context

  • component — A reusable node that adds one capability, such as health, to whatever it is attached to.
  • @export_range — An annotation that shows a variable in the Inspector as a slider limited to a range.
  • simulation test — Running a system many times automatically to measure its behavior, such as a drop rate.
  • pity rule — A guarantee of a reward after a set number of failures, which caps unlucky streaks.

Build: Health component, drop system and simulation

Question. Does the drop system produce the intended drop rate over many trials, and how does a pity rule change the worst-case experience?

Materials

  • Your game project in the Godot 4 desktop editor (4.3 or later)
  • Kenney UI pack (CC0) for a health bar, optional
  • A free spreadsheet program for recording simulation runs
  • Your balance chart draft
Safety.
  • Keep ergonomic habits and 20-20-20 breaks.
  • Remove or disable the simulation test code before sharing the build, and back up the project first.

Procedure

  1. Create the Health component script and add it as a child named Health to the player and to one enemy. Connect health_changed to a ProgressBar and died to a function that removes the enemy.
  2. Add a way to deal damage (for example, an Area2D hitbox or a key press that calls take_damage) and confirm the bar updates and the enemy is removed at 0.
  3. Add roll_drop() to the enemy with drop_chance 0.25 and pity_limit set very high (1000) to disable the pity rule. Add the simulation test and run it five times; record drops and longest dry streak.
  4. Set pity_limit to 8 and run the simulation five more times; record the results.
  5. Choose a drop chance and pity limit for your own game’s target experience, test them in play, and record the values and why you chose them.
  6. Remove or comment out the simulation test.

Data

RunPity off: drops / 1000Pity off: longest dry streakPity 8: drops / 1000Pity 8: longest dry streak
1
2
3
4
5

Analysis

  1. Were your pity-off drop counts within about 225-275? Explain why the results vary between runs even though the code is identical.
  2. How did the pity rule change the longest dry streak and the total drops? Why does the worst case matter to how the game feels?
  3. Why is a health component that only emits signals easier to reuse than health code that directly updates a specific health bar?

If you cannot do this build in person: Without Godot, run the simulation with dice: a roll of 1 on a four-sided die (or 1-3 on a d12) is a drop. Roll 100 times, tally drops and the longest dry streak, then repeat with a rule that forces a drop after 7 misses. Repeat the set of 100 over several sittings to reach 500 or 1,000 trials; rolling several dice at once and reading each die as one trial makes it faster.

Formative check

Work through these before moving on. They are not graded — they tell you whether the standard below has landed yet.

Fill in the blank

With a 25% drop chance, the average is one drop every enemies, and the chance of no drop in 10 enemies in a row is 0.75 to the power 10, about %.

+50 XP

Why does the health component emit health_changed instead of updating the health bar directly?

Signals decouple the component from whatever reacts to it, which is what makes it reusable.
Myth or Fact?

If a 1,000-trial simulation gives 262 drops at a 25% chance, the code must be wrong.

Random results vary. With a standard deviation of about 14, 262 is within one standard deviation of 250 and entirely expected.
Quick self-check

How confident are you that you can build tunable health and drop systems and test a drop rate by simulation?

Not yetVery confident

Practice

Work these on paper or in your notebook, then open Check your answer. Aim for all of Fluency and Application; try at least one Challenge.

Printable version: this unit’s practice workbook (PDF)

Fluency

Build speed and accuracy with the core skill.

  1. What does each do in the health component: @export_range(1, 1000), clampi(current – amount, 0, max_health), died.emit()?
    Check your answer
    Answer: @export_range shows max_health as an Inspector slider limited to 1-1000; clampi keeps health between 0 and the maximum; died.emit() announces the death so any listener can react.
    The component does not know about health bars or animations; it only emits signals.
  2. A drop chance is 0.2. On average, one drop every how many enemies? What does randf() < drop_chance do?
    Check your answer
    Answer: Every 5 enemies. randf() returns a random decimal from 0 to 1, so it is below 0.2 about 20% of the time, giving a drop with probability 0.2.
    1 ÷ 0.2 = 5.
  3. Define a pity rule and explain what it changes and what it barely changes.
    Check your answer
    Answer: A guarantee of a reward after a set number of failures. It caps the worst unlucky streak while barely changing the average.
    This is balance for how it feels, not only for what it averages.

Application

Use the skill in context. Show your reasoning.

  1. Health is 40 with max_health 100. What is current after take_damage(55)? Starting again from 40, what is it after take_damage(-80)?
    Check your answer
    Answer: 0 (and died is emitted); 100.
    40 − 55 = −15, clamped to 0. 40 − (−80) = 120, clamped to the maximum of 100.
  2. With a 20% drop chance and no pity rule, what is the probability of no drop in 10 enemies in a row? About 1 player in how many sees that streak?
    Check your answer
    Answer: About 0.107, roughly 11%: about 1 player in 9.
    0.810: 0.8² = 0.64, 0.8⁴ = 0.4096, 0.8⁸ ≈ 0.1678, × 0.64 ≈ 0.107. 1 ÷ 0.107 ≈ 9.3.
  3. Code reading: with pity_limit = 5, what is the longest possible dry streak? Explain using the line if misses >= pity_limit – 1 or randf() < drop_chance:.
    Check your answer
    Answer: 4 misses. After 4 misses in a row, misses is 4, which equals pity_limit − 1, so the next roll is forced to drop.
    With pity_limit 8 the lesson’s longest streak is 7 for the same reason.
  4. Find the bug. A student deletes misses = 0 from the drop branch. What happens after the first time the pity rule fires?
    Check your answer
    Answer: misses never resets, so it stays at or above pity_limit − 1 and every roll after that returns true: every enemy drops.
    Resetting the counter is what lets the pity rule fire only after a fresh run of misses. A simulation run would show it at once (drops near 1,000).
  5. A 1,000-trial simulation at a 20% chance gives 214 drops. The standard deviation is √(1000 × 0.2 × 0.8). Compute it and say whether 214 suggests a bug.
    Check your answer
    Answer: About 12.6. No: 214 is about one standard deviation above the expected 200, which is normal variation.
    1000 × 0.2 × 0.8 = 160; √160 ≈ 12.6. Expected drops = 1000 × 0.2 = 200; 214 − 200 = 14.

Challenge

Stretch problems. Expect to think before you write.

  1. Explain why exposing drop_chance and pity_limit with @export_range is better than typing numbers inside the function, and what professional teams do beyond that.
    Check your answer
    Answer: Designers can tune the values in the Inspector without editing scripts, within sensible limits, and test many settings quickly. Professional teams keep tables of values in spreadsheets or data files the game reads, so a designer can rebalance a hundred enemies without touching code.
    Separating data from code makes balancing, which means changing numbers many times, fast and safe.

Review

Keep earlier skills sharp.

  1. Review (Lesson 3.1): an enemy has 100 health and the weapon deals 25 per hit. How many hits are needed, and is 25 a breakpoint for 100 health?
    Check your answer
    Answer: 4 hits. Yes: 24 damage would need 5 hits (100 ÷ 24 ≈ 4.2), so 25 is where the count drops to 4.
    Breakpoints for 100 health include 13, 15, 17, 20 and 25.

Missouri CTE — Multimedia (034356) objectives addressed: MM.ANI.6, MM.WRS.6, MM.EMT.4, RST.9-10.3

Instructional focus: Technical skill: exported parameters, signals and simulation testing

Reading

Drop Rates: Expected Values, a Health Walkthrough and a Filled Simulation Log

SLS original; expected values computed for this course, run logs invented · SLS original

Why this reading. The lab has you run a drop simulation and record drops and longest dry streak, and it asks how a pity rule changes the result. To check your runs, you need to know what to expect. This sheet works the expected values out by hand, shows a health-component walkthrough with numbers, and gives you a dice route if you cannot run Godot. SLS original.

Health component: take_damage walkthrough (max_health 100)

Callcurrent beforecurrent afterSignal
take_damage(30)10070health_changed(70, 100)
take_damage(30)7040health_changed(40, 100)
take_damage(30)4010health_changed(10, 100)
take_damage(30)100 (clamped, not -20)health_changed(0, 100), then died

Expected simulation results

  • Pity off, chance 0.25: expected drops per 1,000 = 250; standard deviation = square root of (1,000 x 0.25 x 0.75) = 13.7. Most runs fall between about 222 and 278.
  • Chance of ten misses in a row = 0.75 to the power 10 = 0.0563, or 5.6%.
  • Longest dry streak with pity off: roughly ln(1,000 x 0.25) / ln(1 / 0.75) = 19.2 misses on average, so expect streaks in the teens or twenties.
  • Pity limit 8: the code forces a drop when misses reaches 7, so the longest streak is exactly 7. The average cycle length is 1 + 0.75 + 0.75 squared + … up to 0.75 to the power 7 = (1 minus 0.75 to the power 8) / 0.25 = 3.60 enemies per drop, so drops per 1,000 = 1,000 / 3.60 = 278. Expect about 278.

Read the trade: pity raises the drop count from 250 to about 278 (11% more) and cuts the worst streak from the twenties to 7. That is why designers say pity balances how the game feels.

A filled log (SLS original, invented runs)

RunPity off: dropsPity off: longest streakPity 8: dropsPity 8: longest streak
1244172797
2262212757
3251142817

Run 2 has 262 drops: 12 above 250, less than one standard deviation (14), so the code is fine. The pity-8 column never exceeds 7. If yours does, check whether misses resets to 0 on a drop.

Dice route

Roll a d4; a 1 is a drop (25%). For pity, force a drop after 7 misses. Ten sets of 50 rolls, done over a few sittings, give 500 trials with the same spread; rolling several d4 at once and reading each die as one trial makes it faster.

Up NextComplete & Continue →

Leave a Reply Cancel reply

Balance: Fairness, Difficulty and the Numbers Behind Fun
Prev
Monetization, Loot Boxes and Fair Design
Next

© 2026 The VR School | Career content by Wiley | Powered by Sejal Learning Systems.

Join free · Accreditation · Privacy Policy · Terms of Service

Modal title

Main Content