Unity Lecture 4
Unity Lecture 5(buttons and time)
Unity Lecture 6 and 7(Persistent data and high scores)
Unity Lecture 8(Game Balance)
Probability
100

consider this unity class. It will be used as a component for some GameObject
    public class Script : MonoBehaviour
    {
        Private void OnTriggerEnter2D(Collider2D other) {
            If (other.tag == “Player”)
            SceneManager.LoadScene(SceneManager.GetSceneAt(0).name);
            }
        }
    }
    Briefly explain what this script is meant to do


    Briefly explain what this script is meant to do


if the player comes in contact with this game object, “kill” them by restarting the  game/scene.

100

How can you implement a button click event in Unity, and what are the common methods for handling button clicks?

Unity provides the Button component for UI elements. You can handle button clicks by creating a method in a script and associating it with the button's onClick event through the Unity Editor. Common methods include using the UnityEvent system or directly calling a method with Button.onClick.AddListener().

100

How do you declare something that is static, and why?

Answer: Use the static keyword after the access modifier (public static…) as static members are useful in that they can provide a global point of access to a single static class. Very useful for persistent data

100

According to David Perry, what 3 things should players be doing at the same time in a well designed game?

Exercising a skill, taking risks, working a strategy

100

What is the probability of rolling a 1 on a 4-sided die?

1/4

Explanation: the 4-sided die has equal chances for outcomes 1, 2, 3, and 4. Since there's only one favorable outcome (rolling a 1), the probability is 1/4.

200

for the Mario Unity Game we did in class, what GameObject served as a “parent” to UI elements like scoreText and the pause button?

the Canvas

200

Discuss the importance of the Time.deltaTime variable in Unity.

Time.deltaTime is a time value representing the completion time in seconds since the last frame.

200

How to do use the awake() method and why?

Simply define it as if it's a function like start(), just use Awake() because you can use the Awake() method for setting up references between scripts, initializing variables, or performing tasks that need to be done once the script is loaded.

200

What are at least 2 benefits of asymmetrical games?

1. Simulate real-world situations, 

2. Give players another way to explore game space, personalization, level the playing field, create interesting situations

200

A die is rolled and a coin is tossed. Find the probability that the die lands on 1 or 2 and the coin lands on a tail.

1/6

Explanation

probability of landing on 1 or 2 = 2/6 = 1/3

Probability of landing on a tail = 1/2

Probability of die landing on 1 or 2 and the coin lands on tail = 1/3*1/2 = 1/6

300

a unity scorekeeper class has a Start() method as follows

void Start()

       {

               level = SceneManager.GetActiveScene().buildIndex - 1;

                score = 0;

                scoreThresholdForThisLevel = SCORE_THRESHOLD * level;

        }

Write the code for the player to advance to the next level when their score surpasses the threshold.

 if(score >= scoreThresholdForThisLevel) {

            SceneManager.LoadScene(level + 2);

 }

300

Explain how to implement a pause functionality in a Unity game.

Pausing a Unity game involves stopping time-related functions, animations, and scripts. You can achieve this by setting Time.timeScale to 0 to halt time and resuming by setting it back to 1

300

How do you use Playerperfs and what can it be used for

Use the keyword PlayerPrefs and then use PlayerPrefs.SetInt(“string”, int) or any other built in functions to your liking. PlayerPrefs are used to store data between different runs in a game. Very useful for persistent score/high scores

300

A good game gives the player meaningful __________?

Choices

300

If you draw one shape at a time from a bag containing 5 different shapes, and after each draw, you put the shape back into the bag, what is the probability that the next shape drawn is the same as the previous one?

1/25    

Explanation: On the first draw, the chance of picking a specific shape is 1 in 5. Now, after placing it back into the bag, the odds of drawing that exact shape again on the second draw remain 1 in 5. To find the combined probability, we multiply these individual probabilities, resulting in a 1/25 chance of drawing the same shape consecutively.

400

a unity scorekeeper class has member variable [SerializeField] TMP_Text scoreText;
  private void DisplayScore()

    {     

    }

 scoreText.SetText("Score: " + score);

Complete this method so it displays the string “Score:”, followed by the player’s score

400

Explain how to implement time scaling in Unity animations. How can you dynamically adjust the speed of an animation during runtime, and what role does the Time.timeScale property play in this context?

Time scaling in animations can be achieved by adjusting the animation speed property or by manipulating the Time.timeScale property globally. Dynamically changing the speed during runtime allows for effects like slow-motion or fast-forwarding.

400

what data structure and basic algorithm we can use for storing top X high scores?

A list is perfect as we will be doing alot of inserting and removing. In addition, it will be very time efficient. For algo, we can simply compare the current score to the scores already in the list. If it's lower than the last entry, do not insert. If it's the highest, move everything down, etc etc.

400

Increase difficulty with each success, create “layers of challenge”, and give the losers a break are types of common techniques for _______________?

Striking a proper balance

400

What is the probability of getting at least one 3 when rolling two 5 sided dice.

9/25

Explanation: Each die has 5 possible outcomes. The chance of not rolling a 3 on one die is 4/5. Since the dice are independent, the probability of not rolling a 3 on both dice is (4/5 * 4/5) = 16/25. Using the complementary probability approach to find the probability of rolling at least one 3, we subtract the probability of not rolling a 3 from 1 (1-16/25), resulting in 9/25.

500

a unity scene is named “startinglevel”, exactly. What code can we write to load this scene in the game?

SceneManager.LoadScene(“startinglevel”)

500

How can you integrate sound effects with button clicks in Unity?

Integrate sound effects by attaching an AudioSource component to the button and playing the desired audio clip in response to the button click event. Adjust the volume and consider using a sound manager for better control and resource management.

500

 Why is PlayerPref not used in actual game dev?

because the data in unencrypted and can be easily accessed by the user.

500

This relationship comes up so often, The player is one point of the triangle, the low-risk choice is the second point, and the high-risk choice is the third. What is a shorter name for this?

Triangularity

500

You are given three paths in a game and each has a certain amount of gold. The left path has 5 golds but there is a lazy guard that guards the gold who is sleeping about 60% of the time. The right path has just 1 gold without any danger. The middle path has a dragon who is active and only sleeps about 25% of the time. If you are seen by both the Guard and Dragon you will be killed and lose (-10 golds) Which path do you take to gain the maximum value of golds without being killed?

The right path 

Explanation:

If you take the left path, the expected amount of gold would be:

         p(getting the gold when guard is asleep)+ p(getting killed)

        0.6*5 + 0.4*(-10) = -1

If you take middle path, the expected amount of gold would be;

p(getting the gold when dragon is asleep)+ p(getting killed)

0.25*10+0.75*(-10) = -5

If you decided to play it safe and chose right path

1

The correct answer is playing it safe and getting that 1 gold.