How to make a Video Game in Unity - COLLISION (E05)
HTML-код
- Опубликовано: 27 апр 2024
- What happens when stuff collides? Let's take a look!
● Download the Project Files: devassets.com/assets/how-to-ma...
❤️ Donate: www.paypal.com/donate/?hosted...
····················································································
This video is part of a mini-series on making your first game in Unity.
····················································································
► Join Discord: / discord
♥ Subscribe: bit.ly/1kMekJV
● Website: brackeys.com/
● Facebook: / brackeys
● Twitter: / brackeystweet
····················································································
► All content by Brackeys is 100% free. I believe that education should be available for everyone. Any support is truly appreciated so I can keep on making the content free of charge.
····················································································
♪ Baby Plays Electro Games
teknoaxe.com/cgi-bin/link_code...
Anyone notice how as the series goes on there is less and less views because people give up but great videos I love them
It's like with any other series.
I don't even know why I'm following this series
if you a have a bit of programming experince this is actually that hard
that's what i noticed
that'ts a big mistake don't give up! You need to have fun programming.
Hope this series booms during quarantine!
It did.
mhm, it definateley did
I was like hmm I should really start lerning how to use unity.. TIME FOR LATE NIGHT CODING BOI'S!
yah... i've gotten here in .5 days cuz of all the time on my hands!
did u get this to work, I haven't been able to and I'm totally stuck
Just want to say a shout out for Brackeys being so happy every video! It's cool to see someone so happy about passing on their skills to others! #Hero
I like how he explains things step by step. I mean REALLY step by step. For exmaple I didn't what the tag was for in other tutorials, they just glanced over it but this guy really explains things. Now I have a better solid understanding of unity.
Hey, anyone who sees this and you're thinking about giving up, DON'T. You are halfway through and it gets easier and more fun from here. I promise all of the hard work pays off.
I saw this at the perfect time ;)
omg this takes a lot of time
Yeah, your right, and when you finish here til now (like i am) i kinda figured how to write some code for myself!
@@mr.mystical9776 Omg thank you so much. I want to end but you gave me the power to do it and i did it
@@latrys886 Your welcome!
I just want to quickly comment whilst in the middle of this playlist. Attempting coding has always been a daunting task, but your videos explain everything really well and it is slowly becoming a lot more clearer to me. Thanks. :)
anyone realise that all the ads he does are to help the comunity not for personal gain
this is how to distinguish good content creators from the bad ones.
true legend.
for anyone having this problem if the error shows up and says null reference exception that mean that you have to drag player movement into the collision scrip that's what worked for me. the part I missed was at 7:03
Ahaaaa thank you
thx!!
kai Lange-dei thanks brooooo I can’t thank you enough
Thanks so much I almost gave up until I saw this. So frustrating but incredibly rewarding once you finally figure out what's wrong
@@BreeingIan hey pls help can u elaborate more im rly smol brain so cudnt understadn hv same error tho
You look like the happiest man I’ve ever seen all the time, I love it
Elegant. Clear. Concise. Succinct. Exemplary.
Himself 0 dunno what half of those words meant but i agree!
B
Ah. Wine
Shahriyar Alam Don't spam.
big b o i words
Hi Guys,
For those player who are unable to stop after the collision, you may refer to 5:43.
Check the tag for all of the "obstacle" whether is it the same on your scripts.
Hope this might help you guys!
Have a nice day :)
I still don't get my object to stop please help :(
you saved my day..
♥♥♥
Don't know why the tag created previously disappeared. Thanks so much anyway!
After thinking and being "scared" of starting learning coding and trying to create a game, I started yesterday and downloaded unity - and so far i am having a blast and thats thanks to you, brackeys
wonderful tutorials so far, great explenations, and perfect "from scratch" tutorial/lessons.
I have done a Tutorial, ,besides the "microgame" from unity, but that was way to "specialized" and adding to an existing project, which still did not cover the real basics of unity.
much love!
what did you do
@@ok5183 true what did he do? 🤷♂we will never know
he explains things fast into the point directly and keeps everything simple , can't imagine something better
i love how the videos are short and straight to the point like small baby steps
Thanks. This is the tutorial series i've been looking for a long time. You explain everything clearly and smoothly. You've earned a subscriber.
Good job to those who have kept going through the tutorial. You are a true champ, and I hope to see you watch the next one. Don't lose motivation.
these videos are awesome. Been learning a bunch of new languages over the past few months and this is actually helping me with c# as well. It is so cool because I always wanted to get into game development. Still at novice level but it has been so fun learning all these new things both in my classes and on your channel and many other channels. Thank you for the videos!
I've been using this tutorial to make my first ever game in unity in like one night and its going great!
I made a speed ramp using the information from this video. My game is starting to come together. Thank you for giving amazing free tutorials!
I just discovered a world i love and i didnt know, i guess i will have to change my major😂, btw im doing everything exactly as he is doing it but i have so many different ideas for it but i dont know how to execute them, i guess i have to stick to what he is doing till i actually learn
Thats what i am doing. I think we need to just copy him, and after learning it, we can advance our self, because then we have a lot more experience we can use to put something together, tyhen it gets easier to watch harder turtoials
Keep on moving bro and you'll succeed
Duplicate a scene to give yourself a playground of sorts and hack away at it. Google whatever you don't know. Then, come back to Brackeys for more of these amazing vids!
check out Unity c# documentation
I am also doing this I have an idea to make a sorta 3d version on the no internet dinosaur game it's likely been done already but I just want to do it myself to share with friends
this mans intros are the happiest things ive seen in my entire life
lmao ikr
still helping and relevant 4 years later thank you!
I started game development with this project, one year ago exactly. Meanwhile I made a 2D platformer game for my school project, and game development is what I love to do. Brackeys taught me the basics, and I can´t say thanks enough. Today I will finish this little cube game, because I want to work with 3D as well. Never give up people.
Please make longer episodes when you come back from your vacation, I hope you have fun!
Inter Flash yeah it's too short
Longer and Advanced tutorials, Please!!
I never said to get rid of these short ones, I just said I'd like to see longer and more advanced ones. Maybe some kind of procedural (dungeon, world, quest, etc) generation?
it's for people who are scared by longer videos, like me. I like this piece meal method. I believe have other videos that are longer (not sure though).
Royal Tyger's Media but he makes one video of this series once per week so the solution is to make more videos or make the video longer (sorry for my bad English)
* yellow cube hits black cube *
"Houston, we have a problem"
You sir, are colorblind
@@dio1647 i just colored mine different
Wow, that's exactly how I colored mine
I dont understand
Okay thats so wierd I put the exact same text as mine as well!
Got unity 2 days ago and Brackeys is making it easy to learn c # and game design. thx Brackeys
funny how Brackeys have literal free tutorials on unity and other things have like 300 per year, keep up the great work Brackeys!
When you spell Obstacle "Obstacal" accidentally in the code and it takes you half an hour to figure out that fault:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
hey, I bet that moment when you finally realized your mistake felt GREAT!
@@THEspindoctor84 i started this tutorial series 2 days ago and dont have any other coding exp is it normal that i dont understand the codes but just copying them seeing results for now
@@emoshimo9332 I'm not an expert, but I would definitely say that that is normal. But starting here seems a little bit advanced for someone with literally no coding experience. Its generally not good to just copy code and see the result, without understanding the concepts. I would start with a nice long FreeCodeCamp video, like this one on C#. ruclips.net/video/GhQdlIFylQ8/видео.html
Once you watch that, you will understand some of the basic syntax, and this might make more sense. I also recommend books, since I believe they tend to explain concepts better than videos. I am currently using "Learning C# by Developing Games With Unity 2020" by Harrison Ferrone. Its very good for someone with little or no coding experience.
@@THEspindoctor84 thanks sir that will help a lot i really appreciate your time and effort i can say you made my day :)
Lmao
This series is becoming Addicitive!
This series aspires me so much to go forward in game design thank you ❤
remember to persevere through all the "road blocks" and you may be able to make an amazing game. hope you have an amazing day
I'm so grateful for this series!
For those who are wondering on how to get the collision system to work, I found out how to fix it,
The code:
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public PlayerMovement movement;
void OnCollisionEnter(UnityEngine.Collision collisionInfo)
{
// Check if the player collides with another object
if (collisionInfo.gameObject.CompareTag("Obstacle"))
{
movement.enabled = false;
}
}
}
Make sure you remember to link the PlayerMovement script to this script through unity, in the inspector.
I hope you've found this helpful🙂
Thank you so much! Was stuck on this for so long!
u my god
Me who's misspelled my tag: *Changed everything then realized something-*
Thanks a lot bro....i was stuck too
+rep from Russian community
I am so thankful for this video series!!
This is just so great i already learned so much and also feel like i really understood it to a level where i am able to program my own little games and they actually work :) i am so happy
I'm from Ukrain and don't speak English but watching these videos I'm was amazed because I understood him very good, and I'm so grateful for your work (11 videos "How to make a Video Game"). Thank you man!!
Hi Am Russia Man XD
сало сало сало Українске сало
Then how did you wrote this comment..?
@@digviaysingh480 I wrote this comment whith "Google translate" and I'm know English, but some bad for free understand these videos.
YOU ARE THE BEST RUclipsR! Too sad you no longer produce more content but thank you so much, I actually liked coding thanks to you so it is very inspiring :)
Dude you saved my life. I wanted to make games and stumbled upon this video I started and downloaded everything. But when it came to the first video i couldn't make the camera face the ground so i gave up and deleted unity. but 3 days later i downloaded it again an came back to your channel. And i finally figured it out. I just had to rotate it bro. And i'm still going on this and Thank you bro you're the best. ;)
"displaying a message in console isnt that exciting " *me cheering cuz it took me 2 days to do t properly*
The same mine was working perfectly about 5 Kim’s ago but my unify is like broken cuz stuff never works for me and about 2 mins ago I was able to move and turn my cube and stuff like a game bug then I added the script for collision and it just stopped moving when I clicked play 😭I hate unity
To anybody who thinks that their player is "stuck" as soon as it hits the ground.
I just fixed my code by making sure the semicolon ( ; ) is in the correct place. I axidentally put it after : if (collisionInfo.collider.tag == "Obstacle") ;
Thankyou so much
Helped a lot. Thanks mate
When I do that, it gives me a compile error, it won't work unless I have a semicolon there, so I don't know what to do
Saved me time, thanks
Assets\Playercollisions.cs(5,8): error CS0246: The type or namespace name 'PlayerMovement' could not be found (are you missing a using directive or an assembly reference? how do i fix this please tell
the best getting started tutorial ever in unity hope you came back one day or once a while
Your series is awesome dude I will watch each video of yours atleast 2 times and then will move towards making a basic game due to which I started learning unity and it was a little difficult to make in frameworks like flutter flame which I was recently using
Everyone who is having problems do this!!!
Chang it from, void OnCollisionEnter (Collision collisionInfo) TO void OnCollisionEnter (UnityEngine.Collision collisionInfo) in your script
thank you sooooo muchhhh NichobeastMode i was stuck doing this for like 2 days and i was literally gonna stop this thing then i tried ur thing and it worked out
thank you once again dude
thank you
I was following one of his later videos and accidentally deleted my scripts so I had to rewrite them with all my objects and shit still there. Now whenever I try to write the collision script it won’t work any more even when I tried to change it to the way you said when it worked before. Im infuriated
Thank you so muchhhhhhhhhhhhhhhhhhhhhhhh
Thank you!
i love this channel. thank you for these amazing tutorials
Awesome tutorials! With the script i learned how to turn of gravity to make it almost seem like the crash is in slow mo!
1. I really love the series thank you so much
2. Not important but if you are watching through them now its so unsatasfine if the backround and your position is the same but your T-Shirt changes
This is my third time coming back to Unity, and honestly, I'm astonished at how simple this stuff is in hindsight. I have experience in the kids coding site called Scratch, and frankly it's making this so much easier to digest. I mean, I really get this stuff, and I'm feeling so confident in it so far!! I think the best part for me to, is I have an understanding I don't know that much, and due to this, I got a good grasp on how big my scope is... But! I'm confident I can do something that'll be just fine! I'm just so happy for this tutorial, thank you, Brackeys!!!
Did everything come out well for you??? Because it didn’t for me it had so many problems in this part and now i just messed up all the old parts 😢
@@masterjokerx549 What's the problems you had? I can do my best to help!
@@_zerohour_ omg you answered even tho your comment is 6 months old
@@_zerohour_ i kind of figured out the problem and it was that i don’t have a dotnet which i don’t know what that is since I’m new and after downloading multiple dotnets in unity itself as extensions and outside of unity i still have the same problem so it didn’t fix anything
@@_zerohour_ i had the player movement script functioning normally until i added the player collision script and the it started popping up and saying that my player movement script isn’t valid
The unity vid ever plz make more of these tutorial.
its way better than udemy 300$ courses
Thank you for all your tutorials, they are very helpful.
Im very late and you probably won’t see this but damn, this series is so great and helpful!
Thank you so much, this series is great!
brackeys: We hit an obstacle!
me: AAAAA MY LEG
this is actually so fun to just mess around in and learn, thanks so much! :)
Yo man fantastic tutorials they are so informative and I just love them so much!
For anyone confused on why you wont stop moving and get an error message as well possibly use this code (replase scr with your PlayerMovement script name, and also place playermovement script in collision script)
using UnityEngine;
public class PlayerCollision : MonoBehaviour
{
public scr movement; // A reference to our PlayerMovement script
// This function runs when we hit another object.
// We get information about the collision and call it "collisionInfo".
void OnCollisionEnter(UnityEngine.Collision collisionInfo)
{
// We check if the object we collided with has a tag called "Obstacle".
if (collisionInfo.gameObject.CompareTag("Obstacle"))
{
movement.enabled = false; // Disable the players movement.
}
}
}
OMG THANKS SO MUCH
thank you! it didnt work for me and this saved me
"We can use the dot to assess in to different infos, stuff like the Impact Foursome.." - Brackeys ;)
im having a problem with this as the dot doesnt show any info in visual studio code
They didn’t say that ok, this is a joke
@@lewel3788 it was 3months ago and no i had exams
i didn't think of disabling the script altogether, that's a pretty good idea! if all of the inputs regarding movement and interaction are in there, that's a great solution. i think i will do it the same way when i make my own game. thanks!
I am loving ur series ik it is old but really its amazing!
If you’re having issues at 4:20 rename the script to something other than “Collision” , it confuses unity and causes errors. Also change the 5th line to “void OnCollisionEnter (UnityEngine.Collision collisionInfo)”
now it just outputs untagged in console
Brackeys: We're going to delete both the start AND the update method.
*Wait, we're deleting all of it?*
*Always were going to.*
At this point somany ideas are floating on my mind for games that I even could code.....I already now coding but you teached me some more tipps like AddForce or else. I just want to say THANK YOU FOR THE MOTEVATION
this youtube series helped me get into coding
OMFG - idk if i should be so hyped but here are some comments saying it doesnt work blablabla...
im an absolute beginner, and somehow - idk how in 15 minutes i made it work
Also im happy to help, just copy and paste this!
using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public PlayerMovement movement;
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false;
}
}
}
Oh dude thank you
In my game there are these messages:
The referenced script (Collision) on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'Player') is missing!
Can someone help me?
@@nathinoon1503 Did you copy past the script of the guy right above?
@@nathinoon1503 Oh and in your console, double click the error message, it can lead you where the error is
@@nathinoon1503 and did you create the scripts and "put" them on the right thing? like for this one it s on the player
Still, love how he says "Wednesday"! XD
You look so happy it's like you REALLY love this. I want that.
it's so easy to follow along!
Brackey you are a Legend!!!!!
Im a 10 yro Kid, and i imagened to create a game, i thought it was hard but with this, it is so much better! Thankyou!!!
Don't show your age online, No one cares about you.
Good😊
10 yro dont use comas in good places like "U"
What kind of game will you create?
@@chickeninabox you dont have too be mean -_-
It displaeys an error when i declare the public playermovement movement;
Says that
Unexpected symbol public
This went perfectly well
we love you, you are the best teacher ever Brackeys!
If anyone is having issues with the movement.enabled = false line, replace it with GetComponent().enabled = false;.
Thankyou so much
still not working, thanks for the help tho
@@loganmcghee2529 Go into your slippery physics and change the values dynamic friction and static friction to 0.25. I had a problem where it clicked off but the movement didn't stop. It's possibly a physics problem that noobs like myself don't see. :-/ Took me an hour looking around to figure this one out. Anyhow, hope this helps.
p.s. you do this in the Inspector window.
@@Nakasasama thx bro I am stuck on these error from last 4 days I am getting frustrated thx bro again
I've been trying to figure out how to fix this for days, thank you so much
you deserve more subs
yeah, and he deserves more patreons
Jesil ti to balkanac
Love it, hope i survive, its like my 10 attempt in unity and for first time i have done something and learnd, thank you
Hi man, im currently watching your videos and.. eventho it's been 7 years from posting I really hope this message will reach you. First of all thank you. Thank you so much for helping me making my dream true. I will make sure to show you my gratitude by supporting you on patreon as soon as I can afford it. Second, your videos are so precise, so perfectly described that even a noob like me understand everything perfectly. Thank you so so much!
These are great, but I still haven't revived an answer to a question. I have been asking for a long time. Can you make it so the map random generates and the game is endless
You can. Look up Procedural Generation. Sebastian Lague has a series on it, and there are plenty of Unite talks on the subject (e.g. procedural generation in Sir, You are Being Hunted). The Procedural Generation Wiki and the website donjon (donjon.bin.sh/) have some good material that you should look at.
I was thinking about trying to implement this as well. My idea was to have the ground keep extending on the z axis a the same rate at the player moves forward until player == collision
As the other guy said, you guys are talking about procedural generation. It's the idea of randomly creating maps based on preset stuff. So it can take 10 different obstacles you created and will randomly generate them in different configurations. Could be set to do this indefinitely.
i have a question. When we put Debug.Log statement whenever two things collide and we add an obstacle, shouldnt the obstacle also collide with the ground and add a statement in the console?
since the script was attatched to the "player" cube, it only produced a message when the player cube collided with something. if you were to attatch the script to the obstacle too, it would have produced the message, too.
Best unity tutorials I will be using thank you for making this
Thank you for your videos. You did a great job. You helped to so many people.
if you're back
could you make a video of how to make a game like piano tiles
lol my brain read it as 'if you're black' at first
i will comment every year on this video and share my game dev experince
2022---
i am new in unity trying to learn 2d games
these videos are really helpful, thank you so much for making them! :D
just for fact, tags are not an acurate way for managing collision nowadays due to some reasons... but for sake of simplicity, it works.
also, great tutorial!
7:47 it kept saying that playermovement wasnt found (checked the spelling about 10 times and the squiggly brackets where in the right place
Me too same problem
i had the same problem twice but i forgot to put the semicolons in the right place XD
I have the same problem, pls did you figure it out?
write "using System.Collections.Specialized;" at the very start of your code
@Csak Dolgok This! I’d spelt my initial script without caps.. then tried to do this one with it. Was pulling my hair out
For me it worked when i used following:
void OnCollisionEnter(UnityEngine.Collision collisionInfo)
{
if (collisionInfo.gameObject.CompareTag("Obstacle"))
{
Debug.Log("we hit annother sphere");
}
i still cant figure it out
Nevermind! It kept not working 'cause it would make me put " ; " instead, but you can just replace it with { } !
martigpg xd go back to your code and look for stuff that is red underlined. if you can’t find the problem with the code can you send your full code?
It's Beautiful.
i've looked at this for 5 hours now!
This helped me!!!
Thank you for this amazing tutorial it is really fun working on this project
nice series
I can finally understand programing
For anybody stuck at 7:00 who's PlayerMovement isn't working, just remove all caps and type in playermovement (all small) instead. It'll work just fine..
Thank me Later
MY CODE though:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playercollission : MonoBehaviour
{
public playermovement movement;
void OnCollisionEnter (UnityEngine.Collision collisionInfo) {
if(collisionInfo.collider.tag == "Obstacles"){
}
}
}
Thank you bro 👍🏿
Thank you
Ty
thanks you
@@SlothCGaming I am still getting error with that also
3:59 how to set that in VS ?
The thing that shows you what that code do. Please help
Yep, wondering as well.. :/
Did you guys figured it out?
@@user-te9vx8bx8y Did you figured it out?
@@cloveri1310 IIRC, I installed an older version of visual studio and had to completely wipe my version and install a new one. Make sure to delete any files that has to do with VS. Also, check the place you download.
I know you have just stop uploading videos but still you have helped me a lot and that is why i am commenting.
so far I am able to follow the series.
although last time I made some errors which were hard to resolve.
Hello, I receive this error: Assets/PlayerCollision.cs(5,9): error CS0246: The type or namespace name 'PlayerMovement' could not be found (are you missing a using directive or an assembly reference?) . Can someone help me?
Edit: The reason you have this problem is that you must have misspelled PlayerMovement in one of the scripts.
This is happening with me also😫😫😫
thank you for editind your comment
It says cannot convert string to bool errror what to do??
write without capital, worked for me
@@rodrigopermok thank you
OMG I WAS STRUGGLING FOR 7 HOURS WITH THIS VIDEO AND I JUST REALIZED THE TAG ON OBSTACLE WASNT OBSTACLE
YES ME TOO OMG
OOOOMG me2 thanks a lot xD
F
bro this is awesome stuff right here-- game development is cool
i just went back to this because i needed to know how to check for collisions, this can be usefull for jump mehcanics, so i did!
now i can see if im grounded without a groundcheck
me: why is my collision not working
brackeys: you need to add a rigidbody for this to work
me:FUUUUUUUUUUUUUUUUUUUUU
what?
Will you ever do a tutorial for a 3d platformer?
www.reddit.com/r/unity_tutorials/comments/25dii5/is_anyone_interested_in_a_tutorial_series_on_how/?ref=share&ref_source=link
these videos are amazing and really informative, thank you,
Great tutorials, though I am not doing any work as I go. Perhaps that is a mistake, but I can always come back. I just want to see some basics laid out in a comprehensive way, and these videos are definitely doing that. Also, nice smile! :)
Somehow the PlayerMovement reference did not work, I tried everything but it did not work so I cannot continue
Had the same problem, you probably messed up with the name in the public class
@@Pandadulol thanks
write "using System.Collections.Specialized;" at the very start of your code and make sure that you wrote the name of YOUR script dont just copy PlayerMovement write the name which you gave to your movement script.
{PLEASE READ}
I did everything right but when I hit play and the cube hit something else. The Player Movement didn't stop ;[
i am having these problem too!
I had the same problem. I had misspelled OnCollisionEnter to onCollisionEnter. Use capital O and it should work great =)
still have the problem. :(
me too [(
did you guys figure it out cause im having the same problem?
That feeling of accomplishment after you fix an error is like no other
you are right my friend. Just spent nearly an hour trying to figure out why I wasn't getting any console debub messages. I had accidentally deleted everything and the script was weird.
@@trevorstechcorner8361 me too how did u do it
From a programmer perspective that did comp. science in high school / is doing in university, this is not that hard to understand :D Love your series