Hello everyone! I've addressed this a few places (we talked about it in one of livestreams) but I probably haven't been clear enough to people who don't watch all the videos :) I've decided to focus more on standalone videos and smaller series. The reason for this is that I found that both the Tower Defense and the Multiplayer FPS series were getting too long which meant that only a very small fraction of the people who started watching actually got to the later videos. And this is a shame because a lot of the videos covered later in the series aren't harder to understand than the first ones and might be just as important. So instead I want to create videos that can apply to as many games as possible while still tackling some of the more advanced subjects. I think the Scope, Bullet Time and Volumetric Lights tutorials are good examples of this because they both cover subjects requested for the FPS and Tower Defense series but in a way that makes it usable to people working on other games as well. On top of that I had been getting request for a looong time to remake the Make a Game course because it was getting outdated. So I thought this would be a good opportunity to create a smaller series for beginners. I think overall since I started this new approach that the comments and feedback has been way more positive and the videos are getting way more views on average. I've also found that I have way more fun creating videos this way because it can be much more varied. I hope you guys understand and I'm just excited to bring you new interesting videos - Especially once we wrap up this short series :D Thanks for being awesome!
Nice :) Brackey , can i ask you about your Pc specs because i noticed that game development on your PC is a lot faster than mine. I will love to know about that ...
I wish we could add tags to the video so it would be much easier to browse through them and go directly to where we want. I notices you try to help with this by naming your videos accordingly though.
BUG FIX: For all of you who got an exception "The namespace '' already contains a definition...": Check if you have some of the script files in the Assets folder as well as in the scripts folder. If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder. This might have happened if you had the scripts open while moving them to the Scripts folder. It worked for me, hope it worked for you :)
Just want to say MAKE SURE YOU SPELL EVERYTHING RIGHT! Spent 2 hours trying to see what was wrong with my scripts and it was all because I spelt Manager "Manger"
I spent sleepless hours last night trying to figure out where I'd went wrong with this lesson. Eventually, I decided to delete my progress and start it over fresh today. I will never know the error I made last night, but it just goes to show, attention to detail is key, and a well-rested brain is our best defence against making mistakes... ONWARD!
Brackeys is absolutely amazing. His tutorials are clear and to the point and if something ever gets outdated, his community got your back in the comment section. you guys are all amazing.
OH GOD I DIDN'T THINK IT COULD BE INTERPRETED IN SUCH A LEWD CONTEXT OH GOD I DIDN'T MEAN IT LIKE THAT!!! WHAT TF WAS I THINKING 3 YEARS AGO JESUS FUCKING CHRIST HOLY SHIT. I SWEAR I DIDN'T MEAN IT LIKE THAT AT ALL! i'm not gay I swear!
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
The Boolean part made my Brain feel like scrambled eggs, however after a few re-watches your explanation finally sunk in, loving the series man ... honestly cannot believe i'm starting to comprehend C#
@@fahadaameer5618 Wow, replying to you is a bit funky, the text goes from right to left like with your language. Basically, you check "is 0 actually 0?" then you change the value so that it's never 0 again. That's essentially how it works, but instead of numbers (even though they are numbers in the background) it's instead true or false. Something a bit more readable for us humans.
@@sebastienbergeron4679 I wrote a reply to the Amir dude somewhat explaining it, although I'm guessing you already understand it at this point. If it's easier for you to understand, a boolean is either 1 or 0 (true or false) which means gameHasEnded == false is like checking if 0 is actually 0. Since gameHasEnded can only be false before that point, this will always be true the first time. You then set it to true (1) to make sure it never triggers again. As for why it's == that's simply because = sets a value, so it's used to avoid duplicate uses for the same syntax. That makes the code more readable at a glance. Having multiple uses for the same thing is called overloading by the way.
FIX NaN! In Edit> Project settings> physics, changing Contacts Generation to 'Legacy Contacts Generation' Finally got rid of the NAN message (I tried it a lot and it doesn't come up anymore). Credit - Sebastian Rijks (up vote to help people)
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
Fun fact! For me, if you name the game manager script like GameManager, you don't need to attach it to an object! To tell if you got it right, the script should have a cog icon instead of the standard "script" icon!
at 4:02 I got an error, FindObjectOfType().EndGame(); is not accessable due to its protection level. It took me forever but when I read your comment, I changed the name of the script to not get a cog and it worked. Do you know a way to call EndGame(); using the GameManger as a cog?
For anyone who was stuck with the GameManager, make sure the icon next to the script is the C# icon and not gears. If it is gears recreate the script again only with a different name such as Manager instead. This worked for me at least
for anyone in 2021 doing this tutorial, with the auto lighting bit what you have to do is generate the lighting, it'll be a button that looks like a drop-down menu at the bottom of the 'Scene' section of the Lighting panel, just click Generate Lighting and it works
Froggot i’ve been stuck on this for ages... i’ve rewritten it like 3 times and the reference still isn’t showing up, and when i go into play mode there are no errors (Brackeys says ‘there should be errors in the console’) so i know something’s wrong :(
amelie rose there are errors because he deleted and replaced the player to demonstrate something so he had to put back the references to the player for the main camera and something else.
Time-stamps for reference: 0:25: Creating a Game Manager 2:43: Finding the Game Manager with FindObjectOfType 4:52: Detecting when the player has fallen 6:10: Ensuring the game only ends once with a conditional 7:18: Restarting the game 9:07: Turning off auto-baked lighting 10:00: Using Invoke to add a delay before the game restarts 10:58: Adding the level to the project's Build Settings
For anyone who gets an error for the ().EndGame(); Just remember that 1. You need to make the GameManager Script have a *public* void EndGame() 2. That you specifically save on that specific script to get unity to update to that :)! I saved on the PlayerCollision Script and I just assumed it would save for both scripts. You probably don’t have this problem but it’s not going to break your code if you apply these things so if you have even a remotely similar situation, I recommend you try this! Sorry to everyone who has more complicated problems than this ^^’
OMG Thank you so much!!! I did not save both the scripts and that's why was getting the error! I NEVER THOUGHT I WOULD MAKE A SUCH A MISTAKE DESPITE BEING AN EXPERIENCED PROGRAMMER!! Thanks again! U saved the day
@@skewminds3756 Man this is from a long time ago and I have no idea what I was even referring to anymore, but glad I could help! I just remember this being very frustrating lol.
i followed this tutorial exactly and got an error if your GameManager script has a gear next to it you need to delete it and delete the GameManager from your hierarchy. Then restart the video.. you can rename it GameManager again in the hierarchy, but when you make your #C script name it “Manager” follow the video and when he goes to the player collision type it as: FindObjectOfType().EndGame(); that’s what fixed my error
sir, after reaching this far, i want to thank u so much i have made an almost complete game.. im 15 yrs old, always wondered how to make a game, at last i have made one game, in unity, using basic codings and not directly by the templates and prefigured games on the web.. i m just so happy to build this game, and it is really cool, wish u would be here trying my game on my pc..
For those of you confused about the bool part (cause sure was am for a good 15 minutes haha) bool can only be read as true or false, meaning there can only be 2 options for the command to read it as basically what he did was set the "phase" 'gamehasEnded' equal to false at the beginning; so for example when the player falls down below -1f on the y-axis on the PlayerMovement script it'll call on the 'GameManager' to execute the command 'EndGame' since 'EndGame' has 'gamehasEnded' = true, that means the statement is now a true statement. so IF the 'gamehasEnded' is a true statement then it'll say "yo we true out here" so whatever if statement you type up (ie debug log for "game over") it'll only display as soon as that statement is true. Hopefully this helped someone haha, I'm also new to programing so hopefully, I didn't confuse anyone. Programmers let me know if I interpreted that correctly haha to my fellow new people out there, let's keep prevailing!
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
After spending 2 days on an error I realized that I spelled Manager Maneger in one place that I didn’t even regard in the code looking for spelling mistakes because it was stating the name of the script 🤦🏼♂️ Thank you for the amazing videos bro!!! You are getting me through quarantine
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
If you are having problems disabling auto light calculations in the newer versions of unity just go to the light tab and at the bottom it will say "Generate Lighting" and click it.
Around 4:34 you're talking about the errors I identified a vid or two back! I'm glad I was able to locate the issue on my own, but also glad you covered it just in case, too!
Sometimes if you go of the edge a little and then come back on, the player disappears and the score says NaN and It just stops. I don't know if this has happened to anyone else, but it happens often for me.
Same happens to me: transform.position assign attempt for 'Main Camera' is not valid. Input position is { NaN, NaN, NaN }. UnityEngine.Transform:set_position(Vector3) Follow_Player:Update() (at Assets/Scripts/Follow_Player.cs:9) Tried to google it, and my guess is that the z axis gets kind of "stuck" in the ground object, which fucks up to text/score script. Any fixes?
Great Tutorial! I'm adding many more things in it to learn: slow motion, music, soud effects, restart if you press a button and i'm gona turn this game into mobile! It's the best free tutorial. I knew basics of C# before, so it's easier to me :D
@@maggiethegamer1271 if (collisionInfo.collider.tag == "Obstacle") { Time.timeScale = 0.5f; } else { Time.timeScale = 1; } ("Time.timeScale = 0.5f "slows time, in this if it's slows, when hit)
Referencing the game manager other class - 3.00 Restart the game on game manager - 8:41 Light problem - 8:56 delay function - 10:21 add scene to build setting if more than 1 scene - 11:05
@@lazyboii735 I've only just found these videos, but I was wondering about that. The other thing I'd like to learn sooner than later is how to program a game to save your progress, so the player doesn't have to start again every time they have to stop playing. I've played games like that and just never completed them.
@@anonymousmeskie5059 Just serialize the data and save to a file. www.raywenderlich.com/418-how-to-save-and-load-a-game-in-unity SQLite is also an option, which mimics the functionality of SQL within the program/game. Of course, if you don't know shit about SQL, then don't do that as you need to learn about that as well. I'm guessing you don't, so go for the first option. If you go for the JSON route, you'll be able to basically take the data and make it into a text format similar to what you'll find at this site: json.org/example.html There are other ways of saving the data, such as in binary format, on a database, etc. However, I'd suggest you go for the JSON route to begin with as it's by far the easiest, as there are many tools out there to help you serialize and deserialize data easily. For example, when I do things in Java, I use the GSON library, which lets me simply write String serialized = new Gson().toJson(object); and I'll serialize whatever that object variable is. Then I can say Object object = new Gson().fromJson(serialized); and my Object there will have the same data as what I started with. Then it's just a matter of saving everything in a logical manner. You likely want to have an object/class that holds your player progress by the way. I actually looked around a bit and found this: docs.unity3d.com/ScriptReference/JsonUtility.html So there's actually a Json tool already in Unity. Works similar to what I mentioned. JsonUtility.ToJson(obj) or JsonUtility.ToJson(obj, true); to pretty print it, which I'd recommend if you want to read or edit the Json manually later on. It'll create indentations and stuff, whereas the normal one is usually just one line and no spaces. Although I say that due to my experience with other Json tools... including one I made on my own because I was bored one day.
If you have new version unity then lighting is set after GAME OVER is by these steps 1) click on Window 2) click on Rendering 3) click on Lighting 4) Then click on Generate Lighting which is present in Light Probe Visualization 5) Done. I hope this helps 🙂
Hello, can you help me? I have Error: NullReferenceException: Object reference not set to an instance of an object PlayerCollisions.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/PlayerCollisions.cs:12)
Hey, i wanna say 2 things: This tutorial series is amazing! When you finish all the tutorials, do it all again so you can remember how the code works etc...
Hey, Felipe can you help? After trying everything (5-6 times) by following each and every comment, my "Game Over" text is still not appearing in the console. I think it is happening because in the visual editor "EndGame" isn't showing up. PS- Coding and case sensitive scripts are absolutely correct, checked more than 10 times.
@@Massive-G Make sure the visual studio game making tools are ACTIVATED. I had similar problems until i activated it. You just open the visual studio installer, go to "modify" in the "more" tab, then you seach for the visual studio game tools, with the unity logo and click "modify" or "install"
@@bellobods idk why but i have this error "Assets\Scripts\PlayerCollision.cs(13,45): error CS0122: 'GameManager.EndGame()' is inaccessible due to its protection level " does anyone know why?
1:54 I made the full code exactly as you made there but when I play it and I hit an object it red marks the Line - " void OnCollisionEnter (Collision collisionInfo)" And Says ! Object reference not set to an instance of an object. Please help someone
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
@@Siduch. Can you please stop spamming comments. Also, this might be because you tagged the Ground as an Obstacle, that would be the only reason. Untag it, and it should work.
If anyone is stuck at Level01 , the reason being you dont have the Level01 scene in your assets or scenes, then go back to video number 1 at 10:27 and you ll get it from there
Man, thanks a lot for these tutorials! A couple hours ago I wanted to make my own game and, though it is a different kind, I have a lot of ideas on how to go about it.
Those who are struggling to understand the Boolean False and True thing, this is as far as i have understood, when the player hits its Y axis value of -1f the code will go to "public class GameManager : Monobehaviour" line where the bool gameHasEnded value will be still be set to 'false' now it is by default set to 'false' so that when if() checks it (and as the CONDITION is true) it can change the value form 'False' to 'True' and actually end the game.
4:14 : When your not getting errors don't worry the tutorial is not outdated and the reason ur not getting errors is because U have already assigned the player to the text and the camera, that's what I think it is.
For the lighting issue I couldn't find the button in Unity 2020.3.3f1 to fix the lighting. That is because it's named differently and in a different location It's under Lighting > Generate Lighting at the bottom of the panel. It doesn't matter which submenu you have open in Lighting, they all have that button. I clicked Bake Reflection Probes and it fixed the lighting issue for me.
Hello good sir, when I click Bake Reflection nothing changes, it just goes back to generate lighting, when I click on generate lighting, unity simply crashes :( Could u help me
I'm doing this tutorial now a second time and it's so satisfying getting everything right in 1 go! :D The first time it took me about 6 days to complete it now I think I can finish it in one session.
Hey just wanted to say to make sure to get your positives and negatives the right way round. I put 5 instead of -5 and was stuck trying to figure out the problem for 2 and a half hours.
Hey. My Visual Studio doesn't provide me with all these stuff you see when you add some script parts like at 8:10 of this video. It's like VS doesn't understand I'm working in Unity, but I actually downloaded Unity stuff when I was installing VS. What is my problem?
If you get a NullReferenceException on 8:50 then you might forget to add the GameManager script to the GameManager object in unity. This is how I solved theproblem
Not to worry, at 4:20, it normal NOT to get the error. ( Brackeys got a error because he had remove the player earlier in the video for demonstration :)
I have an error ..... HELP Assets/Scripts/PlayerCollision.cs(11,22): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
I have 2 questions :D why wont my visual studio color all the words like his and why it wont show me all the things it shows to him like it did at 3:28 ?
Most likely you don't have Visual Studio Tools for Unity installed or enabled for Visual Studio. Go to Visual Studio installer and install the Visual Studio Tools for Unity on your version of Visual Studio. After that go Visual Studio. Click Edit --> Preferences --> External Tools. On the External Script Editor drop down menu, change that to Visual Studio 2019.
For the current build of unity (v.2019.4.20f1) I was still getting the lighting issue even though the 'Auto' checkbox (now 'Auto Generate') was already unticked. I solved it by clicking the 'Generate Lighting' button next to it. Don't click the arrow - that will just open a drop-down menu - click the text. It will render for a moment, then it won't cause the lighting bug again. At least, it hasn't for me so far for the current scene.
i’m pretty sure i’ve got everything correct for the first 4-5 mins of the vid but for some reason the debug.log doesn’t show up in the console when i collide and i have no idea why, any help?
Hello everyone. If you're getting mess with finding the *Player* to dont use a variable I will show you how to do. Use the: GameObject.Find("The name of the object that youre wanting to find inside the quotation marks, in the case, Player") and then you can put a dot(.) to access the info about that object. Like: GameObject.Find("Player").transform.position.z.toString("0"); The GameObject.Find("Something Here") is very useful to find an object by name(and only for this too). So you only need to put the name of the object inside quotation marks.
You would most likely use the same code, just instead of running it when you collide with an obstacle/game over, have the code run when you press whatever button you want, assuming you mean a key on the keyboard, instead of a GUI that pops up when the game ends. For the former, just do the same type of thing you did for moving left and right, just modify the body of the code(code within the curly brackets). Not entirely sure how to do the latter.
If someone on 10:50 gets error, local function "Restart" is declared but never used, don't search in the web, maybe you just miss placed { } because that's what I did and I was wondering what's wrong about 20 mins before I start checking every word with his. I'm using C# from 3 days and it was like hell for me to find this little }
Every time I test the game a couple of times, it gives me some errors, saying "Invalid parameter pos in Rigidbody. TransformChanged because it was infinite or NaN", "Invalid AABB aabb", "Assertion failed on expression: 'IsFinite(d)' " etc. (Also, even though the code seems right, the "a" and "d" key doesn't seem to work...)
I know this comment is old but, i might have a fix for the "a" and "d" key not working. If you are in fullscreen when testing then (atleast i have to) you have to click on the scene after you press play in order to interact with it. I hope this helped :P although you are probably not concerned with this anymore lol
If your game isn't restarting some major scene tips to fix are 1: make sure your script is named GameManager (IDK if it works for you but it worked for me and yes I had the settings symbol) 2: make sure you made the empty component in the Hierarchy (tab on the left side of the editor) and call it GameManager caps sensitive, no spaces, and very important (why I had problems) 3: If all else fails close and reopen Visual Studio even if there are no errors that are apparent
I made on my own an invisible barrier at both sides of the ground which also does not have any friction. I know it is not a lot but i am pretty satisfied with myself ;)
Make sure you didnt put the definition of Restart() method inside of the public void EndGame () function. It should be outside public void EndGame () function brackets. Hope this helps even its a late reply :)
Guys, if your ground is for some reason lower than the grid, change the rb.position to be BELOW your ground, or else you will game over when starting the game. (Remember, when working with minus numbers, the value goes higher as you go lower, but you probably know, I just wanted to clear this up.)
Okay so i have some main errors that i don't know how to fix, after finishing at 8:50 1- All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification() 2- All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification() 3- Assets/GameManage.cs(21,10): error CS1547: Keyword `void' cannot be used in this context 4- Assets/GameManage.cs(21,22): error CS1525: Unexpected symbol `(', expecting `,', `;', or `=' 5-Assets/GameManage.cs(31,0): error CS1525: Unexpected symbol `}' Please help.
Did you forget to add the brackets properly ? that is the () ? i think i had a similar problem but realised I was missing brackets, btw did you fix the problem ?
hey, i found the fix to error 3, the: void Restart() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } is inside the: public void EndGame() { if (gameHasEnded == false) { gameHasEnded = true; Debug.Log("GAME OVER!"); Invoke("Restart", restartDelay); } } code. if you replace the curly brackets so that the void Retart() is outside of the endgame code its fixed
PLEASE HELP! at 5:28 you typed if (rb.position... I typed that and it says rb does not exist so I used renderbuffer becaze it recomended it to me but then there is an error that says I need to type a definition or position Idk something I think its becaze Im doing this in 2020 and things changed could you do an updated version of respawning? edit: and I checked all of my scripting if it was right and it was
Check if you have some of the script files in the Assets folder as well as in the scripts folder. If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder. This might have happened if you had the scripts open while moving them to the Scripts folder. It worked for me, hope it worked for you :)
I got to 8:57, but when I pressed play I just died over and over again instantly and the console was spamming game over, I re-followed the whole video TWICE, pausing all the way through and checking over my code, thinking I'm going crazy, turns out I missed a pair of {curly brackets} , I hate myself. But seriously great tutorials, thank you for these free resources, I'm having fun learning all this :D
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
Brackeys plz help, it says The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?) Edit: it works in GameManager script but not player movement.
Anybody know how to help me? My error is: "error CS0246: The type or namespace name `MySystem' Could not be found. Are you missing a using directive of assembly reference?" I have all the code correct, but it's not working. Anybody know how to fix it?
I have a weird bug where if I ride against the wall of my ground and the player touches the bottom edge, the player cube disappears and the z-coordinate (thus the score) becomes NaN.
There's a bug where when an object rotates on the edge of another object the former moves to {NaN, NaN, NaN} To fix the error: Edit > Project Settings > Physics. Change "Contacts Generation" from "Persistent Contact Manifold" to "Legacy Contacts Generation"
Perfect, that fix worked for me, thank you. What exactly does this change mean? Does Unity check physical contact incrementally now instead of consistently?
IDK, I just Googled for a potential solution and found that. But I did a quick search and found this: docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/AdvancedCollisionDetection.html#persistent-contact-manifold-pcm
1:54 I made the full code exactly as you made there but when I play it and I hit an object it red marks the Line - " void OnCollisionEnter (Collision collisionInfo)" And Says ! Object reference not set to an instance of an object. Please help someone
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked. Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
Hi, i don't understand. Obviously i made a mistake. 4:17 i set my camera to follow my player and player on text as well. But then i wanted to try the game but the camera just flew up and player went his way. What's the problem? I hope you will answer. Thank you anyway.
Hello! I have one question. Why when I'm playing and i put my cube in the left lateral my score position of the cube is replaced by "NaN". thaks!!!! :)
There's a bug where when an object rotates on the edge of another object the former moves to {NaN, NaN, NaN} To fix the error: Edit > Project Settings > Physics. Change "Contacts Generation" from "Persistent Contact Manifold" to "Legacy Contacts Generation"
Another way to make a game over when you fall off the edge is to create 2 copies of the obstacle, scale them to the same scale as the ground except x, which should be 0.01, set the location to 0.01 +(positive x) or -(negative x) half the x scale of the ground ,and disable the mesh render.
Thank you for this video! If the game is over, how can I change the number which is in the middle of the screen to "Game Over" or "Press 'R' to restart"
Sorry, I thought i can do this but i do not understand something. How can i get the reference to the Text Component? Because the FindObjectOfType is not working, please help :)
i have reached this video from video on and it has taken me 52h to get it all right cause of grammers or point blank things and now i am stuck at the restard section XD another 2hours to just find something so simple XD lord i love this
Here's something that might be helpful to everyone: Include a line of code at the very top which says this: using Debug = UnityEngine.Debug; I ran into a situation where Unity kept giving an error for Debug.Log because the code didn't explicitly say that it was for debugging things in Unity, or something like that.
Hello everyone!
I've addressed this a few places (we talked about it in one of livestreams) but I probably haven't been clear enough to people who don't watch all the videos :)
I've decided to focus more on standalone videos and smaller series. The reason for this is that I found that both the Tower Defense and the Multiplayer FPS series were getting too long which meant that only a very small fraction of the people who started watching actually got to the later videos. And this is a shame because a lot of the videos covered later in the series aren't harder to understand than the first ones and might be just as important.
So instead I want to create videos that can apply to as many games as possible while still tackling some of the more advanced subjects. I think the Scope, Bullet Time and Volumetric Lights tutorials are good examples of this because they both cover subjects requested for the FPS and Tower Defense series but in a way that makes it usable to people working on other games as well.
On top of that I had been getting request for a looong time to remake the Make a Game course because it was getting outdated. So I thought this would be a good opportunity to create a smaller series for beginners.
I think overall since I started this new approach that the comments and feedback has been way more positive and the videos are getting way more views on average. I've also found that I have way more fun creating videos this way because it can be much more varied.
I hope you guys understand and I'm just excited to bring you new interesting videos - Especially once we wrap up this short series :D
Thanks for being awesome!
Brackeys you can use !gameHasEnded instead of == false, prob you know but you know.
Nice :)
Brackey , can i ask you about your Pc specs because i noticed that game development on your
PC is a lot faster than mine.
I will love to know about that ...
I want to translate your videos from English to Arabic.
Brackeys Awesome!
I wish we could add tags to the video so it would be much easier to browse through them and go directly to where we want. I notices you try to help with this by naming your videos accordingly though.
BUG FIX: For all of you who got an exception "The namespace '' already contains a definition...": Check if you have some of the script files in the Assets folder as well as in the scripts folder.
If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder.
This might have happened if you had the scripts open while moving them to the Scripts folder.
It worked for me, hope it worked for you :)
Tysm
thank you my dude
i give you a virtual $1000 bucks
You are my hero
Thanks man
Gideon Rimmer thank you
Just want to say MAKE SURE YOU SPELL EVERYTHING RIGHT! Spent 2 hours trying to see what was wrong with my scripts and it was all because I spelt Manager "Manger"
Ya Boi Starmix Oh, the irony!
Ya Boi Starmix (*Sleep)
SPELL*
@@MoreST6 That's it! 👏👏👏
Lol I did the same. I spelt Position as "Postion"
I spent sleepless hours last night trying to figure out where I'd went wrong with this lesson. Eventually, I decided to delete my progress and start it over fresh today. I will never know the error I made last night, but it just goes to show, attention to detail is key, and a well-rested brain is our best defence against making mistakes... ONWARD!
"We Simply Drag Our Score Script To Scripts Folder."
Jokes on you.
I did it last part.
haha amazing
Absolute mad lad.
This comment is lit
i dont get it
Haha me too
Brackeys is absolutely amazing. His tutorials are clear and to the point and if something ever gets outdated, his community got your back in the comment section. you guys are all amazing.
This guy is so happy all the time.
His smile just makes me feel tingly inside.
right...
...
OH GOD I DIDN'T THINK IT COULD BE INTERPRETED IN SUCH A LEWD CONTEXT OH GOD I DIDN'T MEAN IT LIKE THAT!!! WHAT TF WAS I THINKING 3 YEARS AGO JESUS FUCKING CHRIST HOLY SHIT. I SWEAR I DIDN'T MEAN IT LIKE THAT AT ALL!
i'm not gay I swear!
@@LetsDrinkWindex XD I knew what u meant lol
ew
Game Over happened in real life. We will miss you Brackeys!
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
But he's not dead
😭😭
no way wtf
you scared me so much damn i thought he died
why if i name my script GameManager it gets a Settings-Icon?
It's simply the script symbol for a C# script named GameManager. You did nothing wrong.
Unity detects that it's the Game Manager (because of the name) and will set the icon to make it more visual
Same
Yet my other scripts look like a # symbol
@@daring7495 yeah lol
The Boolean part made my Brain feel like scrambled eggs, however after a few re-watches your explanation finally sunk in, loving the series man ... honestly cannot believe i'm starting to comprehend C#
i am not sure if i understand it
I rewatched it 10 times and I still don't understand -_-||
@@fahadaameer5618 Wow, replying to you is a bit funky, the text goes from right to left like with your language. Basically, you check "is 0 actually 0?" then you change the value so that it's never 0 again. That's essentially how it works, but instead of numbers (even though they are numbers in the background) it's instead true or false. Something a bit more readable for us humans.
@@sebastienbergeron4679 I wrote a reply to the Amir dude somewhat explaining it, although I'm guessing you already understand it at this point. If it's easier for you to understand, a boolean is either 1 or 0 (true or false) which means gameHasEnded == false is like checking if 0 is actually 0. Since gameHasEnded can only be false before that point, this will always be true the first time. You then set it to true (1) to make sure it never triggers again.
As for why it's == that's simply because = sets a value, so it's used to avoid duplicate uses for the same syntax. That makes the code more readable at a glance. Having multiple uses for the same thing is called overloading by the way.
@@CottidaeSEA i was gonna ask you this in more detail but then while typing the code here somehow it finally understood it. Damn. :D :D
FIX NaN!
In Edit> Project settings> physics, changing Contacts Generation to 'Legacy Contacts Generation' Finally got rid of the NAN message (I tried it a lot and it doesn't come up anymore).
Credit - Sebastian Rijks
(up vote to help people)
r/IHaveReddit
this is not reddit mate
@@PurplySkye fail
appreci8 it m8
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
Fun fact! For me, if you name the game manager script like GameManager, you don't need to attach it to an object! To tell if you got it right, the script should have a cog icon instead of the standard "script" icon!
at 4:02 I got an error, FindObjectOfType().EndGame(); is not accessable due to its protection level. It took me forever but when I read your comment, I changed the name of the script to not get a cog and it worked. Do you know a way to call EndGame(); using the GameManger as a cog?
@@nicolasszorc1356did you figure this out or you still need help? 😂 it’s been a while so just checking
And this is how you make a Ketchapp game in under a hour
oh yeah, good point
took me 2 day tho
well, it's an hour and a half without the pauses
I really love the minimalistic, colour palette and font in this simple prototype.
Brackeys: We should be getting a few errors
Me: Gets no errors the one time I was supposed too
For anyone who was stuck with the GameManager, make sure the icon next to the script is the C# icon and not gears. If it is gears recreate the script again only with a different name such as Manager instead. This worked for me at least
2 years from now and you just saved my programming career xD
@@BamnBooper The same. And you are my inspiration for my heart. Thanks!
I did this but I don't see the "game over" when I die
Thanks man
for anyone in 2021 doing this tutorial, with the auto lighting bit what you have to do is generate the lighting, it'll be a button that looks like a drop-down menu at the bottom of the 'Scene' section of the Lighting panel, just click Generate Lighting and it works
Thanks a lot!
Thank you!!!
Thank you SO MUCH
No need of using that, it's actually fixed.
bro it looks worse doing that
help
The happiness when VS tells you "No Issues Found". xD
thats an issue,,,,,,,,
I would not be making games without you! You're a life saver! Thanks!
Anyone else realize that even if u follow him step by step there is STILL no reference to the game manager in the player collision script
Froggot yes! I was going through every single little thing of code to see if I had exactly what he had and it still had no reference
Froggot i’ve been stuck on this for ages... i’ve rewritten it like 3 times and the reference still isn’t showing up, and when i go into play mode there are no errors (Brackeys says ‘there should be errors in the console’) so i know something’s wrong :(
amelie rose there are errors because he deleted and replaced the player to demonstrate something so he had to put back the references to the player for the main camera and something else.
CoolKCRoyale omg thank you! i see it now, that was a really dumb mistake :0
amelie rose np lol
Time-stamps for reference:
0:25: Creating a Game Manager
2:43: Finding the Game Manager with FindObjectOfType
4:52: Detecting when the player has fallen
6:10: Ensuring the game only ends once with a conditional
7:18: Restarting the game
9:07: Turning off auto-baked lighting
10:00: Using Invoke to add a delay before the game restarts
10:58: Adding the level to the project's Build Settings
For anyone who gets an error for the
().EndGame();
Just remember that
1. You need to make the GameManager Script have a
*public* void EndGame()
2. That you specifically save on that specific script to get unity to update to that :)! I saved on the PlayerCollision Script and I just assumed it would save for both scripts.
You probably don’t have this problem but it’s not going to break your code if you apply these things so if you have even a remotely similar situation, I recommend you try this! Sorry to everyone who has more complicated problems than this ^^’
i actually didn t save the GameManager script, despite making in public. After i saved both scripts, that worked fine, thanks!
OMG Thank you so much!!! I did not save both the scripts and that's why was getting the error! I NEVER THOUGHT I WOULD MAKE A SUCH A MISTAKE DESPITE BEING AN EXPERIENCED PROGRAMMER!! Thanks again! U saved the day
@@skewminds3756 Man this is from a long time ago and I have no idea what I was even referring to anymore, but glad I could help! I just remember this being very frustrating lol.
@@fox_sox haha, anyway, thanks again!
i followed this tutorial exactly and got an error
if your GameManager script has a gear next to it you need to delete it and delete the GameManager from your hierarchy.
Then restart the video.. you can rename it GameManager again in the hierarchy, but when you make your #C script name it “Manager”
follow the video and when he goes to the player collision type it as:
FindObjectOfType().EndGame();
that’s what fixed my error
Brackeys already knew the title of Avengers 4: Endgame :P
He sure did
Hallo mede Nederlander stem PVV
"😱"
I'm gonna stop you right here
Hey I Was Going To Comment That
@@kkibi LOL XD
sir,
after reaching this far, i want to thank u so much
i have made an almost complete game.. im 15 yrs old, always wondered how to make a game, at last i have made one game, in unity, using basic codings and not directly by the templates and prefigured games on the web..
i m just so happy to build this game, and it is really cool, wish u would be here trying my game on my pc..
good for you brotha, keep improving and you can do great things!
For those of you confused about the bool part (cause sure was am for a good 15 minutes haha)
bool can only be read as true or false, meaning there can only be 2 options for the command to read it as
basically what he did was set the "phase" 'gamehasEnded' equal to false at the beginning; so for example when the player falls down below -1f on the y-axis on the PlayerMovement script it'll call on the 'GameManager' to execute the command 'EndGame'
since 'EndGame' has 'gamehasEnded' = true, that means the statement is now a true statement.
so IF the 'gamehasEnded' is a true statement then it'll say "yo we true out here" so whatever if statement you type up (ie debug log for "game over") it'll only display as soon as that statement is true.
Hopefully this helped someone haha, I'm also new to programing so hopefully, I didn't confuse anyone.
Programmers let me know if I interpreted that correctly haha
to my fellow new people out there, let's keep prevailing!
But, he set the bool statement to false, so wouldn't it mean that it is true that the statement is false?
Finally it make sense a little bit. I was just trying staring at it and trying to make sense out of it for 10 15 mins.
took me like an hour to watch a 12-minute vid lmao
raniaska only an hour 😂
What if you watched a 1 hour tutorial video it is going to take decades
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
those are rookie numbers
impossible
After spending 2 days on an error I realized that I spelled Manager Maneger in one place that I didn’t even regard in the code looking for spelling mistakes because it was stating the name of the script 🤦🏼♂️ Thank you for the amazing videos bro!!! You are getting me through quarantine
I’m going to have to watch this series at least 10 more times😂
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
@@Siduch. Honestly, I’m not sure. Just keep checking the code or anything else that might screw up the game.
12 time lmao and I’ve finished everything besides this
If you are having problems disabling auto light calculations in the newer versions of unity just go to the light tab and at the bottom it will say "Generate Lighting" and click it.
i scrolled for so long just to find this comment thank you man
Thanks bro
Around 4:34 you're talking about the errors I identified a vid or two back! I'm glad I was able to locate the issue on my own, but also glad you covered it just in case, too!
4:15
That feeling when you check your work cuz you didn't get any errors XD
Apparently I already made the reference.
All of my code was perfect then I did something and now everrything with "endgame", "restart" and gamemanager has a read mark under it
Pls help me :'(
Sammmeeee
Ive done evrything correct, but i never get the endgame message in console please help
What the crap is Artifact meta info? And why was it not found?
Just look around until you fix it
Lifesaver! Finally, I am starting to understand Game Manager.
Sometimes if you go of the edge a little and then come back on, the player disappears and the score says NaN and It just stops. I don't know if this has happened to anyone else, but it happens often for me.
No it doesn't happen for me. Maybe check if your code is correct
Its Happens but that doesnt mean your code has a error, its like when we approach the edge sometimes unity get an error and this thing is not to worry
find a fix? having the same problem :C
Same happens to me:
transform.position assign attempt for 'Main Camera' is not valid. Input position is { NaN, NaN, NaN }.
UnityEngine.Transform:set_position(Vector3)
Follow_Player:Update() (at Assets/Scripts/Follow_Player.cs:9)
Tried to google it, and my guess is that the z axis gets kind of "stuck" in the ground object, which fucks up to text/score script. Any fixes?
Same problem here. Also looking for a fix.
Great Tutorial!
I'm adding many more things in it to learn: slow motion, music, soud effects, restart if you press a button and i'm gona turn this game into mobile! It's the best free tutorial.
I knew basics of C# before, so it's easier to me :D
how do you get slo-mo when colliding?
@@maggiethegamer1271
if (collisionInfo.collider.tag == "Obstacle")
{
Time.timeScale = 0.5f;
}
else
{
Time.timeScale = 1;
}
("Time.timeScale = 0.5f "slows time, in this if it's slows, when hit)
@@przemysawpakua4179 looks simple enough.
@@przemysawpakua4179 hippity hoppity your code is now my property
@@jindrasyky2354 ctrl C and ctrl V a coders favourite shortkey
Referencing the game manager other class - 3.00
Restart the game on game manager - 8:41
Light problem - 8:56
delay function - 10:21
add scene to build setting if more than 1 scene - 11:05
What about a shop system where you can buy new textures?
@@lazyboii735 I've only just found these videos, but I was wondering about that. The other thing I'd like to learn sooner than later is how to program a game to save your progress, so the player doesn't have to start again every time they have to stop playing. I've played games like that and just never completed them.
@@anonymousmeskie5059 Just serialize the data and save to a file. www.raywenderlich.com/418-how-to-save-and-load-a-game-in-unity
SQLite is also an option, which mimics the functionality of SQL within the program/game. Of course, if you don't know shit about SQL, then don't do that as you need to learn about that as well. I'm guessing you don't, so go for the first option. If you go for the JSON route, you'll be able to basically take the data and make it into a text format similar to what you'll find at this site: json.org/example.html
There are other ways of saving the data, such as in binary format, on a database, etc. However, I'd suggest you go for the JSON route to begin with as it's by far the easiest, as there are many tools out there to help you serialize and deserialize data easily. For example, when I do things in Java, I use the GSON library, which lets me simply write String serialized = new Gson().toJson(object); and I'll serialize whatever that object variable is. Then I can say Object object = new Gson().fromJson(serialized); and my Object there will have the same data as what I started with. Then it's just a matter of saving everything in a logical manner. You likely want to have an object/class that holds your player progress by the way.
I actually looked around a bit and found this: docs.unity3d.com/ScriptReference/JsonUtility.html
So there's actually a Json tool already in Unity. Works similar to what I mentioned. JsonUtility.ToJson(obj) or JsonUtility.ToJson(obj, true); to pretty print it, which I'd recommend if you want to read or edit the Json manually later on. It'll create indentations and stuff, whereas the normal one is usually just one line and no spaces. Although I say that due to my experience with other Json tools... including one I made on my own because I was bored one day.
You Sound Like The CEO of EA...
If you have new version unity then lighting is set after GAME OVER is by these steps
1) click on Window
2) click on Rendering
3) click on Lighting
4) Then click on Generate Lighting which is present in Light Probe Visualization
5) Done.
I hope this helps 🙂
Hello, can you help me? I have Error:
NullReferenceException: Object reference not set to an instance of an object
PlayerCollisions.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/PlayerCollisions.cs:12)
Thanks, the UI changed so I was looking for this. Anyone having trouble around 9:30, it's probably this.
@@hikomore4508 may be u have forgot to attach it into Inspector.
Thanks man!!
Hey, i wanna say 2 things:
This tutorial series is amazing!
When you finish all the tutorials, do it all again so you can remember how the code works etc...
Hey, Felipe can you help?
After trying everything (5-6 times) by following each and every comment, my "Game Over" text is still not appearing in the console. I think it is happening because in the visual editor "EndGame" isn't showing up.
PS- Coding and case sensitive scripts are absolutely correct, checked more than 10 times.
@@Massive-G Make sure the visual studio game making tools are ACTIVATED. I had similar problems until i activated it.
You just open the visual studio installer, go to "modify" in the "more" tab, then you seach for the visual studio game tools, with the unity logo and click "modify" or "install"
@@bellobods idk why but i have this error "Assets\Scripts\PlayerCollision.cs(13,45): error CS0122: 'GameManager.EndGame()' is inaccessible due to its protection level
" does anyone know why?
For those watching this video in 2021, just click Generate Lighting and it should work. (for the 9:18 part)
LifeSaver
"We also want to show the Game Over message when we fall over the edge"
Jokes on you.
I made invisible walls
HOW!!!!!!!!
watch it in first ep of this series, it is somewhere on start
@@uopy3775 just make long cubes and delete the mesh renderer
idk I kind of like the idea that you can fall off the edge, although I don't know which I prefer
watching this 2 hours after brackeys last video we'll never forget you asbjørn thirslund, never 😭
When you think you did something wrong because you didn't get any errors
1:54
I made the full code exactly as you made there but when I play it and I hit an object it red marks the
Line
- " void OnCollisionEnter (Collision collisionInfo)"
And Says ! Object reference not set to an instance of an object.
Please help someone
@@bamtamanerjee2620 try check the obstacle tag..make sure the obstalce tag is set to obstacle in the insceptor
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
@@Siduch. Can you please stop spamming comments. Also, this might be because you tagged the Ground as an Obstacle, that would be the only reason. Untag it, and it should work.
If anyone is stuck at Level01 , the reason being you dont have the Level01 scene in your assets or scenes, then go back to video number 1 at 10:27 and you ll get it from there
Man, thanks a lot for these tutorials! A couple hours ago I wanted to make my own game and, though it is a different kind, I have a lot of ideas on how to go about it.
Those who are struggling to understand the Boolean False and True thing,
this is as far as i have understood,
when the player hits its Y axis value of -1f the code will go to "public class GameManager : Monobehaviour" line where the bool gameHasEnded value will be still be set to 'false'
now it is by default set to 'false' so that when if() checks it (and as the CONDITION is true) it can change the value form 'False' to 'True' and actually end the game.
I'm an Egyption
6 years and you still the best
4:14 : When your not getting errors don't worry the tutorial is not outdated and the reason ur not getting errors is because U have already assigned the player to the text and the camera, that's what I think it is.
For the lighting issue I couldn't find the button in Unity 2020.3.3f1 to fix the lighting. That is because it's named differently and in a different location
It's under Lighting > Generate Lighting at the bottom of the panel. It doesn't matter which submenu you have open in Lighting, they all have that button. I clicked Bake Reflection Probes and it fixed the lighting issue for me.
Thanks man just had this issue right now and this fixed it!
Hello good sir, when I click Bake Reflection nothing changes, it just goes back to generate lighting, when I click on generate lighting, unity simply crashes :( Could u help me
@@codewizz1885 Ah sorry for the late reply. Sadly I don't know the answer to that question. I haven't really messed with the Bake Reflections either.
I'm doing this tutorial now a second time and it's so satisfying getting everything right in 1 go! :D
The first time it took me about 6 days to complete it now I think I can finish it in one session.
Welp, it took 8 episodes but Unity is finally doing something completely different from what's happening on-screen
Hey just wanted to say to make sure to get your positives and negatives the right way round.
I put 5 instead of -5 and was stuck trying to figure out the problem for 2 and a half hours.
Hey. My Visual Studio doesn't provide me with all these stuff you see when you add some script parts like at 8:10 of this video. It's like VS doesn't understand I'm working in Unity, but I actually downloaded Unity stuff when I was installing VS. What is my problem?
same happens to me, don't know what to do
9:16 I couldn't find the Auto Lightmap Baker in the new Lighting Settings Unity has.
Did it make a big difference for you guys?
It should be in windows, rendering.
If you get a NullReferenceException on 8:50 then you might forget to add the GameManager script to the GameManager object in unity. This is how I solved theproblem
Thank you so much. I don't know how I missed that, I thought I had created the GameManager Object but apparently I didn't.
OMG thank you so much bro, that really helped me.
i got the same problem and I fixed it by myself and now I see this comment
Not to worry, at 4:20, it normal NOT to get the error. ( Brackeys got a error because he had remove the player earlier in the video for demonstration :)
I have an error ..... HELP
Assets/Scripts/PlayerCollision.cs(11,22): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Same here, but I found a comment below that helped me fix it. Just make sure to include parenthesis after both AND EndGame.
Chris Field thanx problem solved
Had the same problem here
@@ChrisField13 thank you i was stuck at this for half an hour
@@ChrisField13 thanks man i was stuck at this for about 1.5hour
@@ChrisField13 Thank god you exist
I have 2 questions :D
why wont my visual studio color all the words like his and why it wont show me all the things it shows to him like it did at 3:28 ?
It's because he is using intellisense for c# and probably you don't.
Most likely you don't have Visual Studio Tools for Unity installed or enabled for Visual Studio.
Go to Visual Studio installer and install the Visual Studio Tools for Unity on your version of Visual Studio.
After that go Visual Studio. Click Edit --> Preferences --> External Tools. On the External Script Editor drop down menu, change that to Visual Studio 2019.
@@Tiikers Love you. x
These videos are pure gold. I've made a game called Jumpy Cube.
For the current build of unity (v.2019.4.20f1) I was still getting the lighting issue even though the 'Auto' checkbox (now 'Auto Generate') was already unticked. I solved it by clicking the 'Generate Lighting' button next to it. Don't click the arrow - that will just open a drop-down menu - click the text. It will render for a moment, then it won't cause the lighting bug again. At least, it hasn't for me so far for the current scene.
This actually saved me a huge headache. You're a hero
Same
thx so much for this
you're the best
i’m pretty sure i’ve got everything correct for the first 4-5 mins of the vid but for some reason the debug.log doesn’t show up in the console when i collide and i have no idea why, any help?
try UnityEngine.Debug.log instead
1:45 why does assigning a script to an object makes it a "type"? If I did not insert the script the FindObjectOfType method doesn't work
1:19 avengers 4 title confirmed 2 years ago
Hello everyone. If you're getting mess with finding the *Player* to dont use a variable I will show you how to do.
Use the: GameObject.Find("The name of the object that youre wanting to find inside the quotation marks, in the case, Player") and then you can put a dot(.) to access the info about that object. Like:
GameObject.Find("Player").transform.position.z.toString("0");
The GameObject.Find("Something Here") is very useful to find an object by name(and only for this too).
So you only need to put the name of the object inside quotation marks.
Your tutors are the best i've seen! I didnt know anything, but your tutors helped me! Thank you so much!)
Hey Brackeys! How do you add a restart panel and restart the game with buttoninstead of restart instantly?
Please let me know
You would most likely use the same code, just instead of running it when you collide with an obstacle/game over, have the code run when you press whatever button you want, assuming you mean a key on the keyboard, instead of a GUI that pops up when the game ends. For the former, just do the same type of thing you did for moving left and right, just modify the body of the code(code within the curly brackets). Not entirely sure how to do the latter.
Understand :) Thanks for the help after 2 years of waiting for answers!
If someone on 10:50 gets error, local function "Restart" is declared but never used, don't search in the web, maybe you just miss placed { } because that's what I did and I was wondering what's wrong about 20 mins before I start checking every word with his. I'm using C# from 3 days and it was like hell for me to find this little }
I grabbed the script itself that he had left on his website but it still says that, do you think you could share your code with us?
@@sparkeee3 sorry bro i have started javascript bcs it seemed easier and my friends told me that, and I deleted my C# codes
but i did not receive any errors as mentioned in 4:18
*edit: oh i did not do the prefab lol nvm pls no answer*
I think Unity did change something in its new version this time - I didn't turn off the auto lighting, but it was still working fine!
Every time I test the game a couple of times, it gives me some errors, saying "Invalid parameter pos in Rigidbody. TransformChanged because it was infinite or NaN", "Invalid AABB aabb", "Assertion failed on expression: 'IsFinite(d)' " etc.
(Also, even though the code seems right, the "a" and "d" key doesn't seem to work...)
I have the exact same error. Did you find a fix?
Nope...
I know this comment is old but, i might have a fix for the "a" and "d" key not working. If you are in fullscreen when testing then (atleast i have to) you have to click on the scene after you press play in order to interact with it.
I hope this helped :P although you are probably not concerned with this anymore lol
For the error: Edit > Project Settings > Physics.
Change "Contacts Generation" from "Persistent Contact Manifold" to "Legacy Contacts Generation"
@@CandorZofain Thanks a lot! It works
If your game isn't restarting some major scene tips to fix are
1: make sure your script is named GameManager (IDK if it works for you but it worked for me and yes I had the settings symbol)
2: make sure you made the empty component in the Hierarchy (tab on the left side of the editor) and call it GameManager caps sensitive, no spaces, and very important (why I had problems)
3: If all else fails close and reopen Visual Studio even if there are no errors that are apparent
@Brackeys Hey could you make a start and pause GUI. Or maybe a colour select menu. Just my ideas
This isn't twitter you don't use the "@".
i think it then sends that message to Brackeys..
i think....
@@sentientringoffire7658 RUclips used to notify when you use @ to refer to someone, today i think you need to use +.
+Brackeys Read the main message please
@@sentientringoffire7658 actualy you do
I'm not getting any errors but I cannot get the game over to show in the console. I'm not sure what I'm doing wrong.
Facing Same Problem Someone Please help us!
@@photoshopsuraj me too
Did you spell Debug.Log(); correctly?
Try print() and the thing you want the console to say in ""
Check if the debug.log works on another fonction and check if you are locking the right console
I made on my own an invisible barrier at both sides of the ground which also does not have any friction. I know it is not a lot but i am pretty satisfied with myself ;)
I don’t know what is happening but when my player hits a obstacle it doesn’t reset. The coding is exactly the same... someone help! D:
you can check this tutorial out , i think it can help you : ruclips.net/video/2bE0ubwWzhY/видео.html
Yeah it’s the same for me
Same here
Make sure you didnt put the definition of Restart() method inside of the public void EndGame () function. It should be outside public void EndGame () function brackets. Hope this helps even its a late reply :)
Guys, if your ground is for some reason lower than the grid, change the rb.position to be BELOW your ground, or else you will game over when starting the game. (Remember, when working with minus numbers, the value goes higher as you go lower, but you probably know, I just wanted to clear this up.)
can you help every time i touch the ground it says game over
Okay so i have some main errors that i don't know how to fix, after finishing at 8:50
1- All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()
2- All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()
3- Assets/GameManage.cs(21,10): error CS1547: Keyword `void' cannot be used in this context
4- Assets/GameManage.cs(21,22): error CS1525: Unexpected symbol `(', expecting `,', `;', or `='
5-Assets/GameManage.cs(31,0): error CS1525: Unexpected symbol `}'
Please help.
Did you forget to add the brackets properly ? that is the () ? i think i had a similar problem but realised I was missing brackets, btw did you fix the problem ?
@@94D33M i just tried going back with the video and everything was the same thing he did.
@@johnland8372 paste your gamemanage.cs code
hey, i found the fix to error 3, the: void Restart()
{ SceneManager.LoadScene(SceneManager.GetActiveScene().name); }
is inside the: public void EndGame()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log("GAME OVER!");
Invoke("Restart", restartDelay);
}
}
code. if you replace the curly brackets so that the void Retart() is outside of the endgame code its fixed
@@goran5844 lmao
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO Unity crashed when i tried the test and the errors came at 4:10 so i had to start over again ;-;
PLEASE HELP! at 5:28 you typed if (rb.position...
I typed that and it says rb does not exist so I used renderbuffer becaze it recomended it to me but then there is an error that says I need to type a definition or position Idk something I think its becaze Im doing this in 2020 and things changed could you do an updated version of respawning?
edit: and I checked all of my scripting if it was right and it was
check this tutorial out , i think it can help : ruclips.net/video/2bE0ubwWzhY/видео.html
Don't mind me just telling myself where to continue from next time :)
5:30
I Have An Error
He Says SceneManagement are not exist in your namespace 'unity engine' Are You Missing an Assembly reference?
Please Help Me
Have u figured out
Check if you have some of the script files in the Assets folder as well as in the scripts folder.
If so, make sure the ones in the Scripts folder are updated and delete the ones in the Assets folder.
This might have happened if you had the scripts open while moving them to the Scripts folder.
It worked for me, hope it worked for you :)
I got to 8:57, but when I pressed play I just died over and over again instantly and the console was spamming game over, I re-followed the whole video TWICE, pausing all the way through and checking over my code, thinking I'm going crazy, turns out I missed a pair of {curly brackets} , I hate myself.
But seriously great tutorials, thank you for these free resources, I'm having fun learning all this :D
me: so ive made a small level
also me: looks at the number of objects, sees 410
OH MY G
Lol ikr, level 20 be like *number of objects: 12,390*
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
@@Siduch. change this line from if (rb.position.y < -1f) to if (rb.position.y < -0.5f)
Brackeys plz help, it says
The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?)
Edit: it works in GameManager script but not player movement.
Banana Llama how did you fix it? I have the same problem
I got the same error
I solved it by renaming the script and changing FindObject type from FindObjectType to FindObjectType
Eralp Çelebi it still won't work.
Thx This Worked well
Brackeys = God of coding
Tutorials
I just realized how close of a resemblance my profile picture and brackeys has lol
Mine starts losing everytime i start the game.
help?
Same
Sorry for the late reply, but check if your player y position is over 1 because if it is you will lose.
It's because for unity is a collision when the player touch the ground
Use Debug.Log to locate the problem
SAME PLEASE HELP!
Anybody know how to help me? My error is: "error CS0246: The type or namespace name `MySystem' Could not be found.
Are you missing a using directive of assembly reference?" I have all the code correct, but it's not working. Anybody know how to fix it?
You might of spelled something wrong bc that's what I did and I fixed it and it went away
I have a weird bug where if I ride against the wall of my ground and the player touches the bottom edge, the player cube disappears and the z-coordinate (thus the score) becomes NaN.
There's a bug where when an object rotates on the edge of another object the former moves to {NaN, NaN, NaN}
To fix the error: Edit > Project Settings > Physics.
Change "Contacts Generation" from "Persistent Contact Manifold" to "Legacy Contacts Generation"
Perfect, that fix worked for me, thank you. What exactly does this change mean? Does Unity check physical contact incrementally now instead of consistently?
IDK, I just Googled for a potential solution and found that.
But I did a quick search and found this: docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/AdvancedCollisionDetection.html#persistent-contact-manifold-pcm
I made the obstacles spawn randomly as the player moved forward. Pretty fun!
"We probably geting some Errors"
Danm i didnt get one does this make me good or bad because i somehow messed up but it worked for me?
same
1:54
I made the full code exactly as you made there but when I play it and I hit an object it red marks the
Line
- " void OnCollisionEnter (Collision collisionInfo)"
And Says ! Object reference not set to an instance of an object.
Please help someone
is it only me who takes 2 hours for every tutorial trying to fix grammers ?
Grammar*
Tab = auto fill/ auto correct
yes
Anyone know why it ends game as soon as game starts. In a previous video, where Brackeys told us how to make the object slow down only when it hits an obstacle, I copied and did exactly what he said and it worked.
Someone plz EXPLAIN TO ME WHY THE GAME ENDS RIGHT WHEN I PRESS PLAY!!!!????
Hi, i don't understand. Obviously i made a mistake. 4:17 i set my camera to follow my player and player on text as well. But then i wanted to try the game but the camera just flew up and player went his way. What's the problem? I hope you will answer. Thank you anyway.
Hello! I have one question. Why when I'm playing and i put my cube in the left lateral my score position of the cube is replaced by "NaN". thaks!!!! :)
This stands for "Not a Number" which means for some reason your variable is not a float or int
There's a bug where when an object rotates on the edge of another object the former moves to {NaN, NaN, NaN}
To fix the error: Edit > Project Settings > Physics.
Change "Contacts Generation" from "Persistent Contact Manifold" to "Legacy Contacts Generation"
Yes, this finally fixed it for me!
i dont think there is game manager is 2019.2!
You need to make a script named GameManager, and thats the same name you need to set it to
That was a chosen variable name, not a reserved keyword for anything.
Another way to make a game over when you fall off the edge is to create 2 copies of the obstacle, scale them to the same scale as the ground except x, which should be 0.01, set the location to 0.01 +(positive x) or -(negative x) half the x scale of the ground ,and disable the mesh render.
Thank you for this video!
If the game is over, how can I change the number which is in the middle of the screen to "Game Over" or "Press 'R' to restart"
You can change the text by getting a reference to the Text Component - Let's call that myText and then writing myText.text = "Game Over";
Brackeys Thank you very much! I love your videos :-)
Sorry, I thought i can do this but i do not understand something. How can i get the reference to the Text Component? Because the FindObjectOfType is not working, please help :)
@@somabencsik Use GetComponent
sorry for the late reply I didn't realise tht
Can u show to all how to create "Finish Level" and then this,show text "Good job!!" ?Like if u want this!
i have reached this video from video on and it has taken me 52h to get it all right cause of grammers or point blank things and now i am stuck at the restard section XD another 2hours to just find something so simple XD lord i love this
Here's something that might be helpful to everyone: Include a line of code at the very top which says this:
using Debug = UnityEngine.Debug;
I ran into a situation where Unity kept giving an error for Debug.Log because the code didn't explicitly say that it was for debugging things in Unity, or something like that.
Can you help me?,my cube wont restart after it crashes
yup !! thanks for the help
Thank you.