wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unity Programming Certification

Total questions: 23

Worksheet time: 23mins

Name
Class
Date
1.

An error is being thrown when setting the velocity of the RigidBody2D in the Update() method.

The error produced states the following: CS1955 C# Non-invocable member 'Vector2' cannot be used like a method.

Select the appropriate options in the dropdown menus that would fix the error.

​ (a)  

Choose from the below words
Choose One
new
void
() =>
2.

You want to be able to call the actionBtPressed() method from your player object. What is the appropriate access modifier and return type that the method should have? Select the appropriate option from the dropdown menu.​ (a)  

Choose from the below words
Choose One...
void
public
virtual
private
accessible
3.

Based on the API definition, select the correct implementation of the AddForce() function from the dropdown menu.

Rigidbody.AddForce

public void AddForce(float x, float y, float z, ForceMode mode = ForceMode.Force);

Parameters:

∎x Size of force along the world x-axis.

∎y Size of force along the world y-axis.

∎z Size of force along the world z-axis.

∎mode Type of force to apply.

Description:

Adds a force to the Rigidbody.

Force is applied continuously along the direction of the x,y, and z vectors. Specifying the ForceMode mode allows the type of force to be changed to an Acceleration, Impuls, or Velocity Change.

Force can be applied only to an active Rigidbody. If a GameObject is inactive, AddForce has no effect.

By default, the Rigidbody's state is set to awake once a force is applied unless the force is Vector3.zero.​ ​ (a)  

Choose from the below words
Choose One...
AddForce(0, 0, thrust, ForceMode.Impulse);
AddForce("0", "0", thrust, ForceMode.Impulse);
AddForce(0, 0, ForceMode.Impulse);
4.

Your current task is to create a script that will start an attack animation and instantiate a projectile when the play presses a button on the keyboard. Drag the appropriate code snippets to the correct place in the code block.

5.

Input.GetMouseButton(0) returns true if the left mouse button is held down.

a)

True

b)

False

6.

Input.GetMouseButtonDown(1) returns true if the middle mouse button was pressed.

a)

True

b)

False

7.

Input.GetMouseButtonUp(2) returns true if the right button was released.

a)

True

b)

False

8.

You want to write a log message to the console to check if a key was pressed. Select the correct way to write a debug log message.​ (a)  

Choose from the below words
CHoose One...
Debug.Log("Space key was pressed!");
Console.Log("Space key was pressed!");
Unity.Log("Space key was pressed!");
System.Log("Space key was pressed!");
9.

You just got an error message that says "NullReferenceException: Object reference not set to an instance of an object." Which object is likely null?

a)

myName

b)

myPos

c)

Debug.Log

d)

enemy

10.

Given the line of code below, select the generic syntax of the GameObject.AddComponent() API.

SphereCollider sc = gameObject.AddComponent(typeof(SphereCollider)) as SphereCollider;

a)

SphereCollider sc = gameObject.AddComponent SphereCollider;()

b)

SphereCollider sc = gameObject.AddComponent<SphereColleder>

c)

SphereCollider sc = gameObject.AddComponent(SphereCollider)() as SphereCollider;

d)

SphereCollider sc = gameObject.AddComponent<SphereCollider>() as SphereCollider;

11.

You have a dictionary of weapons. When the game starts, you want to ensure that a dagger is in the list so you can use it. Select the correct way to get an object stored in a dictionary.​ (a)  

Choose from the below words
Choose One...
weapons.TryGetValue("Dagger", out selectedWeapon)
weapons.GetValue("Dagger", out selectedWeapon)
weapons.TryGetValue("Dagger")
weapons.GetValue("Dagger", as selectedWeapon)
12.

You are tasked with creating a function that will change the players current animation state based on an Enum value passed as an argument.

Select the correct options to create a viable function declaration that can be accessed from other objects and does not return anything.​ (a)  

Choose from the below words
Choose One...
ChangeAnimState(AnimState state)
ChangeAnimState(string state)
ChangeAnimState()
ChangeAnimState(state)
13.

You have a pressure plate that activates a trap with an animation that automatically resets after the trap has been fired.

Drag the appropriate animator method to the designated spot for this scenario.


​ ​ ​ (a)  

Choose from the below words
anim.SetBool("Trap", true);
anim.SetFloat("Trap', 1);
anim.SetTrigger("Trap", true);
anim.SetTrigger("Trap");
14.

You have a collectible gem with several particle effects as child gameobjects.

When the player collects the gem, you want to deactivate each child as to visibly show that the gem can no longer be collected.

Select the correct code snippets from each dropdown menu to complete the code block.


​ (a)  

Choose from the below words
Choose One...
gem.transfor.GetChild(i).gameObject
gem.transform.GetChild(i)
gem.transform.GetChild(0).gameObject
15.

In your game, you have wired up a UI button to a method that pauses the game and displays the menu when the player presses the button.

Drag the appropriate code statements to the appropriate spots to complete the code block.


​ ​ (a)   ​ (b)  

Choose from the below words
Time.DeltaTime = Time.PAUSED;
Time.pause = true;
Time.timeScale = 0
menuPanel.SetActive(true);
menuPanel.isActive = true;
menuPanel.SetActive(false);
16.

True or False: The the supplied class is an ECS class.

a)

True

b)

False

17.

Determine whether each code snippet observes Unity naming standards.

Select Yes or No for each code snippet.


public class Enemy : MonoBehaviour {}

a)

True

b)

False

18.

Determine whether each code snippet observes Unity naming standards.

Select Yes or No for each code snippet.


public class weapon : MonoBehaviour {}

a)

True

b)

False

19.

Determine whether each code snippet observes Unity naming standards.

Select Yes or No for each code snippet.


public void enemyHit(int HITPoints){}

a)

True

b)

False

20.

Drag each code comment to the appropriate spot in the code block.

public void EnemyHit(int hitPoints) {

​​ (a)  

if (healthPoints - hitPoints > 0 {

​ (b)  

anim.Play(Hurt);

​ (c)  

​ GameManager.Instance.AudioSource.PlayOneShot(SoundManager.Instance.Hit)

​ (d)  

healthPoints -= hitPoints;

} else {

die();

}

}

Choose from the below words
//check if health - hit points is greater than 0
//Play the hurt animation
//Play hit sound
//subtract from health
//check if health - hit points is less than 0
//Play death sound
21.

Select all the options that are true about the Animator window. (Choose two)

a)

The Animator window allows you to create, view, and modity Assets linked to the controller.

b)

The Animator window allows you to define parameters to control the flow of animations.

c)

The Animator window lets you create 3D or 2D models you can animate.

d)

All of the above.

22.

What 3 IDE's are supported in Unity?

a)

NotePad++, Visual Studio, and Visual Studio Code

b)

Visual Studio, Visual Studio Code, and JetBrains Rider

c)

Visual Studio, Eclipse, and Xcode

23.

What setting in an animator's transition allows you to make the transition duration independent of state length?

a)

Transition Duration

b)

Interruption Source

c)

Fixed Duration

d)

Exit Time