Class hours: 10:05 – 2:45
Mr. Bohmann | wbohmann@ewsd.org
10:05 Today’s Notes & Attendance
Actors Wanted!– looking for a couple to assist with the creation of a bus safety video
Friday, CAWD II is going to the SkillsUSA Awards Lunch. It’s a celebration for your hard work preparing for SkillsUSA and the competition itself. We will hopefully be back for the bus, but we may be late. Arrange for a ride home as a backup plan. If this does not work for you – you will stay in Student Services for the day.
- Lunch attendees are required to wear white shirt / polo and dark pants and shoes.
- We are leaving at 10:30am
PSA Contest Information from the Vermont Highway Safety Alliance
CAWD Classroom – Starting Monday, CAWD will be closed during lunch. Lunch alternatives include Student Services, Mx. Yopp’s Room and the Cafeteria of course. Why? I am doing some mentoring during lunch and eating my own lunch. Doors will open 5 minutes before lunch ends.
10:10 Unity – Pinball

Before Skills we used the Unity physics engine to create realistic collisions between objects.
Collisions are an important part of gameplay. If the player shoots a target, your game might update a score, or if the player hits an obstacle, he or she might lose some health, or if there is a goal or a basket, the player should be rewarded! This game logic requires more than just the physics engine – you also need to write some scripts.
Besides collisions, there are other event driven programming:
- Player clicks on a button
- Timer countdown reaches zero
- Player health reaches zero
- Player wins the game
- …and of course, a collision between objects!
OnCollisionEnter2D
As soon as you add a Collider 2D component to your game object, Unity can run a specific function every time a collision occurs with that object. OnCollisionEnter2D() function can be added to your script.
When a function is called, it is possible to give that function some useful data. The function can then use that data to perform a task. The data is listed inside the function parentheses right after the function name.
For our example, (Collision2D otherObject) is the parameter. The first part (“Collision2D”) shows the type of data and the second part (“otherObject”) is the local name for that piece of data that we can use inside our function. Of course we could use the name “pizza” as our local name, but that doesn’t make much sense.
Once you add the OnCollisionEnter2D() function to your script and attach that script to a game object with a collider, the function will be called each time a new collision is detected with another object that also has a collider.
void OnCollisionEnter2D(Collision2D otherObject)
{
// Code here runs when collision occurs
Debug.Log("Collision with: " + otherObject.gameObject.name);
}
OnTriggerEnter2D
So far, all of our collisions have resulted in some real-world reaction from the objects that hit each other. Beach balls bounce and bowling pins go flying. However, you may want to detect collisions in cases where there should be no real-world physics reaction. Like when a ball crosses the goal line in soccer or your car jumps or crosses over a powerup. In those case you want to trigger an event.
With “Is Trigger” checked, your collider will detect collisions but game objects will not be part of the game physics when a collision happens. You will get an event-driven function call that you can use to run game logic, but the two objects will pass through each other on the screen.
void OnTriggerEnter2D(Collider2D otherObject)
{
// Code here runs when a trigger collision occurs
Debug.Log("Trigger with: " + otherObject.gameObject.name);
}
Pinball is a classic stand-up arcade game and one that I played a lot growing up. A steel ball is shot onto a playing surface and bounces between bumpers and other gadgets, scoring points. The player tries to keep the ball in play with flippers or paddles at the bottom. Making a Pinball game is a great chance to show off the physics engine in Unity and some of the skills you worked on the last few days with movement. Open the project we created called 2D Playground (or something like that)
Create a New 2D scene (called) PinBall
Project Details
For our game, a ball will drop from the top of the screen to start the game. As it falls, it will bounce off a series of bumpers on the screen. The player will move a paddle to the left and right at the bottom of the screen to prevent the ball from falling down the “hole” at the bottom of the screen. Once the ball falls down the hole, the game is over.
The boundaries of the game are a series of rectangles with box colliders added.

You will add the rigidbody, collider, and physics material components to the ball, bumpers, and paddle to make the game work correctly! You will also write the C# script to control the paddle movement and detect when the game is over.

Let’s create a simple prototype. Later we an add our own look to customize our game. Let’s just get the mechanics working. A minimum viable product is what we are after. For reference, I’ve created my own basic prototype above. You can copy or create your own.
You will need:
- A Movement Script for your player so that when you use the A or D key, your paddle moves around
- A Ball Script for detecting game over (We’ll code together)
- Add RigidBody 2D to your pinball
- Use physics materials (that you create) to manage your bumpers
- PlayTest your game
- Challenge: Can you respawn your ball if you lose?
10:50 Break

11:00 Unity Continued….
New vs Old Input Systems – Let’s try them both out

New Input System

Respawn

11:45 Vermont Highway Safety Alliance Showcase

Let’s look at our first animatics. All you have to do is drop your link to your video in Google Classroom.
12:25 – 12:55 Lunch

12:55 Independent Reading

1:20 Break

1:30 Design Challenge

1:55 Production Time and Guided Support
Current Assignments:
- Work on PSA
2:38Dailies

Dailies can be placed in the CAWD2 Dailies Folder on the CAWD2 Public Folders drive