Beginner Godot Tutorial - How to Make Pong with AI

preview_player
Показать описание
Learn the basics of Godot by making a pong game from scratch.

This tutorial will use static collision shapes, area2d as well as character body 2d nodes to handle the different collision types. The played paddle is controlled with up and down keys while the enemy paddle has AI control which follows the position of the ball.

Рекомендации по теме
Комментарии
Автор

Allen went from beginner to wizard 🧙‍♂️ mode! will definately practice this one. thanks for the dinosaur 🦕 infinite runner 🏃 game tutorial. my best so far.
keep it up man

MahmudShuaib
Автор

I was making pong by myself and got stuck on the collision layer part. I can say that after watching your video, it finally clicked how it works. Thank you, good sir!

origamiprince
Автор

I tried doing this using more of Godot's built in physics. i used characterbody2d for the paddles and ball and it's such a huge number of minor pains. At certain angles the ball get stuck on the paddle and can even push the paddle. I'm going to rework mine a bit and use some ideas from your game. Thanks for the video!

FayteZephyr
Автор

can't you please explain the concepts you're using? It's not really a tutorial for beginners, if you just pull out as many code terms and nodes as you can, as fast as you can, even if it ends up being a simple way of coding the game. No one will learn from this unless they're already familiar with Godot enough to not need this video.

lauridsen
Автор

Thank you so much for doing this tutorial!
I tried making games a few months ago, but ended up choosing a project that was way too hard for a beginner. I'm trying to start making games again.
Since it was almost impossible to win the AI in this game, I added 5 different levels of difficulty, which changes the speed of the CPU paddle every time that the player gives a click in the game screen. The level is displayed in another label at the top of the game screen.

vitorrenato
Автор

It's nice, but not a single why question was asked or answered, just do this and do that, having the project file would save me 10 min of my life.

cembaturkemikkiran
Автор

the line ``` position.y = clamp(position.y, p_height / 2, win_height - p_height / 2) ``` doesnt seem to work either it wont let my paddle move on the top half the the board im stuck with the middle as my top height

LilFishowo
Автор

If anyone is still having issues with clamping the paddles within the viewports, try using global_position instead of position. I'm not exactly sure whats causing the position to not work, but after a lot of debugging, seems like the problem isn't the values being ignored so I tried global instead and it worked.

assadnewar
Автор

Thanks for your tutorial, I just successfully made a cursed game that when I press E on my keyboard, I add myself a score, when I press Q on my keyboard, the y position of my paddle sticks to the y position of the ball!

jacetang
Автор

Finished the project. Played the game. Lost like 5 in a row before I scored. So I edited the player ColorRect and CollisionShape2D to equals the size of the Left border. After 20 bounces, I can't see the ball anymore :) but I usually win in 5 bounces.

aopen
Автор

thank you so much for this, this was the 3rd tutorial i found to do this and this one is the only one that worked for me

VicenteCarretero
Автор

Hi, thank you for the tutorial - had a lot of fun working on this!

Just a quick question: is there a reason why the Player's control and the CPU's AI are scripted within '_process' instead of '_physics_process'?

slothjohnson
Автор

Nice video!
Any reason for not calculating the move direction of the CPU with this simple calculation? I know next to nothing about game dev so I am not sure if this could end up hitting some weird edge case?

func _process(delta):
ball_pos = ball.position
dist = position.y - ball_pos.y
var movement_speed = get_parent().PADDLE_SPEED * delta

if dist > 0.0:
position.y -= movement_speed
else:
position.y += movement_speed

position.y = clamp(position.y, p_height / 2, win_height - p_height / 2)

tyrtz
Автор

I didn’t understand anything but, yeah that’s a good pong game

TrueMayo
Автор

Thanks man this is exactly what I was looking for.

BirkinIdk
Автор

Realy enjoying your tutorials bro cheers

tedmosby
Автор

How would you make the AI less precise? (i.e. how do you stop it from making perfect shots every time?)

MaximeVerstraeten
Автор

As beginner my Head is smoking now, but I got a pong game, I guess I'll stick to making graphics.

TheySchlendrian
Автор

Thanks! Now i can make my first game! (With actual coding)

Cacodevidro
Автор

I find the Godot editor very pleasing to use as opposed to Unity editor. I always do everything in code anyway so I'm not very familiar with all the built-in functions in the Unity editor in the first place

Koski_Sampo