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)
What is the Sprite Renderer?
3.1.1 Open Prototype & change background
Component that enables you to render or see images in your game and environment
3.1.1 Open Prototype & change background
What are <> used for?
3.1.3 Make player jump at start
They are used for finding specific things like components.
3.1.3 Make player jump at start
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
It applies forces to things using physics
3.1.3 Make player jump at start
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
playerRb = GetComponent< Rigidbody >();
playerRb.AddForce(Vector3.up * 1000);
3.1.3 Make player jump at start
What does the following code achieve?
3.1.3 Make player jump at start
Adds force to an object on the Y axis (jump)
3.1.3 Make player jump at start
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
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
What is a ForceMode?
3.1.4 Make player jump is spacebar is pressed
ForceMode tells Unity how AddForce should be applied to the Rigidbody
3.1.4 Make player jump is spacebar is pressed
What are the options of ForceMode?
1.ForceMode.Force
2. ForceMode.Impulse
3. ForceMode.VelocityChange
4. ForceMode.Acceleration
Describe ForceMode.Force
Applies continuous force, affected by the mass of the object
Describe ForceMode.Impulse
Applies an instant force to simulate a sudden impact or burst
Mass is still considered but it’s a one time push
What could you use ForceMode.Force on an object for?
Things with gradual acceleration, like wind, jet engines or movement over time.
What could you use ForceMode.Impulse on an object for?
Use this for explosions, gunshots, jump bursts, etc.
Describe ForceMode.VelocityChange
Directly changes the velocity of the Rigidbody, instantly. Ignores mass.
Directly changes the velocity of the Rigidbody, instantly. Ignores mass.
What could you use ForceMode.VelocityChange on an object for?
Ideal for things like sudden dashes, teleport-like bursts, or snappy platformer jumps.
Describe ForceMode.Acceleration
Applies an acceleration over time, ignoring mass.
What could you use ForceMode.Accelration on an object for?
Can be good for jetpacks, gravity-like forces, or engine thrust in space. Use when you want consistent acceleration across objects of any mass.
What is the Syntax for an AddForce statement?
Rigidbody.AddForce(Vector3, ForceMode)
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
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
What does *= mean
Times Equal
Modify the code
- Create a public variable for AddForce and modify the code.
- Create a public variable for a gravity modifer
- 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
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
What is a bool, or boolean?
3.1.6 Prevent Player from double jumping
Data type - a value that holds true or false
3.1.6 Prevent Player from double jumping
What does && mean?
3.1.6 Prevent Player from double jumping
“And”
3.1.6 Prevent Player from double jumping
We want to make sure the player can’t keep pressing space in the air to keep going higher.
- Write a variable to test if the player is on the ground
- 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
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
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
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