0
0
Unityframework~20 mins

Transform component (position, rotation, scale) in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Transform Mastery
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 position update code?
Consider a Unity GameObject with initial position (1, 2, 3). What will be the new position after running this code snippet?
Unity
transform.position = new Vector3(1, 2, 3);
transform.position += new Vector3(0, 5, 0);
Debug.Log(transform.position);
A(1.0, 5.0, 3.0)
B(1.0, 2.0, 3.0)
C(0.0, 5.0, 0.0)
D(1.0, 7.0, 3.0)
Attempts:
2 left
💡 Hint
Adding a Vector3 to position moves the object by that amount.
Predict Output
intermediate
2:00remaining
What is the rotation angle after this code runs?
A GameObject starts with rotation (0, 0, 0). After running this code, what is the z-axis rotation in degrees?
Unity
transform.rotation = Quaternion.Euler(0, 0, 45);
transform.Rotate(0, 0, 30);
float zRotation = transform.rotation.eulerAngles.z;
Debug.Log(zRotation);
A30
B75
C45
D0
Attempts:
2 left
💡 Hint
Rotate adds to the current rotation.
Predict Output
advanced
2:00remaining
What is the scale of the object after this code?
Given a GameObject with initial scale (1, 1, 1), what is the scale after this code runs?
Unity
transform.localScale = new Vector3(2, 2, 2);
transform.localScale = Vector3.Scale(transform.localScale, new Vector3(0.5f, 3, 1));
Debug.Log(transform.localScale);
A(1.0, 3.0, 1.0)
B(2.0, 6.0, 2.0)
C(1.0, 6.0, 2.0)
D(1.0, 1.0, 1.0)
Attempts:
2 left
💡 Hint
Vector3.Scale multiplies each component separately.
Predict Output
advanced
2:00remaining
What error occurs when running this code?
What error will this code produce when executed in Unity?
Unity
transform.position = new Vector3(1, 2);
Debug.Log(transform.position);
ACS1501: No overload for method 'Vector3' takes 2 arguments
BNo error, outputs (1.0, 2.0, 0.0)
CNullReferenceException
DIndexOutOfRangeException
Attempts:
2 left
💡 Hint
Vector3 requires three float arguments.
🧠 Conceptual
expert
3:00remaining
How does changing localScale affect child objects?
If you scale a parent GameObject's transform.localScale to (2, 2, 2), how does it affect its child GameObjects' positions and scales?
AChild objects' positions and scales are multiplied by the parent's scale, making them appear larger and farther from the parent.
BChild objects' positions remain the same, but their scales double.
CChild objects' scales remain the same, but their positions double relative to the world origin.
DChild objects are unaffected in both position and scale.
Attempts:
2 left
💡 Hint
Think about how scaling a container affects everything inside it.