This is the Complete Unity Developer - one of the most successful e-learning courses on the internet! Completely re-worked from scratch with brand-new projects and our latest teaching techniques. You will benefit from the fact we have already taught nearly half a million students game development, many shipping commercial games as a result.
You're welcome to download, fork or do whatever else legal with all the files! The real value is in our huge, high-quality online tutorials that accompany this repo. You can check out the course here: Complete Unity Developer
In this section we use Unity's physics engine to create a wall-breaking game. (Ref: BR_CUD)
Here are the lectures of the course for this section.
In this video (objectives)…
- Overview of this section.
- Focus on Unity's physics engine and collisions.
- Lots of creative opportunity to make your own levels, background, blocks, rules, tuning and so on.
After watching (learning outcomes)… Ready and raring to start this section.
In this video (objectives)…
- Fundamental aspects of our design.
- Ideas for your game.
- Challenge for your game theme, background image and name.
After watching (learning outcomes)… Clear on the game design we will use for Block Breaker.
In this video (objectives)…
- Export scenes and SceneLoader.cs from previous project.
- Import package into our new project.
- Set up build settings, change aspect ratio, update text.
After watching (learning outcomes)… Export scenes and logic from one project and import as a package into another.
In this video (objectives)…
- Discuss what Unity World Units are.
- Set up our camera size.
- Import and set up background image, paddle, ball and block.
After watching (learning outcomes)… Understand world units and set up play space.
In this video (objectives)…
- Add a Rigidbody2D to the ball so that it has gravity influencing it.
- Add colliders to ball and block so that they collider.
After watching (learning outcomes)… Able to add the core physics components to 2D objects.
In this video (objectives)…
- Add Polygon Collider 2D to our paddle.
- Add Physics Material 2D to our ball.
- Bounce!
After watching (learning outcomes)… Make a game object bounce off another game object.
In this video (objectives)…
- Stop our ball rotating by freezing Z axis rotation on our Rigidbody.
- Create a lose collider.
- Discuss difference between trigger and collider and examine the event matrix for collision events.
- Load Game Over screen when ball passes through lose collider.
After watching (learning outcomes)… Make the game load a new scene when an object passes through a trigger volume.
In this video (objectives)…
- Find the position of the mouse on the screen.
- Convert the mouse position into a relative proportion of our screen represented as game units.
- Link movement of our mouse to movement of our paddle.
After watching (learning outcomes)… Move a game object so that it matches the position of the player's mouse.
In this video (objectives)…
- Figure out the range we want to allow the paddle to move on x axis.
- use Mathf.Clamp() to limit the paddle's movement.
After watching (learning outcomes)… Use Mathf.Clamp() to limit the movement of a game object.
In this video (objectives)…
- Understand how to calculate the distance from ball to paddle.
- Update location of the ball to match the location of the paddle plus our offset.
After watching (learning outcomes)… Stick the ball to the paddle.
In this video (objectives)…
- Create a method to give the ball an upwards velocity.
- Create a bool which allows us to determine if the game has started yet and therefore stop locking the ball to the paddle.
After watching (learning outcomes)… Launch the ball with upward velocity from the paddle.
In this video (objectives)…
- Ben and Rick discuss the use of public variables versus [SerializeField].
After watching (learning outcomes)… Understand why we avoid using public variables in our classes.
In this video (objectives)…
- Add walls for our ball to bounce off.
- Alter the gravity so that the ball doesn't slow down due to gravity.
After watching (learning outcomes)… Set up our play space and change our gravity.
In this video (objectives)…
- Add Block.cs script to our block.
- Use the Destroy() method to destroy the block once its hit.
- Discuss the option to set arguments for the method.
After watching (learning outcomes)… Destroy our block when the ball hits it.
In this video (objectives)…
- Create our first prefab.
- Experiment with how prefabs work.
- Set our snap settings.
- Build a level.
After watching (learning outcomes)… Use prefabs and build a level out of prefabbed blocks.
In this video (objectives)…
- Prefab all of the game objects that are required for our game levels.
- Create Level 2 using our prefabbed objects.
After watching (learning outcomes)… Create a second level using prefabbed assets.
In this video (objectives)…
- Identify the issue - the ball slows down after hitting the side of the paddle.
- Alter the physics material friction value to remove all friction on the ball.
After watching (learning outcomes)… Stop the ball slowing down when it collides with the paddle.
In this video (objectives)…
- Understand Audio Listener, Audio Source and Audio Clip.
- Use GetComponent to access the Audio Source and play our clip.
- Ensure that the sound does not start until the ball is launched.
After watching (learning outcomes)… Trigger sound effect each time the ball collides with something.
In this video (objectives)…
- Use PlayOneShot instead of Play.
- Create an array and then use that array to randomly select one of many audio clips.
- Cache our component reference.
After watching (learning outcomes)… Randomly play one of many sound effects when an event takes place.
In this video (objectives)…
- Examine our problem with destroying our GameObject and therefore destroying the ability to play our destroyed SFX.
- Use PlayClipAtPoint() to solve the issue of our AudioSource being destroyed.
After watching (learning outcomes)… Play sounds from objects which are being destroyed.
In this video (objectives)…
- Map out our workflow for determining how many blocks are in a scene so that we can know when we reach zero.
- Create level GameObject and script.
- Increment our number of blocks for each block in our scene.
- Introduction to FindObjectOfType.
After watching (learning outcomes)… Tally up the total number of blocks in our scene.
In this video (objectives)…
- Create a public method for decreasing total number of blocks when a block is destroyed.
- Use FindObjectOfType to access our level loading methods.
After watching (learning outcomes)… Load the next level when all blocks in a level have been destroyed.
In this video (objectives)…
- Use [Range] to create a constrained slider in our inspector.
- Add Time.timeScale to adjust the speed of our entire game instead of needing to play around with gravity and velocity.
- Hunt down an error by updating our other level with our prefabs.
After watching (learning outcomes)… Able to change the speed of our game using Time.timeScale.
In this video (objectives)…
- Create currentScore and pointsPerBlockDestroyed variables.
- Create a public method that adds to our score when called.
- Call the method which increases our score when a block is destroyed.
After watching (learning outcomes)… Able to increase the player's score when a block is destroyed.
In this video (objectives)…
- Create TextMeshPro text, import font, tweak till we're happy.
- Use ToString() to update our text field with our current score.
After watching (learning outcomes)… Able to display and update the player's score in the UI.
In this video (objectives)…
- Introduce the Singleton Pattern.
- Use DontDestroyOnLoad().
- Examine the Unity script execution order to see that we can use Awake() for our singleton.
After watching (learning outcomes)… Able to implement a Singleton Pattern to ensure that our score persists across level load.
In this video (objectives)…
- Inserted a simple fix for bugs we are seeing with the Singleton.
- Immediately set the game object to inactive and then destroy it.
After watching (learning outcomes)… Fix one of the known issues with the singleton not destroying itself correctly.
In this video (objectives)…
- Reinforce the public method paradigm we've been using.
- Fix the issue with our score persisting from game session to game session.
- How to rename a class.
After watching (learning outcomes)… How to elegantly reset our game session so that our score resets.
In this video (objectives)…
- Review how Instantiate() works, discussing method overloads and signatures.
- Create code for instantiating a particle effect when we destroy a block.
After watching (learning outcomes)… Able to instantiate a GameObject through our code.
In this video (objectives)…
- Getting schwifty with tags - understanding the what and why of using them.
- Creating an unbreakable block type which... doesn't... break!
After watching (learning outcomes)… Able to use tags to create an unbreakable block type.
In this video (objectives)…
- Create 2 variables we can compare - maxHits and timesHit.
- Implement a conditional statement to destroy block if maxHits is more than timesHit.
After watching (learning outcomes)… Create a simple system of multiple damage levels for our blocks.
In this video (objectives)…
- Create an array to hold our damage sprites.
- Change our sprite renderer depending upon how many hits a block has taken.
After watching (learning outcomes)… Change the sprite displayed for a block based upon how many hits it has taken.
In this video (objectives)…
- Remove blocks and recreate our playtesting level.
- Add code to provide a warning if our array is missing sprites.
- Remove the manual process for defining maxHits and link this to the array size of our sprites.
After watching (learning outcomes)… Add warnings to catch mistakes and remove one place we could make a mistake.
In this video (objectives)…
- What's our problem? Boring ball loops.
- How can we solve it? Adding velocity tweaks to our balls when they bounce into things.
After watching (learning outcomes)… Add velocity tweaks to our balls to stop them being boring.
In this video (objectives)…
- Discuss the concept of extreme tuning - why use it.
- Audit our current project for places that we can apply some extreme tuning.
- Rick does some extreme tuning.
After watching (learning outcomes)… Able to audit your project and apply extreme tuning to make your project rad.
In this video (objectives)…
-
Refer back to your player experience to determine how you tune your game.
-
Tune all of your game variables so that you're happy with them.
-
Ask a friend to playtest.
After watching (learning outcomes)…
Tune your game so that it matches your player experience.
In this video (objectives)…
- Create an if statement to test if we have enabled autoplay.
- If auto play is enabled, change the paddle's x position to the same as the ball's x position.
After watching (learning outcomes)… Able to lock the paddle to the ball using an autoplay toggle.
In this video (objectives)…
- Add extra levels so that you have at least 5 levels.
- Create a WebGL build and share to ShareMyGame.com
After watching (learning outcomes)… Finish your game and upload for the community to check out.
In this video (objectives)...
- Discussion about the endless loop issue.
- Public versus [SerializeField].
- What are messages and how are they called.
After watching (learning outcomes)…
Ben and Rick talk about a few issues that came up in this section of the course.
In this video (objectives)...
- Well done for the great creativity in this section.
- You can add to your project or push on to the next section.
After watching (learning outcomes)…
Onwards and upwards to the next section of the course!