Game development is a multidisciplinary craft that blends programming, art, design, and storytelling. Whether you're building a 2D platformer in Godot, a physics-driven simulator in Unity, or a cinematic experience in Unreal Engine, the right prompt can save hours of debugging and spark creative solutions. This article collects 15 battle-tested prompts for three major engines — Unity (C#), Unreal Engine (Blueprints), and Godot (GDScript/C#) — to help you write cleaner code, optimize performance, and prototype faster.
Each prompt is copy-paste ready, includes an explanation of the task, and shows a concrete usage example. Let's dive in.
Prompts for Unity (C#)
1. Optimize Update() Calls with a Cooldown Timer
Task: Replace raw Update() calls with a coroutine-based cooldown to reduce CPU load.
Prompt:
Write a Unity C# script that toggles a boolean `isReady` every 2 seconds using a coroutine. The script should have a public method `TryAction()` that returns true only when `isReady` is true, and then sets `isReady` to false. Use `WaitForSeconds` for the cooldown.
Usage example:
using System.Collections;
using UnityEngine;
public class CooldownAction : MonoBehaviour
{
private bool isReady = true;
public bool TryAction()
{
if (isReady)
{
isReady = false;
StartCoroutine(CooldownRoutine());
return true;
}
return false;
}
private IEnumerator CooldownRoutine()
{
yield return new WaitForSeconds(2f);
isReady = true;
}
}
This pattern is widely used for attack cooldowns, NPC actions, and UI updates. According to Unity's official performance guide (docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity), coroutines are more efficient than checking Time.time in Update() for infrequent tasks.
2. Object Pooling for Bullet Spawning
Task: Create an object pool that reuses bullets instead of instantiating/destroying them.
Prompt:
Write a Unity C# object pool class that manages a queue of GameObjects. It should have a `Get()` method that returns an inactive object from the queue (or instantiates a new one if empty), and a `Return(GameObject obj)` method that deactivates and enqueues the object. The pool should be initialized with a given prefab and initial size.
Usage example:
using System.Collections.Generic;
using UnityEngine;
public class BulletPool : MonoBehaviour
{
[SerializeField] private GameObject bulletPrefab;
[SerializeField] private int initialSize = 10;
private Queue<GameObject> pool = new Queue<GameObject>();
void Start()
{
for (int i = 0; i < initialSize; i++)
{
GameObject obj = Instantiate(bulletPrefab);
obj.SetActive(false);
pool.Enqueue(obj);
}
}
public GameObject Get()
{
if (pool.Count == 0)
{
GameObject newObj = Instantiate(bulletPrefab);
return newObj;
}
GameObject obj = pool.Dequeue();
obj.SetActive(true);
return obj;
}
public void Return(GameObject obj)
{
obj.SetActive(false);
pool.Enqueue(obj);
}
}
Object pooling is essential for mobile games and bullet-hell titles. Unity's official documentation (docs.unity3d.com/Manual/InstantiatingPrefabs) recommends pooling for objects created and destroyed frequently.
3. State Machine for Player Controller
Task: Implement a finite state machine (FSM) for a player character with Idle, Walk, and Jump states.
Prompt:
Write a Unity C# state machine for a player character. Create an abstract base class `PlayerState` with methods `Enter()`, `Update()`, and `Exit()`. Then create three concrete states: `IdleState`, `WalkState`, `JumpState`. The state machine should transition between states using a `TransitionTo(PlayerState newState)` method. Use a `PlayerController` class that holds references to the states and updates the current state each frame.
Usage example:
public abstract class PlayerState
{
protected PlayerController controller;
public PlayerState(PlayerController controller) => this.controller = controller;
public abstract void Enter();
public abstract void Update();
public abstract void Exit();
}
public class IdleState : PlayerState
{
public IdleState(PlayerController c) : base(c) { }
public override void Enter() => Debug.Log("Enter Idle");
public override void Update() { /* check input for walk/jump */ }
public override void Exit() => Debug.Log("Exit Idle");
}
// Similar for WalkState and JumpState...
FSMs are the backbone of AI and player logic. Many commercial games (e.g., Hades, Celeste) use state machines for responsive controls.
4. Data Persistence with PlayerPrefs
Task: Save and load a player's high score and volume setting using PlayerPrefs.
Prompt:
Write a Unity C# script that saves an integer `highScore` and a float `volume` to PlayerPrefs when the game quits, and loads them on start. Use `PlayerPrefs.SetFloat()` and `PlayerPrefs.GetFloat()` with default values. Also include a public method `ResetData()` that clears all saved data.
Usage example:
using UnityEngine;
public class DataManager : MonoBehaviour
{
public int HighScore { get; private set; }
public float Volume { get; private set; }
void Awake()
{
HighScore = PlayerPrefs.GetInt("HighScore", 0);
Volume = PlayerPrefs.GetFloat("Volume", 0.5f);
}
public void SaveHighScore(int score)
{
HighScore = score;
PlayerPrefs.SetInt("HighScore", score);
PlayerPrefs.Save();
}
public void ResetData()
{
PlayerPrefs.DeleteAll();
HighScore = 0;
Volume = 0.5f;
}
void OnApplicationQuit()
{
PlayerPrefs.Save();
}
}
PlayerPrefs is suitable for small data (settings, progress). For complex game data, consider JSON serialization or a database.
5. Singleton Pattern for Game Manager
Task: Create a singleton GameManager that persists across scenes.
Prompt:
Write a Unity C# GameManager singleton. Use the classic pattern with a static instance property and `DontDestroyOnLoad()` in Awake(). Add a public integer `score` and a method `AddScore(int amount)`. Ensure that if another instance exists, it destroys itself.
Usage example:
using UnityEngine;
public class GameManager : MonoBehaviour
{
private static GameManager _instance;
public static GameManager Instance => _instance;
public int Score { get; private set; }
void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
DontDestroyOnLoad(gameObject);
}
public void AddScore(int amount)
{
Score += amount;
Debug.Log($"Score: {Score}");
}
}
Singletons are controversial but widely used for managers. Unity's official tutorials (learn.unity.com) often use this pattern for simplicity.
Prompts for Unreal Engine (Blueprints)
6. Custom Event with Parameters
Task: Create a Blueprint custom event that takes an integer damage value and applies it to a character's health.
Prompt:
In an Unreal Engine Blueprint, create a custom event called `TakeDamage` with an input integer parameter `DamageAmount`. Inside the event, subtract `DamageAmount` from the `Health` integer variable, then print the new health to the screen using `Print String`. If health drops below 0, call `DestroyActor`.
Usage example:
- Create a new Blueprint Class (Actor or Character)
- Add an integer variable Health (default 100)
- In Event Graph, right-click -> Add Custom Event -> Name: TakeDamage, add input DamageAmount (Integer)
- Connect nodes: Get Health -> Int - Int -> Set Health -> Branch (Health <= 0) -> True: DestroyActor, False: Print String ("Health: " + Health)
Custom events are the Blueprint equivalent of functions. They keep your graphs organized.
7. Line Trace for Shooting
Task: Implement a line trace from camera center to detect hit objects.
Prompt:
In a First Person Character Blueprint, create a `Shoot` function that performs a line trace from the camera's location forward by 10,000 units. On hit, print the hit actor's name using `Print String` and apply a damage event to the hit actor if it implements the damage interface.
Usage example:
- Get Player Camera Manager -> Get Camera Location and Camera Rotation
- Use Line Trace by Channel node from the camera location to (location + rotation * 10000)
- If Out Hit is valid -> Get Hit Actor -> Apply Damage (if valid)
Line traces are fundamental for hitscan weapons, interaction prompts, and AI vision checks. Epic's official documentation (docs.unrealengine.com/BlueprintAPI/Collision/LineTraceByChannel) provides detailed parameters.
8. Timed Door with Timeline
Task: Create a door that opens smoothly over 2 seconds when the player approaches, then closes after 3 seconds.
Prompt:
In a Blueprint Actor, create a Timeline that interpolates a float value from 0 to 1 over 2 seconds. Use this float to lerp the door's relative location from closed (0) to open (e.g., Y = 200). Use an `OnBeginOverlap` event to play the timeline forward, and a `Delay` node (3 seconds) to play it in reverse.
Usage example:
- Add a Box Collision component to the door
- On Event ActorBeginOverlap -> Play Timeline (Forward from start)
- After Timeline finishes -> Delay 3 seconds -> Play Timeline (Reverse from end)
Timelines are a powerful Blueprint feature for animations without coding.
9. AI Perception for Enemy Detection
Task: Set up an AIController that uses sight perception to detect the player.
Prompt:
Create an AIController Blueprint that uses the AI Perception component with a Sight sense. Configure the sight radius to 1000 units and lose sight radius to 1200 units. On perception update, if the stimulus is `Dominant`, set a Blackboard key `TargetActor` to the sensed actor. If stimulus is `Lost`, clear the key.
Usage example:
- Add AI Perception component to AIController
- Configure Sight config with detection by affiliation
- In Event OnPerceptionUpdated -> For Each Perceived Actor -> if Was Recently Sensed -> Set Blackboard key
AI Perception is the standard way to implement enemy awareness in Unreal. It's used in games like Fortnite and Gears of War.
10. Widget Animation with Bindings
Task: Create a health bar widget that smoothly changes color from green to red as health decreases.
Prompt:
In a User Widget Blueprint, create a progress bar that binds its percent to a character's health (e.g., Health / MaxHealth). Create a second binding for the bar's fill color: if health > 50%, return green; if between 25% and 50%, return yellow; if below 25%, return red. Use `Lerp (Linear Interpolation)` for smooth color transitions.
Usage example:
- Add Progress Bar to Widget
- In Details panel, bind Percent to function: GetHealthPercent
- Bind Fill Color to function that returns LinearColor based on thresholds
Widget bindings are reactive and reduce manual updates.
Prompts for Godot (GDScript / C#)
11. Signal-Based Communication
Task: Emit a signal from a player node when it collects a coin, and update the UI.
Prompt:
Write a GDScript for a `Coin` area that emits a `collected` signal when the player enters. In the player script, connect to the signal and increment a `coin_count` variable. In a HUD script, connect to the player's `coins_changed` signal to update the label.
Usage example:
# Coin.gd
extends Area2D
signal collected
func _on_body_entered(body):
if body.is_in_group("player"):
emit_signal("collected")
queue_free()
Signals are Godot's built-in observer pattern, replacing Unity's events. Godot's official documentation (docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html) explains them in detail.
12. Tilemap Procedural Generation
Task: Generate a random dungeon floor using a tilemap with floor and wall tiles.
Prompt:
Write a GDScript that creates a 2D array of 0s (floor) and 1s (wall), then uses a `TileMap` node to set cells based on the array. Use a simple random walk algorithm: start at center, move in random directions 100 steps, set floor tiles. Then surround all floor tiles with wall tiles.
Usage example:
extends TileMap
var floor_tile = Vector2i(0, 0) # atlas coordinates
var wall_tile = Vector2i(1, 0)
func _ready():
var grid = {}
var pos = Vector2i(0, 0)
for i in 100:
grid[pos] = 0
var dir = randi() % 4
match dir:
0: pos.x += 1
1: pos.x -= 1
2: pos.y += 1
3: pos.y -= 1
for cell in grid:
set_cell(cell, 0, floor_tile)
# Add wall border logic...
Procedural generation is used in games like Spelunky and No Man's Sky.
13. Animation Tree State Machine
Task: Create an AnimationTree with a state machine for idle/walk/run transitions.
Prompt:
In a Godot 2D character, set up an AnimationTree with a StateMachine. Create three animations: idle, walk, run. Use a float parameter `speed` to blend between walk and run (0-1). Use a boolean parameter `is_moving` to transition between idle and walking. Write a script that updates these parameters based on player input.
Usage example:
func _process(delta):
var input = Input.get_vector("left", "right", "up", "down")
var moving = input.length() > 0.1
$AnimationTree.set("parameters/is_moving", moving)
$AnimationTree.set("parameters/speed", input.length())
AnimationTree is Godot's advanced animation system, similar to Unreal's Blend Spaces.
14. JSON Save/Load System
Task: Save and load game data (health, position, inventory) to a JSON file.
Prompt:
Write a GDScript that uses `FileAccess` to save a dictionary containing player health, position (Vector2 as x/y), and an array of inventory item names to a file named "save.json". Loading reads the file and returns the dictionary. Use `JSON.stringify()` for saving and `JSON.parse_string()` for loading.
Usage example:
func save_game():
var data = {
"health": 100,
"position": {"x": global_position.x, "y": global_position.y},
"inventory": ["sword", "potion"]
}
var file = FileAccess.open("user://save.json", FileAccess.WRITE)
file.store_string(JSON.stringify(data))
file.close()
This is the standard approach for Godot save systems (docs.godotengine.org/en/stable/tutorials/io/saving_games.html).
15. Shader for Outline Effect
Task: Write a custom shader that adds a colored outline to a sprite.
Prompt:
Write a Godot shader (visual or code) that takes a texture and an outline color. Use a fragment shader that checks the alpha of neighboring pixels (4-directional offset). If the current pixel is transparent but any neighbor is opaque, output the outline color. Otherwise, output the texture color.
Usage example:
shader_type canvas_item;
uniform vec4 outline_color : source_color = vec4(1.0, 0.0, 0.0, 1.0);
uniform float outline_size : hint_range(0, 10) = 1.0;
void fragment() {
vec4 tex_color = texture(TEXTURE, UV);
float alpha = tex_color.a;
float outline_alpha = 0.0;
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
vec2 offset = vec2(float(x), float(y)) * outline_size * TEXTURE_PIXEL_SIZE;
float neighbor_alpha = texture(TEXTURE, UV + offset).a;
if (neighbor_alpha > 0.5)
outline_alpha = 1.0;
}
}
if (alpha < 0.5 && outline_alpha > 0.5)
COLOR = outline_color;
else
COLOR = tex_color;
}
Outline shaders are popular for highlighting interactable objects or player characters.
Conclusion
These 15 prompts cover the most common tasks in Unity, Unreal Engine, and Godot — from performance optimization and state machines to procedural generation and shaders. Copy them into your project, tweak the parameters, and you'll save hours of boilerplate coding.
Which engine do you use most? Try adapting the Unity object pool prompt for Godot or the Unreal AI perception for your next enemy — the principles are cross-engine. Bookmark this guide and come back when you hit a roadblock. Happy developing!
Comments