Consider this Unity C# script snippet that moves a 2D camera to follow a player object with a fixed offset. What will be the camera's position after running this code if the player is at (5, 3, 0)?
Vector3 playerPosition = new Vector3(5f, 3f, 0f); Vector3 offset = new Vector3(0f, 2f, -10f); Vector3 cameraPosition = playerPosition + offset; Debug.Log(cameraPosition);
Remember that adding vectors adds each component separately.
The camera position is the player's position plus the offset. So (5,3,0) + (0,2,-10) = (5,5,-10).
In Unity's 2D camera setup using an Orthographic camera, which property controls how zoomed in or out the camera view is?
Orthographic cameras do not use field of view.
The orthographicSize property controls the half-height of the camera view in world units, effectively controlling zoom for 2D orthographic cameras.
Given this Unity C# script attached to the camera to follow a player, why might the camera jitter during gameplay?
public Transform player;
void Update() {
Vector3 newPos = player.position + new Vector3(0, 2, -10);
transform.position = newPos;
}Think about when Update() runs compared to physics updates.
Update() runs before physics updates, so the camera position can lag behind the player's physics movement causing jitter. Using LateUpdate() fixes this.
Choose the correct line of code to set the main camera to orthographic mode.
Check the exact property name for orthographic mode.
The correct property to set orthographic mode is Camera.orthographic, which is a boolean.
Consider this C# code snippet that sets up a dictionary mapping layer names to their camera culling masks. How many entries does the dictionary contain?
var cameraLayers = new Dictionary<string, int>(); cameraLayers["Background"] = 1 << 8; cameraLayers["Player"] = 1 << 9; cameraLayers["Enemies"] = 1 << 10; cameraLayers["UI"] = 1 << 5; cameraLayers["Player"] = 1 << 11;
Remember that dictionary keys must be unique and duplicate keys overwrite previous values.
The key "Player" is assigned twice, so the second assignment overwrites the first. The dictionary ends with 4 unique keys.