Introduction
Game development is a complex, multi-disciplinary craft. Whether you're a solo indie dev or part of a studio, you constantly face repetitive tasks: debugging, optimizing shaders, generating UI code, or prototyping mechanics. AI assistants can cut this time in half—if you know the right prompts. This collection brings 18 battle-tested prompts for Unity (C#), Unreal Engine (Blueprints), and Godot (GDScript). Each prompt is a complete, copy-paste ready instruction with a real usage example and code snippet. No fluff, no theory—just practical prompts that work in 2026.
Prompts for Unity (C#)
1. Generate a MonoBehaviour class
Prompt: "Write a C# script for Unity that inherits from MonoBehaviour. The script should [describe behavior, e.g., 'move an object forward at speed 5 when Space is pressed']. Use Start() for initialization and Update() for frame-by-frame logic. Include [SerializeField] for editable variables."
Example: To create a simple player movement script:
using UnityEngine;
public class PlayerMover : MonoBehaviour
{
[SerializeField] private float speed = 5f;
void Update()
{
if (Input.GetKey(KeyCode.Space))
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
}
}
Why it works: The prompt explicitly asks for [SerializeField], which makes variables tweakable in the Inspector—essential for quick iteration. Always include the method names (Start, Update) to avoid generic code.
2. Debug a NullReferenceException
Prompt: "I have a Unity C# script that throws NullReferenceException. Here's the code: [paste code]. The error occurs in [method name]. Find the most likely null variable and suggest a fix. Add a null check and log a warning."
Example: For a script where target is null:
if (target == null)
{
Debug.LogWarning("Target not assigned in " + gameObject.name);
return;
}
Why it works: The prompt narrows down the error context. According to Unity's official debugging guide (docs.unity3d.com/Manual/Debugging.html), logging with object context helps trace the specific GameObject.
3. Optimize Update() with caching
Prompt: "Refactor this Unity C# script to cache component references in Start() instead of calling GetComponent in Update(). Show both before and after versions."
Example:
Before:
void Update()
{
GetComponent<Rigidbody>().AddForce(Vector3.up);
}
After:
private Rigidbody rb;
void Start() { rb = GetComponent<Rigidbody>(); }
void Update() { rb.AddForce(Vector3.up); }
Why it works: Caching reduces GC pressure. Unity's performance best practices (learn.unity.com/tutorial/optimizing-scripts) recommend this pattern.
4. Generate a simple state machine
Prompt: "Write a C# state machine for Unity using an enum for states (Idle, Walk, Run) and a Dictionary
Example:
public enum State { Idle, Walk, Run }
private Dictionary<State, Action> stateActions;
private State currentState;
void Start()
{
stateActions = new Dictionary<State, Action>
{
{ State.Idle, () => Debug.Log("Idling") },
{ State.Walk, () => Debug.Log("Walking") }
};
SetState(State.Idle);
}
public void SetState(State newState)
{
currentState = newState;
stateActions[currentState]?.Invoke();
}
Why it works: The Dictionary pattern is lightweight and avoids long switch statements. Useful for AI behavior or animation states.
5. Write a coroutine for timed events
Prompt: "Create a Unity coroutine that waits for 2 seconds, then spawns a prefab at a random position within a circle radius 5. Use WaitForSeconds and Instantiate."
Example:
IEnumerator SpawnAfterDelay(GameObject prefab)
{
yield return new WaitForSeconds(2f);
Vector3 randomPos = Random.insideUnitCircle * 5;
Instantiate(prefab, randomPos, Quaternion.identity);
}
Why it works: Coroutines are standard for delays. The prompt specifies WaitForSeconds to avoid confusion with WaitForSecondsRealtime.
6. Create a simple object pool
Prompt: "Implement a generic ObjectPool class in Unity C#. It should have a Queue of GameObjects, a method Get() that returns an inactive object or instantiates a new one, and a method Return() that deactivates the object. Use [SerializeField] for the prefab."
Example:
public class ObjectPool : MonoBehaviour
{
[SerializeField] private GameObject prefab;
private Queue<GameObject> pool = new Queue<GameObject>();
public GameObject Get()
{
if (pool.Count > 0)
{
var obj = pool.Dequeue();
obj.SetActive(true);
return obj;
}
return Instantiate(prefab);
}
public void Return(GameObject obj)
{
obj.SetActive(false);
pool.Enqueue(obj);
}
}
Why it works: Object pooling avoids instantiation/destruction overhead. Unity's DOTS documentation (docs.unity3d.com/Packages/com.unity.entities@1.0/manual/object-pooling.html) recommends similar patterns for performance.
Prompts for Unreal Engine (Blueprints)
7. Create a Blueprint interface
Prompt: "Create a Blueprint Interface in Unreal Engine with one function called 'Interact'. The function takes an AActor* as Instigator and returns nothing. Explain how to implement it in a Blueprint class."
Example: Create a Blueprint Interface named BPI_Interactable. In any Actor Blueprint, implement the event Interact and add logic (e.g., open a door).
Why it works: Interfaces decouple logic—essential for modular game systems. Unreal's official documentation (docs.unrealengine.com/5.4/en-US/blueprint-interfaces) explains the process.
8. Debug a Blueprint execution order
Prompt: "In Unreal Engine, I have a Blueprint where two events fire in wrong order. Add Print String nodes with timestamps before and after each event. Also, add a Delay node to force order."
Example: Place Print String with Get World Elapsed Time before and after each event. Then connect a 0.1s Delay between them.
Why it works: Print String is the simplest debug tool. The prompt also teaches a common fix—Delay to control tick order.
9. Generate a simple AI patrol behavior
Prompt: "Create a Blueprint for an AI character that patrols between two points (waypoints). Use a Behavior Tree with a Sequence: MoveTo first waypoint, Wait 2 seconds, MoveTo second waypoint, Wait 2 seconds, loop. Use a Blackboard with Vector variables."
Example: Set up Blackboard keys Waypoint1 and Waypoint2. In Behavior Tree, use MoveTo tasks and Wait tasks.
Why it works: Behavior Trees are the standard for AI in Unreal. The prompt provides a minimal but complete example.
10. Optimize heavy Blueprint loops
Prompt: "I have a Blueprint that loops over 1000 actors every tick. Suggest how to refactor it: (1) use a timer instead of tick, (2) use a Foreach loop with a Break condition, (3) move logic to C++. Provide a code example for each."
Example: In Blueprint, use Set Timer by Event with a 0.1s interval instead of Event Tick.
Why it works: Timers reduce per-frame cost. Unreal's performance guidelines (docs.unrealengine.com/5.4/en-US/optimizing-blueprints) warn against tick-based loops.
11. Create a simple HUD widget
Prompt: "Build a UMG widget Blueprint that shows player health as a progress bar and text. Bind the health variable from a PlayerState. Use Event Construct to initialize."
Example: In Widget Blueprint, add ProgressBar and TextBlock. Bind Text to Get Player State > Health.
Why it works: UMG binding updates automatically. The prompt avoids manual updates.
12. Implement a simple line trace
Prompt: "Create a Blueprint that performs a Line Trace by Channel from camera location forward. If it hits an actor, apply damage. Use Branch to check hit."
Example: Use Line Trace by Channel, output Out Hit, branch on bBlockingHit, then Apply Damage.
Why it works: Line traces are fundamental for shooting, interaction, and visibility checks.
Prompts for Godot (GDScript)
13. Generate a simple player controller
Prompt: "Write a GDScript for Godot 4 that makes a CharacterBody2D move left/right with A/D keys and jump with Space. Use Input.get_axis() and move_and_slide(). Include jump velocity and gravity."
Example:
extends CharacterBody2D
@export var speed = 300
@export var jump_velocity = -400
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = jump_velocity
var direction = Input.get_axis("ui_left", "ui_right")
velocity.x = direction * speed
move_and_slide()
Why it works: Uses built-in actions for flexibility. The prompt references Godot 4's physics system.
14. Debug a signal connection
Prompt: "My Godot signal isn't firing. Add a print() inside the signal emitter and in the connected method. Also check if the signal is connected using is_connected(). For example, for a button pressed signal."
Example:
print("Emitting signal")
signal_name.emit()
print("Is connected? ", signal_name.is_connected(callable))
Why it works: Simple prints isolate the issue. The official Godot debugging guide (docs.godotengine.org/en/stable/tutorials/scripting/debug/index.html) recommends this approach.
15. Create a simple object pool
Prompt: "Write a GDScript object pool for Godot 4. It uses a PackedScene and an Array. Method get_object() returns an instance, and return_object(obj) hides it. Use preload() for the scene."
Example:
var pool = []
@onready var scene = preload("res://Bullet.tscn")
func get_object() -> Node:
if pool.size() > 0:
var obj = pool.pop_back()
obj.show()
return obj
return scene.instantiate()
func return_object(obj):
obj.hide()
pool.append(obj)
Why it works: Similar to Unity's pool but idiomatic GDScript.
16. Optimize _process()
Prompt: "Refactor this Godot script to move heavy logic out of _process() into a Timer. Show before and after. Example: updating a label every frame vs every 0.5 seconds."
Before:
func _process(delta):
$Label.text = str(randi())
After:
func _ready():
$Timer.wait_time = 0.5
$Timer.timeout.connect(update_label)
func update_label():
$Label.text = str(randi())
Why it works: Timers reduce CPU load. Godot's optimization docs (docs.godotengine.org/en/stable/tutorials/optimization) emphasize this.
17. Write a simple state machine
Prompt: "Create a GDScript state machine using an enum and match statement. States: Idle, Walk, Attack. Each state prints its name. Use a function set_state(new_state)."
Example:
enum State { IDLE, WALK, ATTACK }
var current_state = State.IDLE
func set_state(new_state):
current_state = new_state
match current_state:
State.IDLE:
print("Idle")
State.WALK:
print("Walking")
State.ATTACK:
print("Attacking")
Why it works: Match is clean and fast. The pattern is easy to extend.
18. Create a simple save system
Prompt: "Write a GDScript script that saves a dictionary (containing player position and score) to a JSON file using FileAccess. Load it back. Use ConfigFile for simplicity."
Example:
func save_game(data: Dictionary):
var file = FileAccess.open("user://save.json", FileAccess.WRITE)
file.store_string(JSON.stringify(data))
func load_game() -> Dictionary:
var file = FileAccess.open("user://save.json", FileAccess.READ)
if file:
return JSON.parse_string(file.get_as_text())
return {}
Why it works: JSON is human-readable. Godot's FileAccess API is the standard for file I/O.
Conclusion
These 18 prompts cover the most common GameDev tasks across Unity, Unreal, and Godot. They are designed to be copy-pasted and adapted to your specific project. Remember that AI is a tool—always review generated code for edge cases and performance. Start with the prompt that matches your current pain point, and tweak the wording to fit your engine version. For example, replace 'Unity 6' with 'Unity 2022.3' if you're on LTS. The best prompts are the ones you use daily. Bookmark this page, and next time you hit a repetitive task, let the AI handle the boilerplate while you focus on design.
Comments