You need a message to appear in the Unity Console that reads "Player has spawned". Which line of code produces that output?
Debugging Problem Solving
Question · Easy
A script throws a NullReferenceException on the line rb.AddForce(Vector3.up); where rb is declared as private Rigidbody rb;. What is the most likely cause?
Question · Medium
Which Unity API method retrieves a component, such as an Audio Source, attached to the same GameObject as the script?
Tech Exam Prep Podcast
Listen on Spotify
Podcast
You want to print the current value of an integer score variable along with descriptive text, like "Score: 50". Which statement is correct?
A teammate needs to move a Transform upward every frame in a way that is independent of frame rate. Which API expression accomplishes this inside Update()?
The Console shows the error "object reference not set to an instance of an object" when calling target.GetComponent<Renderer>(). Which object is null?
You need to destroy a GameObject named enemy two seconds after a collision. Which call schedules that?
A debug message printed "Health is now 0" and was followed by code that ended the game. Which statement most likely generated that log line?
Which Console message type should you use to flag a non-fatal issue, such as a missing optional reference, that you still want highlighted in yellow?
A task requires detecting whether the player is currently holding down the spacebar each frame. Which Input method is appropriate?
You must spawn a prefab named bulletPrefab at the player's position with no rotation. Which Instantiate call is correct?
Given a task to find the distance between two Vector3 positions a and b, which API call returns that distance?
Double-clicking a red error entry in the Unity Console most directly helps a programmer do what?
A script needs to know whether the left mouse button was clicked this frame. Which call returns true only on the frame of the click?
You are told a value should never be negative, and the Console prints "Assertion failed" when it is. Which method most likely produced that?
Question · Hard
A task requires reading horizontal movement from the arrow keys or A/D keys as a value between -1 and 1. Which call is the standard approach?
The Console reports "NullReferenceException" pointing at player.transform.position when player is a public GameObject left unassigned in the Inspector. What is the fix?
Which API property would you use inside Update() to scale a rotation so the object turns at a consistent degrees-per-second regardless of frame rate?
A log line reads "Collected coin #3". The code uses a counter named coinCount. Which statement produced it?
When a NullReferenceException occurs, what does the Console stack trace most usefully tell the programmer?
You need to apply an upward force to a Rigidbody for a jump. Which API call does this?
A specific task needs the magnitude (length) of a Vector3 named velocity. Which expression returns it?
A script logs "Spawned 5 enemies" but should log the actual count stored in enemyCount. The current line is Debug.Log("Spawned enemyCount enemies");. What change is needed?
Which Debug method draws a temporary line in the Scene view to visualize a direction, such as a raycast, during play mode?
A method must return the GameObject in the scene tagged "Player". Which API call does this?
Which declaration correctly creates a private floating-point variable named speed initialized to 5.0 in C#?
Code Creation Control
You want a private variable to remain private in code but still be editable in the Inspector. Which attribute should you add above it?
Which collection type should you choose when you need an ordered group of items that can grow and shrink at runtime?
Given the keywords public, void, and Jump, which is a valid C# method (function) declaration with no parameters?
Which method signature declares a function that takes an int parameter named amount and returns an int?
Inside Update(), which input listener fires an action exactly once when the player first presses the Jump key (spacebar)?
Which statement correctly adds the string "Sword" to a List<string> named inventory?
Which data structure stores unique keys mapped to values, such as a player name mapped to a high score?
Which keyword, when applied to a variable, makes its value shared across all instances of a class rather than stored per object?
You need to declare an integer array that holds exactly three high scores. Which declaration is valid?
Which variable type is most appropriate to track whether a door is currently open?
To read smooth left/right movement and store it, which line correctly captures the horizontal input as a float?
Which declaration creates a constant that cannot be changed after it is set, such as a maximum health of 100?
A function must accept a player's name and return a greeting string. Which declaration fits?
Which loop correctly iterates over every element in a List<string> named names to print each one?
Which access modifier makes a variable reachable from any other script in the project?
Which expression correctly reads the number of elements currently stored in a List<int> named enemies?
A touch-based input listener should detect when a finger first touches the screen. Which check works on mobile?
Which statement declares a string variable for a character's name and assigns it correctly in C#?
You need a method that performs an action but returns no value. Which return type should it use?
Which statement correctly removes the first matching element "Key" from a List<string> named items?
A variable must store a whole number of lives. Which declaration uses the most appropriate type?
Loading more…