
Unity - Create with Code - Unit 4 Review
Quiz by Kelly Herbert
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
- Q1
You’re trying to write some code that creates a random age between 1 and 100 and prints that age, but there is an error. What would fix the error?
Change line 1 to “private float age”
Add the word “int” to line 8, so it says “int age = …”
On line 7, change the word “private” to “void”
Add a new line after line 8 that says “return age;”
300s - Q2
The following message was displayed in the console: “Monica has 20 dollars”. Which of the line options in the PrintNames function produced it?
Option A
Option B
Option C
Option D
300s - Q3
The code below produces “error CS0029: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'”. Which of the following would remove the error?
On line 1, change “Vector3” to “float”
On line 3, change “=” to “+”
Either A or B
None of the above
300s - Q4
Which of the following follows Unity’s naming conventions (especially as it relates to capitalization)?
Line A
Line B
Line C
Line D
300s - Q5
You are trying to assign the powerup variable in the inspector, but it is not showing up in the Player Controller component. What is the problem?
You cannot declare a powerup variable in the Player Controller Script
You cannot assign GameObject type variables in the inspector
The powerup variable should be public instead of private
The PlayerController class should be private instead of public
300s - Q6
Your game has just started and you see the error, “UnassignedReferenceException: The variable playerIndicator of PlayerController has not been assigned.” What is likely the solution to the problem?
PlayerController variable in the playerIndicator script needs to be declared
The playerIndicator variable needs to be made private
The PlayerController script must be assigned to the player object
An object needs to be dragged onto the playerIndicator variable in the inspector
300s - Q7
You are trying to create a new method that takes a number and multiplies it by two. Which method would do that?
Method A
Method B
Method C
Method D
300s - Q8
Which comment best describes the code below?
// If the player collides with an enemy, destroy the enemy
// If the enemy collides with a spike, destroy the spike
// If the enemy collides with a spike, destroy the enemy
// If the player collides with a spike, destroy the spike
300s - Q9
The code below produces the error, “error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject' to 'UnityEngine.Rigidbody'”. What could be done to fix this issue?
On line 1, change “collision” to “Rigidbody”
On line 2, change “gameObject” to “Rigidbody”
On line 3, delete “.gameObject”
On line 3, add “.GetComponent
()” before the semicolon 300s - Q10
Which of the following statements about functions/methods are correct:
A and B are correct
Only B is correct
B and C are correct
Only D is correct
None are correct
300s