How To Make Game Objects Bounce In Unity?

What are you going to learn?

Set the value of Bounce Combine to Maximum and our ball won’t stop bouncing at all
This is what you will learn

In this article, I will show you how you can make your Game Objects bounce. This is useful when you need to make a ball bounce off the floor, the walls, or the ceiling. Let’s see how we can achieve this in Unity.

The key step here is to use a Physics material and change the properties of it so that it behaves like a bouncy object. It is easier than you think.

Here are the steps —

Step 1: Add a plane and a sphere to an empty scene.

The plane represents the floor and the sphere will be the ball that bounces on that floor.

Position the floor and the sphere so that the sphere is on top of the plane
Position the floor and the sphere so that the sphere is on top of the plane

I also added a blue color to the floor. If you don’t know how to do that, you can check out my article - “How To Apply Color To A Game Object In Unity?

Step 2: Add the Rigidbody component to the Ball

Since we need our ball to obey the laws of physics, we will have to attach the Rigidbody component to it. Make sure the Use Gravity box is checked. We don’t want the ball to float in space.

Select the Sphere > Add Component > Rigid Body > Keep “Use Gravity” box checked
Select the Sphere > Add Component > Rigid Body > Keep “Use Gravity” box checked

Step 3: Create a “Bouncy” material

Right-click in the assets panel > Create > Physic Material > Name it “Bouncy”
Right-click in the assets panel > Create > Physic Material > Name it “Bouncy”

Step 4: Change the properties of the Bouncy material

Select the Bouncy Material > You should be able to view the properties of this material on the right-hand side i.e the Inspector panel. Now change the properties.

Set Friction to 0 and Bounciness to 1
Set Friction to 0 and Bounciness to 1

Step 5: Apply the material to the sphere

Now apply this material to the sphere(i.e the ball) in our scene.

Drag and drop the Bouncy Material into the Sphere
Drag and drop the Bouncy Material into the Sphere

That’s it. This step confirms that the sphere will bounce on our floor.

Step 6: Hit the play button

Our ball is bouncing now. Yayyy!
Our ball is bouncing now. Yayyy!

Bonus: You can also control the number of times the ball bounces. Try experimenting with different properties of the “Bouncy” material.

Set the value of Bounce Combine to Maximum and our ball won’t stop bouncing at all
Set the value of Bounce Combine to Maximum and our ball won’t stop bouncing at all

Great! 👏

Hopefully, you didn’t face any problems in any of the steps above. In case you did, comment below and I will help you out.😉

--

--

--

Product | Software Engineer(AR/VR) | Get 100+ AR/VR Resources — https://knightcube.gumroad.com/l/arvr-resources | https://linktr.ee/knightcube

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create a pouring water effect in RealFlow

Kotlin Mutable Map Write Performance

Kotlin: Conditions and loops

Amazon Elasticsearch Migration — Cross Account

What is the difference between CentOS Linux and CentOS stream?

Starting Your Journey in Coding: The Skills That You Actually Want To have

Figuring out Scala functional programming libraries

Community Update 2021/07/19

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rajat Kumar Gupta

Rajat Kumar Gupta

Product | Software Engineer(AR/VR) | Get 100+ AR/VR Resources — https://knightcube.gumroad.com/l/arvr-resources | https://linktr.ee/knightcube

More from Medium

The Ultimate Guide To Start Making 3D Video Games

Analysis of UE5 Rendering Technology: Nanite

RANDOMNESS IN GAMES — THE EQUILIBRIUM OF ITS USE

Face detection in AR for beginners