
Unity GameDev Tutorial for Beginners: Brick Breaker Game
video description
Date: 2022-03-14
Related videos
Comments and reviews: 10
Thiago
Great tutorial! I started building my own brick breaker game before watching your tutorial.
The thing that I got stuck with is the bounciness behavior. My ball has a circle collider and bricks naturally have a box collider.
The behavior that I want for collisions with bricks is to add speed but don't change the angle, simply invert velocity X or Y depending on where the ball hit (sides or top/bottom).
And PhysicsMaterial2D kind of does that, except that it changes the direction if the ball hits the edge of a brick or if it hits two bricks at once (between them).
Do you have any suggestions to fix that?
reply
Great tutorial! I started building my own brick breaker game before watching your tutorial.
The thing that I got stuck with is the bounciness behavior. My ball has a circle collider and bricks naturally have a box collider.
The behavior that I want for collisions with bricks is to add speed but don't change the angle, simply invert velocity X or Y depending on where the ball hit (sides or top/bottom).
And PhysicsMaterial2D kind of does that, except that it changes the direction if the ball hits the edge of a brick or if it hits two bricks at once (between them).
Do you have any suggestions to fix that?
reply
RGB
My ball won't bounce back after colliding with the brick. It just ram them down in one swap.
PS.: Nevermind. I just put this on the OnCollisionEnter2D and it worked pretty fine:
void OnCollisionEnter2D(Collision2D other)-
--
if (other.transform.CompareTag(-Brick-))-
--
Debug.Log (-Colliding with a brick-);-
rb.velocity = new Vector2 (rb.velocity.x, -rb.velocity.y);-
Destroy(other.gameObject);-
--
-
reply
My ball won't bounce back after colliding with the brick. It just ram them down in one swap.
PS.: Nevermind. I just put this on the OnCollisionEnter2D and it worked pretty fine:
void OnCollisionEnter2D(Collision2D other)-
--
if (other.transform.CompareTag(-Brick-))-
--
Debug.Log (-Colliding with a brick-);-
rb.velocity = new Vector2 (rb.velocity.x, -rb.velocity.y);-
Destroy(other.gameObject);-
--
-
reply
Cyber
How can i stop the ball when a level ends? the paddle stops moving but when a level is completed the ball will just continue to move. One scenario I had happen to me is that I had 1 life left and completed the level, and while in the level complete screen the ball hit the collision trigger in the bottom of the game, giving me a game over screen.
reply
How can i stop the ball when a level ends? the paddle stops moving but when a level is completed the ball will just continue to move. One scenario I had happen to me is that I had 1 life left and completed the level, and while in the level complete screen the ball hit the collision trigger in the bottom of the game, giving me a game over screen.
reply
Ria
Longshot because I know the video is a few years old, but whenever my ball crosses the bottom collider it takes away ALL lives even if I change my total from 3 to 5. Ive doubled checked that UpdateLives is set to -1 and my GM script says lives += changeInLives so that its adding the -1 to that like you said.
reply
Longshot because I know the video is a few years old, but whenever my ball crosses the bottom collider it takes away ALL lives even if I change my total from 3 to 5. Ive doubled checked that UpdateLives is set to -1 and my GM script says lives += changeInLives so that its adding the -1 to that like you said.
reply
jesus
some important time stamps:
-movement script for the paddle-
4:20 - 9:32
-script for setting the left and right screen edges-
11:19 - 14:14
-setting the paddle collider-
15:44 - 18:05
-adding rigid body and collider to ball-
19:40 - 21:11
-force script for ball-
21:39 - 23:31
reply
some important time stamps:
-movement script for the paddle-
4:20 - 9:32
-script for setting the left and right screen edges-
11:19 - 14:14
-setting the paddle collider-
15:44 - 18:05
-adding rigid body and collider to ball-
19:40 - 21:11
-force script for ball-
21:39 - 23:31
reply
New
Really appreicate a nice, long form video where you explain the logic in everything you are doing. Im 45 minutes in and i feel more comfortable with code and unity than i ever have with any other videos ive watched. thank you so much for taking the time to make a video such as this :)
reply
Really appreicate a nice, long form video where you explain the logic in everything you are doing. Im 45 minutes in and i feel more comfortable with code and unity than i ever have with any other videos ive watched. thank you so much for taking the time to make a video such as this :)
reply
wajih
hey just want to say im stuck at the beginning with the paddel... im geting 19 lines when i click on c# but in your video its only 17 lines i tried to rewrite the code to the same as you.. but it dident work any solutions ? but i still love how you explain things :D
reply
hey just want to say im stuck at the beginning with the paddel... im geting 19 lines when i click on c# but in your video its only 17 lines i tried to rewrite the code to the same as you.. but it dident work any solutions ? but i still love how you explain things :D
reply
itech
Nice tutorial!!! One of the best of youtube!
I have a question, my ball keeps going horizontal all the time, and then i have to wait like 10 minutes, or more, to the ball change direction. Someone knows a fix to it? Thanks!
reply
Nice tutorial!!! One of the best of youtube!
I have a question, my ball keeps going horizontal all the time, and then i have to wait like 10 minutes, or more, to the ball change direction. Someone knows a fix to it? Thanks!
reply
slahser
I just finished my first commercial game that I am releasing on steam in 2 weeks, and every time people ask me about programming I always recommend this tutorial. First I completed and it is just amazing. Thank you so much!
reply
I just finished my first commercial game that I am releasing on steam in 2 weeks, and every time people ask me about programming I always recommend this tutorial. First I completed and it is just amazing. Thank you so much!
reply
AliciaHammond
that tutorial was AMAZING! the best i've seen so far. everything so clean, calming voice, in great pace, loved it! it really helped me with my uni project, thank you very much, i've learned so much!
reply
that tutorial was AMAZING! the best i've seen so far. everything so clean, calming voice, in great pace, loved it! it really helped me with my uni project, thank you very much, i've learned so much!
reply
Add a review, comment
Other channel videos















