0
0
Unityframework~10 mins

Game engine architecture overview in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a basic GameObject in Unity.

Unity
GameObject [1] = new GameObject();
Drag options to blanks, or click blank then click option'
Aplayer
Bint
Cvoid
DStart
Attempts:
3 left
💡 Hint
Common Mistakes
Using a data type like 'int' instead of a variable name.
2fill in blank
medium

Complete the code to add a Rigidbody component to a GameObject.

Unity
Rigidbody rb = [1].AddComponent<Rigidbody>();
Drag options to blanks, or click blank then click option'
AComponent
BGameObject
Cthis
Dplayer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'this' when not inside a MonoBehaviour class.
3fill in blank
hard

Fix the error in the Update method to move the GameObject forward.

Unity
void Update() {
    transform.Translate(Vector3.[1] * Time.deltaTime);
}
Drag options to blanks, or click blank then click option'
Aforward
Bleft
Cright
Dup
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'up' or 'right' which move the object in other directions.
4fill in blank
hard

Fill both blanks to create a dictionary mapping GameObject names to their components.

Unity
Dictionary<string, [1]> components = new Dictionary<string, [2]>();
Drag options to blanks, or click blank then click option'
AComponent
BGameObject
CRigidbody
DTransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using GameObject as the value type instead of Component.
5fill in blank
hard

Fill all three blanks to filter and store active GameObjects with Rigidbody components.

Unity
var activeRigidbodies = [1].Where(go => go.[2] && go.GetComponent<[3]>() != null).ToList();
Drag options to blanks, or click blank then click option'
AgameObjects
BactiveSelf
CRigidbody
Dtransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'transform' instead of 'Rigidbody' in GetComponent.