Class hours: 9:40 – 2:05
- Today is an EHS A Day and wacky Wednesday – Carter you are out at 1:30pm.
- Dan, you have an early lunch today – at 11:55.
- Today, guest speaker at 10:00am – James Orrigo
- Vermont Highway Safety Alliance Awards are Wednesday at 5pm. Do you want to attend virtually? If so, you must register first on this link. We have at least two winner$ in this class…
- Some news out of Disney….
10:00 Guest Speaker – James Orrigo
11:15 Agency Showcase
- What did you work on?
- What did you learn?
- What would you like us to try or know that could be helpful with our own projects?
11:35 Unity – Working with Rigidbody Components
The concept of “game physics” usually includes all movements and collisions that an object might have in a game. Think about a simple cannonball shot from the deck of a pirate ship. How should this object behave?
- It should have force as it comes out of the cannon, giving it direction and speed
- It should fly and fall out of the air due to gravity
- If it hits another object, the cannonball has some kind of collision based on the mass and what it collides with.
Before quality game engines, this used to have to be carefully programmed to look real. In Unity, there is a built in Physics engine just for this.
Open your 2D project (called) GameProgramming project, Create a new 2DScene – name it PhysicsPractice.
I have some new Sprites for you, grab what you like from my Google Drive Folder.
Rigidbody and Rigidbody 2D
In Unity, the physics engine is handled by a component that you attach to a game object. For a 2D game, the component is called Rigidbody 2D. When you attach this component to a game object like a sprite, that object automatically comes under the control of the Unity 2D physics engine. Objects with a Rigidbody 2D component can respond realistically to physical forces such as gravity.
Rigidbody 2D Properties can be modified to make your gameObject behave more like you intend it to. For example a tennis ball is bouncy and a cannonball is not (so much).
Some Properties include:
- Mass – lets you control how much mass an object contains. The higher the mass, the harder an object is to move and the more effect it has when it collides with other objects in the game. Mass does not change how fast an object will fall.
- Gravity – controls how strongly gravity will affect your game object. Increase gravity to increase the speed that something falls (or does not – use negative numbers)
- Linear Drag – an object thrown in the air will naturally slow down due to air resistance. A beach ball has more linear drag than a rock.
- Angular Drag – Some objects spin (rotate) very easily, without much resistance like the wheel on your bike. Higher drag values will slow an objects spinning motion.
- Body Type (dynamic, kinematic or static) more on this later….
Bounce and Friction are Material Properties
In Unity we can create our own physics materials to control the behavior of our gameObjects.
The Friction value controls how much resistance is felt when an object is moving in contact with this material. A value of 0 means there is no friction or resistance at all.
The Bounciness value shows how much one object will bounce when it collides. A value of 0 means the object will not bounce at all.
Challenge: Bowling Game
Don’t worry, we won’t use any code! (well, maybe a little bit…)
- Create a new scene. Name it Bowling Game
- Set up your bowling ball sprite at the top of the screen and your pins at the bottom of the screen (10 Pins)
- Add Rigidbody 2D for your ball and pins – don’t forget the colliders
- Add physics material for pins/ball as you see fit
- You can also change the starting point of the bowling ball so it doesn’t hit the top pin directly in the center. Can you also adjust the bowling ball’s Mass, Angular Drag, Linear Drag, and Gravity Scale to produce different behavior?
- Observe and try to understand how different Rigidbody 2D properties affect your game
12:45 Focus on Literacy
1:05 Mask Break
1:15 Production Time & Guided Support
- Karting custom track build – Due Friday
- Career Exploration – Game Careers due Friday
- Challenge: Alien Space Dance if you have not checked out with me
- Week 32 Agency Project – Due May 2nd
- Past Due work – check PowerSchool. P4 closes on Friday.