Recall & Review
beginner
What is a state machine in AI behavior?
A state machine is a way to organize AI behavior by defining different states and rules to switch between them. It helps AI decide what to do next based on its current situation.
Click to reveal answer
beginner
Name three common states in an AI enemy's state machine.
Common states include: Idle (waiting), Patrol (moving around), and Attack (engaging the player).
Click to reveal answer
intermediate
How does a state machine improve AI behavior in games?
It makes AI predictable and organized, so the AI can react properly to different situations by switching states smoothly.
Click to reveal answer
intermediate
In Unity, what component or script structure is commonly used to implement state machines for AI?
Developers often use C# scripts with enums or classes to represent states and switch logic inside the Update() method or coroutines.
Click to reveal answer
beginner
What triggers a transition between states in a state machine?
Transitions happen when certain conditions or events occur, like spotting the player, losing sight, or reaching a destination.
Click to reveal answer
What does a state machine primarily help an AI do?
✗ Incorrect
A state machine organizes AI behaviors into states and controls switching between them.
Which of these is NOT a typical AI state?
✗ Incorrect
Sleep is usually not a common AI state in games; Idle, Patrol, and Attack are typical.
In Unity, where is state switching logic usually placed?
✗ Incorrect
Update() runs every frame, making it ideal for checking conditions and switching states.
What triggers a state transition in an AI state machine?
✗ Incorrect
Transitions happen when specific conditions or events occur, such as spotting the player.
Why is using a state machine better than writing all AI behavior in one big script?
✗ Incorrect
State machines organize behavior into clear states, making code easier to read and maintain.
Explain how a state machine controls AI behavior in a game.
Think about how AI decides what to do next.
You got /4 concepts.
Describe how you would implement a simple AI state machine in Unity using C#.
Focus on how the code checks and changes states.
You got /4 concepts.