3 - Sound and Effects Flashcards

Learn how to add music, sound effects, and visual particle effects to transform the experience of your project. (34 cards)

1
Q

What is the Sprite Renderer?

3.1.1 Open Prototype & change background

A

Component that enables you to render or see images in your game and environment

3.1.1 Open Prototype & change background

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are <> used for?

3.1.3 Make player jump at start

A

They are used for finding specific things like components.

3.1.3 Make player jump at start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If transform.translate can move an object physically just using positions, what does Adding Force on the Rigidbody do?

3.1.3 Make player jump at start

A

It applies forces to things using physics

3.1.3 Make player jump at start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Make an object jump with force

In the start method, write the code to call the Rigidbody component and apply force using the Rigidbody variable “playerRb”.

Integer for force is your choice

3.1.3 Make player jump at start

A

playerRb = GetComponent< Rigidbody >();
playerRb.AddForce(Vector3.up * 1000);

3.1.3 Make player jump at start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the following code achieve?

3.1.3 Make player jump at start

A

Adds force to an object on the Y axis (jump)

3.1.3 Make player jump at start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Make the player jump if spacebar is pressed. Rewrite and adjust the cod

void Start()
{
playerRb = GetComponent< Rigidbody >();
playerRb.AddForce(Vector3.up * 1000);
}

void Update()
{

}

3.1.4 Make player jump is spacebar is pressed

A

void Start()
{
playerRb = GetComponent< Rigidbody >();
}

void UPdate()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * 1000);

3.1.4 Make player jump is spacebar is pressed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a ForceMode?

3.1.4 Make player jump is spacebar is pressed

A

ForceMode tells Unity how AddForce should be applied to the Rigidbody

3.1.4 Make player jump is spacebar is pressed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the options of ForceMode?

A

1.ForceMode.Force
2. ForceMode.Impulse
3. ForceMode.VelocityChange
4. ForceMode.Acceleration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe ForceMode.Force

A

Applies continuous force, affected by the mass of the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe ForceMode.Impulse

A

Applies an instant force to simulate a sudden impact or burst

Mass is still considered but it’s a one time push

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What could you use ForceMode.Force on an object for?

A

Things with gradual acceleration, like wind, jet engines or movement over time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What could you use ForceMode.Impulse on an object for?

A

Use this for explosions, gunshots, jump bursts, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe ForceMode.VelocityChange

A

Directly changes the velocity of the Rigidbody, instantly. Ignores mass.

Directly changes the velocity of the Rigidbody, instantly. Ignores mass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What could you use ForceMode.VelocityChange on an object for?

A

Ideal for things like sudden dashes, teleport-like bursts, or snappy platformer jumps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe ForceMode.Acceleration

A

Applies an acceleration over time, ignoring mass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What could you use ForceMode.Accelration on an object for?

A

Can be good for jetpacks, gravity-like forces, or engine thrust in space. Use when you want consistent acceleration across objects of any mass.

17
Q

What is the Syntax for an AddForce statement?

A

Rigidbody.AddForce(Vector3, ForceMode)

18
Q

Change code to add the ForceMode Impulse

void Start()
{
playerRb = GetComponent< Rigidbody >();
}

void UPdate()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * 1000);

3.1.4 Make player jump is spacebar is pressed

A

void Start()
{
playerRb = GetComponent< Rigidbody >();
}

void UPdate()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * 1000, ForceMode.Impulse);

3.1.4 Make player jump is spacebar is pressed

19
Q

What does *= mean

20
Q

Modify the code

  1. Create a public variable for AddForce and modify the code.
  2. Create a public variable for a gravity modifer
  3. Call the gravity modiifer in Start method

void Start()
{
playerRb = GetComponent< Rigidbody >();
}

void UPdate()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * 10, ForceMode.Impulse);

3.1.5 Tweak the jump force and gravity

A

public float jumpForce = 10.0f;
public float gravityModifier;

void Start()
{
playerRb = GetComponent< Rigidbody >();
Physics.gravity = gravityModifier
}

void UPdate()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

3.1.5 Tweak the jump force and gravity

21
Q

What is a bool, or boolean?

3.1.6 Prevent Player from double jumping

A

Data type - a value that holds true or false

3.1.6 Prevent Player from double jumping

22
Q

What does && mean?

3.1.6 Prevent Player from double jumping

A

“And”

3.1.6 Prevent Player from double jumping

23
Q

We want to make sure the player can’t keep pressing space in the air to keep going higher.

  1. Write a variable to test if the player is on the ground
  2. Modify the if statement so that when the player is in the air they can’t press space

public float jumpForce = 10.0f;
public float gravityModifier;

void Start()
{
playerRb = GetComponent< Rigidbody >();
Physics.gravity = gravityModifier
}

void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

3.1.6 Prevent Player from double jumping

A

public float jumpForce = 10.0f;
public float gravityModifier;
public bool isOnGround;

void Start()
{
playerRb = GetComponent< Rigidbody >();
Physics.gravity = gravityModifier
}

void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && isOnGround)
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
isOnGround = false;
}

3.1.6 Prevent Player from double jumping

24
Q

Describe what is happening in this code

void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && isOnGround)
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
isOnGround = false;
}

3.1.6 Prevent Player from double jumping

A

When space bar is pressed and character is on the ground, object jumps into the air. Once in the air, the object is written to be no longer on the ground, and so the space bar cannot be pressed in the air.

3.1.6 Prevent Player from double jumping

25
We've made it so you can't spam jump when in the air by making isOnGround false, but the problem is we never defined how to set it back to true. Using colliders, write a new method to ensure the program knows when the character is back on the ground by making isOnGround = true. | Name the method OnCollisionEnter ## Footnote 3.1.6 Prevent Player from double jumping
private void OnCollisionEnter(Collision collision) { isOnGround = true; } ## Footnote 3.1.6 Prevent Player from double jumping
26
# What is this code saying in our PlayerController script? private void OnCollisionEnter(Collision collision) { isOnGround = true; } ## Footnote 3.1.6 Prevent Player from double jumping
Any time our PlayerController comes into collision with something, then isOnGround = true; ## Footnote 3.1.6 Prevent Player from double jumping
27
Make a variable startPos and in the Start method define it as the starting position of our background sprite. ## Footnote 3.2.2 Reset position of Background
private Vector3 startPos; void Start() { startPos = transform.position; } ## Footnote 3.2.2 Reset position of Background
28
We want our background to repeat as it moves left on the X axis. Write the Update method for the code below. private Vector3 startPos; void Start() { startPos = transform.position; } ## Footnote 3.2.2 Reset position of Background
private Vector3 startPos; void Start() { startPos = transform.position; } void Update(0 { if (transform.position.x < -50) { transform.position = startPos; } } ## Footnote 3.2.2 Reset position of Background
29
# Modify the code The repeating background is currently stuttery. Use the background's Object collider to fix it. Write a new variable to get the width of the component and divide it by 2 to create a seamless, left flowing background. private Vector3 startPos; void Start() { startPos = transform.position; } void Update(0 { if (transform.position.x < -50) { transform.position = startPos; } } ## Footnote 3.2.3 Fix background repeat with collider
private Vector3 startPos; **private float repeathWidth; ** void Start() { startPos = transform.position; **repeatWidth = GetComponent().size.x / 2;** } void Update(0 { if (transform.position.x < startPos.x - **repeatWidth**) { transform.position = startPos; } } ## Footnote 3.2.3 Fix background repeat with collider
30
# Modify the code Write an if statement to check if our Player collides with another game object. Use tag "Ground" as the other game object. Write a game over variable to check if the game is over. public float jumpForce = 10.0f; public float gravityModifier; public bool isOnGround; void Start() { playerRb = GetComponent< Rigidbody >(); Physics.gravity = gravityModifier } void Update() { if (Input.GetKeyDown(KeyCode.Space) && isOnGround) playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); isOnGround = false; } | HINT: You'll need to write a new method ## Footnote 3.2.4 Add a new game over trigger
public float jumpForce = 10.0f; public float gravityModifier; public bool isOnGround; **public bool gameOver;** void Start() { playerRb = GetComponent< Rigidbody >(); Physics.gravity = gravityModifier } void Update() { if (Input.GetKeyDown(KeyCode.Space) && isOnGround) playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); isOnGround = false; } **private void onCollisionEnter (Collision, collision) { if(collision.gameObject.CompareTag("Ground") { isOnGround = true; } else if(collision.GameObject.CompareTag("Ground") { Debug.Log("Game Over"); gameOver = true; }** ## Footnote 3.2.4 Add a new game over trigger
31
Describe what the following code is doing. private void onCollisionEnter (Collision, collision) { if(collision.gameObject.CompareTag("Ground") { isOnGround = true; } else if(collision.GameObject.CompareTag("Ground") { Debug.Log("Game Over"); gameOver = true; } ## Footnote 3.2.4 Add a new game over trigger
Check collision with the object tagged with Ground. If player object collides with ground, then variable isOnGround is true. Also if, sends a debug message "Game Over" as well as the bool gameOver equals true. ## Footnote 3.2.4 Add a new game over trigger
32
We need two scripts to interact. What are steps to make this happen. ## Footnote 3.2.5 Stop Move Left on gameOver
1. We need to create a variable that can hold a reference to our script 2. Call the script in the Start method 3. Find the name of your object 4. Get the component ## Footnote 3.2.5 Stop Move Left on gameOver
33
We want our MoveLeft script to stop on game over. We need to hold a reference to the PlayerController script inside the moveLeft script. Write that variable.
private PlayerController playerControllerScript;
34