How to make Pong in Unity (Complete Tutorial) ๐Ÿ“๐Ÿ’ฅ

preview_player
ะŸะพะบะฐะทะฐั‚ัŒ ะพะฟะธัะฐะฝะธะต
Learn to make the classic 2D arcade game Pong in Unity. Pong is a table tennis-themed arcade video game, featuring simple two-dimensional graphics, manufactured by Atari and originally released in 1972. It was one of the earliest arcade video games; it was created by Allan Alcorn as a training exercise assigned to him by Atari co-founder Nolan Bushnell, but Bushnell and Atari co-founder Ted Dabney were surprised by the quality of Alcorn's work and decided to manufacture the game. Bushnell based the game's concept on an electronic ping-pong game included in the Magnavox Odyssey, the first home video game console.

0:00โ€‹ - Introduction
0:57 - Project Creation
1:55 - Scene Setup
15:49โ€‹ - Player Paddle
27:22 - Ball Movement
37:20 - Computer Paddle
48:26 - Increasing Speed
57:17 - Scoring
1:06:10 - UI & Cleanup
1:17:26 - Outro

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยญยญยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยญยทยญยทยทยทยท

#unity #unitytutorial #gamedev #unity3d #unity2d #gamedevelopment #indiegame #indiedev #madewithunity
ะ ะตะบะพะผะตะฝะดะฐั†ะธะธ ะฟะพ ั‚ะตะผะต
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
ะะฒั‚ะพั€

Small chance this will be seen
for those of you using newer versions of the unity editor that use "TextMeshPro"
in order to change the text you will have to use the TMPro library and make your text variables be "TMPro.TMP_Text" instead of "Text"
then you can drag your TMP's into their corresponding places in the game manager object

Criticalrror
ะะฒั‚ะพั€

I've followed quite a few Pong Tutorials on YouTube now. Some were okay. Some I had to quit because they weren't well enough explained or had other issues.

This one was by far the best. I like your calm, logical, almost OCD-type of explaining and showing everything in detail and cleaning up the code.

I learned a lot just from this single video and feel encouraged to program my first game now. Thank you so much!

MrMundharmonikah
ะะฒั‚ะพั€

This has gotta be the best tutorial ive seen for unity, so easy to follow and your content is insanely high quality. Keep it up!

kwipxd
ะะฒั‚ะพั€

Second one I've followed, after Snake, going to go through each one. I learned a lot from this and appreciate what your doing. I feel like these smaller games help me to understand the more basic principles. People ask for tutorials on complex games but if they learn how to code a bunch of simpler games, take notes and apply the principles on a bigger scale then eventually they will be able to work these larger ideas out themselves.
Someone mentioned Bomberman and I think a Nes style bomberman game could be a really cool fit with the other videos. Keep up the good work and thanks for what your doing!

spacekris
ะะฒั‚ะพั€

Hi! I just finished this tutorial, and I wanted to come down here to feed the Youtube algorithm for you! As someone who's just started using Unity and had essentially no prior knowledge of coding, I found this to be a fantastic way to learn and practice both. I've subscribed and will definitely be checking out your other videos, thanks a ton!

reubenoakley
ะะฒั‚ะพั€

TNice tutorials is one of the best tutorials of ANYTNice tutorialNG that I've ever watched in my life! Thank you so much!

hilmansantika
ะะฒั‚ะพั€

obsessed with soft design now and more obsessed with cool scales Nd stuff.

kylebelonoac
ะะฒั‚ะพั€

Bro thanks for this tutorial, Its my first game that I creat in unity a you did a very googd job๐Ÿ‘Œ

jeremyadriel
ะะฒั‚ะพั€

AWESOME! Best game development tutorial series i've ever seen.

tayfunyirdem
ะะฒั‚ะพั€

Great tutorial! It really helped me out! I'm completely new to programming, and I've started and stopped Unity several times in the past because I just couldn't get my head around it and coding. Thanks to you I finally finished a project!

ohmygigglez
ะะฒั‚ะพั€

Thumbnail got my expectations high, thought it was the usual ping pong across a table.

cool-aquarian
ะะฒั‚ะพั€

Great tutorial!

Not only the tutorial itself is made with some quality, but the guy also takes some time to explain everything in detail. Looking forward to future videos :)

Thanks!

rdlzexx
ะะฒั‚ะพั€

Pong completed yesterday. Tutorial was very clear for beginner like me ๐Ÿ‘ I even managed to create player 2 paddle script and replaced it with computer script today, can now play with a friend. Keep up the good work! next up Asteroids ๐Ÿš€

uniKorn
ะะฒั‚ะพั€

Incredibly useful content. You deserve views.

maxriley
ะะฒั‚ะพั€

An enhancement you can do is to have the computer play against itself. You'll probably have to adjust the speed of each paddle so they're not so evenly matched (maybe by using a random speed) but all it takes is a minor change in the ComputerPaddle script.

In the FixedUpdate method rather than determining if the ball is moving to the right (and thus it's moving towards the computer paddle so act accordingly) you can determine the direction of the ball relative to the paddle. Then you can act based on that instead, otherwise if you use the system as-is, the computer paddle will just sit idle at the center when it's on the left side of the screen.

So instead of checking if(ball.velocity.x > 0f) you need to determine if the ball if moving towards or away from the paddle. This is pretty easy using the dot product of the relative velocity and the direction between the two objects.

// calculate the direction from the ball to the paddle using the position of each object
Vector2 ballDirection = transform.position - ball.transform.position;
// calculate the relative velocity between the two objects
Vector2 relativeVelocity = ball.velocity - rigidbody.velocity;
// calculate the dot product of the two
float dotProduct = Vector2.Dot(relativeVelocity, ballDirection.normalized);
if(dotProduct > 0)
{
// ball is moving towards paddle
}
else
{
// ball is moving away from paddle
}

Now you can adjust the paddles y position accordingly regardless of where it is on the playing field.

PS YouTube code comment and my brain syntax may be wrong

Enjoy!

occularmalice
ะะฒั‚ะพั€

Blakey Don't stop making soft. I wished I started as early as you. You have a lot of years to learn!

sofiaanabela
ะะฒั‚ะพั€

Having not seen the entire tutorial, it may be you address what I am about to comment on :) First of all, what a great series... I do however feel like in this the collision between the bats and the ball is wrong. In the original game the ball would always be sent back based on where on the bat it hit. So if the ball hits on the top of the bat, the ball will bounce upwards no matter what direction it has when it collides.
Here it seems it is entirely a standard reflection you calculate. So the ball will always move around at the same angle in your version, and as a player you are not able to send the ball back from where it came.
When I made Pong a couple of months back I defined a circle with a given radius (Still using the bats box collider as a trigger of a collision, but not reflecting), and then sent the ball back using this circle construct. Like if the bat was a circular curve. While I don't have the original game, it more close resembles what I see in videos showing the original.

HKragh
ะะฒั‚ะพั€

It's great that there are people like you.

jesusbarrios
ะะฒั‚ะพั€

Thanks for the tutorial, it's much faster than any other method I came across.

raihanhossan
ะะฒั‚ะพั€

Yes, I build my First game in Unity. Thanks for Explaning there is so mutch to learn. ๐Ÿ˜ƒ

grandsuzuki