void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag == "Enemy") { Destroy(gameObject); } }
When the player game object collides with an object tagged as "enemy" the player game object will be destroyed. The "OnCollisionEnter" function triggers when a collision occurs and Destroy will destroy the gameObject it is attached to.
A die is rolled and a coin is tossed. Find the probability that the die shows an odd number and the coin shows a head
1/4
There are three types of rules. Operational rules, constitutive rules and
implicit Rules
A symbol for Killers in the Bartle’s Player Types.
a club
To display a list of all GameObjects in the current scene and their parent-child relationships?
the Unity Hierarchy window
private int score = 0;
void OnTriggerEnter(Collider other) {
if(other.gameObject.tag == "Coin") {
score += 10;
Destroy(other.gameObject);
Debug.Log("Score: " + score); }}
Each time the GameObject collides with an object tagged as "Coin", 10 points will be added to the score. The coin object will be destroyed, and the new score will be logged to the console. This happens in the OnTriggerEnter function, which is called when the GameObject enters a trigger collider.
A die is rolled 4 times what is the probability of all the outcomes being even?
1/16
The snowball effect is prevalent in this type of feedback loop
a positive feedback loop
A system where if something gets too high, the game will pull them back for the sake of balance.
a negative feedback loop
A function that dynamically create copies of a GameObject in Unity
the Instantiate() function
public GameObject prefab; void Update() { if(Input.GetKeyDown(KeyCode.S)) { Instantiate(prefab, new Vector3(0, 0, 0), Quaternion.identity); } }
Whenever S is pressed a new instance of the prefab game object will be created at the coordinates 0,0,0 this is done using the Instantiate object.
From a standard deck of 52 playing cards, what is the probability of drawing an Ace followed by a King, without replacement?
265216≈0.00603 or 0.603%.
Chess is an example of a game that’s deterministic and has this type of information
perfect information
A player that has a high interest in winning but violates implicit rules.
an unsportsmanlike player
A Unity component allows you to respond to button clicks
the OnClick method
void FixedUpdate() {
if(Input.GetKeyDown(KeyCode.Space)) {
GetComponent<Rigidbody>().AddForce(Vector3.up * 500);
}
}
Every time the spacebar is pressed, a force of 500 units in the upward direction is applied to the GameObject's Rigidbody. This will likely cause the GameObject to jump upwards, depending on its mass and the physics properties of the Rigidbody.
you have 5 kids and 5 seats how many different ways can the kids sit in the seats?
5! = 120
Jesse Snell thinks that games are problem-solving activities approached in this attitude.
a playful attitude
Categories of information on an object.
attributes
A method is called when the script instance is being loaded, before Start()
the Awake() method in Unity
void Update() {
if(Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward * 10 * Time.deltaTime);
}
if(Input.GetKey(KeyCode.A)) {
transform.Rotate(Vector3.down * 50 * Time.deltaTime);
}
}
When the W key is held down the game object moves forward at a constant speed of 10 units per second. If the 'A' key is held down, the GameObject continuously rotates left (counterclockwise) at a rate of 50 degrees per second.
you have a deck of cards with replacement and want one ace one king and one queen all from the same suit what is the probability that occurs?
4/52 * 1/52 * 1/52 = 4/140608
We do not care for the suit of the ace because we care that the king and queen are of the same suit as the ace.
The attributes in a game of checkers.
the color, position, and role of pieces
A type of rule that represents the underlying structure of a game.
constitutive Rule
A system handles input events, such as clicks, and interacts with UI elements, like buttons
Unity's Event System in the context of UI interactions