Bird
Raised Fist0
Unityframework~20 mins

3D coordinate system in Unity - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
3D Coordinate Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Vector3 addition?
Consider the following Unity C# code snippet. What will be printed to the console?
Unity
using UnityEngine;

public class TestVector : MonoBehaviour {
    void Start() {
        Vector3 a = new Vector3(1, 2, 3);
        Vector3 b = new Vector3(4, 5, 6);
        Vector3 c = a + b;
        Debug.Log(c);
    }
}
A(3.0, 7.0, 9.0)
B(5.0, 7.0, 9.0)
C(4.0, 5.0, 6.0)
D(1.0, 2.0, 3.0)
Attempts:
2 left
💡 Hint
Remember that Vector3 addition adds each coordinate separately.
🧠 Conceptual
intermediate
1:00remaining
Which axis points upwards in Unity's 3D coordinate system?
In Unity's default 3D coordinate system, which axis represents the vertical direction (up)?
AX axis
BNegative Y axis
CY axis
DZ axis
Attempts:
2 left
💡 Hint
Think about which axis controls height in the scene view.
🔧 Debug
advanced
2:30remaining
Why does this code produce an unexpected movement?
This code is intended to move an object 5 units forward along the Z axis, but it moves only 1 unit forward instead. Why?
Unity
using UnityEngine;

public class MoveObject : MonoBehaviour {
    void Start() {
        Vector3 move = new Vector3(0, 0, 5);
        transform.position += move.normalized;
    }
}
ABecause move.normalized changes the vector length to 1, so it moves only 1 unit forward.
BBecause transform.position cannot be changed directly.
CBecause the vector should be multiplied by Time.deltaTime.
DBecause the vector should be added without normalization.
Attempts:
2 left
💡 Hint
Check what normalized does to a vector's length.
📝 Syntax
advanced
1:30remaining
Which code correctly creates a Vector3 pointing left?
Select the code snippet that correctly creates a Vector3 pointing left in Unity's 3D space.
AVector3 left = new Vector3(0, -1, 0);
BVector3 left = new Vector3(0, 0, -1);
CVector3 left = new Vector3(1, 0, 0);
DVector3 left = new Vector3(-1, 0, 0);
Attempts:
2 left
💡 Hint
Left means negative direction along the X axis.
🚀 Application
expert
3:00remaining
How many unique Vector3 points are generated by this nested loop?
Consider this code that generates Vector3 points in a 3D grid: int count = 0; for (int x = 0; x < 3; x++) { for (int y = 0; y < 2; y++) { for (int z = 0; z < 4; z++) { Vector3 point = new Vector3(x, y, z); count++; } } } What is the value of count after this code runs?
A24
B9
C12
D18
Attempts:
2 left
💡 Hint
Multiply the number of iterations in each loop.

Practice

(1/5)
1.

In Unity's 3D coordinate system, which axis typically represents the vertical direction?

easy
A. Z-axis
B. X-axis
C. W-axis
D. Y-axis

Solution

  1. Step 1: Understand Unity's coordinate axes

    Unity uses X for horizontal (left-right), Y for vertical (up-down), and Z for depth (forward-back).
  2. Step 2: Identify the vertical axis

    The vertical direction is along the Y-axis in Unity's 3D space.
  3. Final Answer:

    Y-axis -> Option D
  4. Quick Check:

    Vertical = Y-axis [OK]
Hint: Remember Y is up/down in Unity's 3D space [OK]
Common Mistakes:
  • Confusing Z-axis as vertical
  • Thinking X-axis is vertical
  • Using W-axis which doesn't exist in 3D
2.

Which of the following is the correct way to set an object's position to (1, 2, 3) in Unity using Vector3?

transform.position = ?;
easy
A. new Vector2(1, 2, 3)
B. Vector3(1, 2, 3)
C. new Vector3(1, 2, 3)
D. Vector3.new(1, 2, 3)

Solution

  1. Step 1: Recall Vector3 instantiation syntax

    In Unity C#, you create a Vector3 using the constructor: new Vector3(x, y, z).
  2. Step 2: Check each option's syntax

    new Vector3(1, 2, 3) uses correct syntax. Vector3(1, 2, 3) misses 'new'. new Vector2(1, 2, 3) uses Vector2 which only has 2 components. Vector3.new(1, 2, 3) uses incorrect method call.
  3. Final Answer:

    new Vector3(1, 2, 3) -> Option C
  4. Quick Check:

    Use 'new Vector3(x, y, z)' to create 3D points [OK]
Hint: Always use 'new Vector3' with three numbers [OK]
Common Mistakes:
  • Omitting 'new' keyword
  • Using Vector2 instead of Vector3
  • Wrong method call syntax
3.

What will be the output of this Unity C# code snippet?

Vector3 pos = new Vector3(2, 5, -3);
pos.z = 10;
Debug.Log(pos);
medium
A. (2.0, 5.0, 10.0)
B. (2.0, 5.0, -3.0)
C. (0.0, 0.0, 10.0)
D. Error: Cannot assign to z

Solution

  1. Step 1: Understand Vector3 initialization

    pos is set to (2, 5, -3) initially.
  2. Step 2: Modify the z component

    pos.z = 10 changes the z value from -3 to 10.
  3. Step 3: Output the Vector3

    Debug.Log prints the current pos, which is (2.0, 5.0, 10.0).
  4. Final Answer:

    (2.0, 5.0, 10.0) -> Option A
  5. Quick Check:

    Changing z updates position z value [OK]
Hint: Changing pos.z updates only the z coordinate [OK]
Common Mistakes:
  • Thinking original z stays unchanged
  • Expecting error on assignment
  • Confusing output format
4.

Identify the error in this Unity C# code that tries to move an object up by 1 unit:

transform.position = transform.position + Vector3.up * 1;
medium
A. Code is correct and moves object up by 1 unit
B. Cannot add Vector3 to transform.position
C. Missing semicolon at the end
D. Vector3.up is not defined in Unity

Solution

  1. Step 1: Check Vector3.up usage

    Vector3.up is a predefined vector (0,1,0) in Unity representing upward direction.
  2. Step 2: Verify addition with transform.position

    transform.position is a Vector3, so adding Vector3.up * 1 is valid and moves the object up by 1 unit.
  3. Final Answer:

    Code is correct and moves object up by 1 unit -> Option A
  4. Quick Check:

    Vector3.up moves object up [OK]
Hint: Vector3.up is (0,1,0), adding moves object up [OK]
Common Mistakes:
  • Thinking Vector3.up is undefined
  • Believing Vector3 addition is invalid
  • Missing semicolon (actually present)
5.

You want to move an object diagonally forward and up by 3 units each in Unity. Which code correctly updates transform.position?

hard
A. transform.position += new Vector3(3, 3, 3);
B. transform.position += Vector3.forward * 3 + Vector3.up * 3;
C. transform.position = Vector3.forward * 3 + Vector3.up * 3;
D. transform.position += Vector3.right * 3 + Vector3.up * 3;

Solution

  1. Step 1: Understand directions in Unity

    Vector3.forward is (0,0,1) for forward, Vector3.up is (0,1,0) for up.
  2. Step 2: Combine movements correctly

    Adding Vector3.forward * 3 and Vector3.up * 3 moves object 3 units forward and 3 units up.
  3. Step 3: Use '+=' to add to current position

    transform.position += Vector3.forward * 3 + Vector3.up * 3; correctly adds this combined vector to current position.
  4. Final Answer:

    transform.position += Vector3.forward * 3 + Vector3.up * 3; -> Option B
  5. Quick Check:

    Use '+=' with combined vectors for diagonal move [OK]
Hint: Add forward and up vectors multiplied by distance [OK]
Common Mistakes:
  • Replacing position instead of adding
  • Using wrong axis like right instead of forward
  • Adding equal values to x, y, z instead of correct axes