Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new GameObject named "Player".
Unity
GameObject player = new GameObject([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the quotes around the name.
Using single quotes instead of double quotes.
Passing a variable name instead of a string.
✗ Incorrect
The GameObject constructor requires the name as a string in double quotes.
2fill in blank
mediumComplete the code to rename an existing GameObject to "Enemy".
Unity
gameObject.[1] = "Enemy";
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call a method instead of setting a property.
Using incorrect property names like
SetName.✗ Incorrect
The name property sets the GameObject's name.
3fill in blank
hardFix the error in the code to create a GameObject named "Bullet".
Unity
GameObject bullet = new GameObject([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the name without quotes causes a compile error.
Using single quotes instead of double quotes.
✗ Incorrect
The name must be a string in double quotes to avoid errors.
4fill in blank
hardFill both blanks to create a GameObject named "Coin" and then rename it to "GoldCoin".
Unity
GameObject coin = new GameObject([1]); coin.[2] = "GoldCoin";
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method instead of the
name property to rename.Forgetting quotes around the initial name.
✗ Incorrect
Use "Coin" to name the new GameObject and set the name property to rename it.
5fill in blank
hardFill all three blanks to create a GameObject named "Tree", rename it to "OakTree", and then print its name.
Unity
GameObject tree = new GameObject([1]); tree.[2] = "OakTree"; Debug.Log(tree.[3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method instead of the
name property.Forgetting quotes around the initial name.
Trying to print a method instead of the property.
✗ Incorrect
Create the GameObject with "Tree", rename by setting name, and print the name property.