GAME OVER - How to make a Video Game in Unity (E08)
HTML-код
- Опубликовано: 27 мар 2024
- What happens when we lose?
● Download the Project Files: devassets.com/assets/how-to-ma...
♥ Support my videos on Patreon: / brackeys
····················································································
This video is part of a mini-series on making your first game in Unity.
····················································································
♥ Donate: brackeys.com/donate/
♥ Subscribe: bit.ly/1kMekJV
● Website: brackeys.com/
● Facebook: / brackeys
● Twitter: / brackeystweet
····················································································
Edited by the lovely Sofibab.
····················································································
► 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...
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.
Which is scarier? Getting an error when the tutorial doesn't, or not getting an error when the tutorial does?
The second one by far. The first one i'd assume i made a mistake, the second i'd assume the tutorial is outdated and panic.
yeah i got this when brackys went to add the thing about the game over only happening once, mine already did only end once and my code was EXACTLY like in the video. i think something musta updated in unity in the time this came out.
of course, when we get errors and tutorial doesn't
The second one 100%
If I get an error that shouldn't be there, I can just work around it, knowing that there is a solution. However, if I don't get an error when I should, then... *panik*
this 12 min video took me an hour and 30 to finish. I got error after error lmao. but we finished! onto the next :)
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
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!
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"
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
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.
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
"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
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
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?
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
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
I really love the minimalistic, colour palette and font in this simple prototype.
The happiness when VS tells you "No Issues Found". xD
thats an issue,,,,,,,,
Brackeys: We should be getting a few errors
Me: Gets no errors the one time I was supposed too
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!
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!!!!????
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!
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
I would not be making games without you! You're a life saver! Thanks!
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
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!
Ive got to the movment script where we add
if (rb.position.y < -1f)
{
FindObjectOfType().EndGame();
}
And there is some ERROR that I cant figure out why it comes. I watched the part where he puts in the code and I looked in mine to see if something is wrong but nothing really was so I downloaded his script and copy-pasted it but it continues showing me an error. WHY?
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
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
Assets\Scripts\playercollision.cs(16,13): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
any help?
Hi, i have this problem, please help me.
NullReferenceException: Object reference not set to an instance of an object
PlayerCollisions.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/PlayerCollisions.cs:12)
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 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 get this error after trying to enable restart
Assets\GameManager.cs(22,62): error CS1061 : 'Scene' doesn not contain a definition for 'Name' accepting a first argument of type 'scene' could be found (are you missing a using directive or an assembly reference?)
NullReferenceException: Object reference not set to an instance of an object
PlayerCollision.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/Scripturi/PlayerCollision.cs:15)
what can i do?
"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
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
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
Hey, so I've noticed that visual studio won't give me the suggestions/show me what I can do with the variables, nor do the objects show up in orange text. I am using Unity 2020.3.11f1 Personal and Visual Studio 2019. I do have (using UnityEngine;), ignore the (), at the top. Any idea as to why this is happening?
Found the problem, I had to go to unity, edit > preferences > external tools, and select Visual Studio under External Script Editor. If Visual Studio is giving you the error that Assembly-CSharp is incompatible, right-clicking the assembly then pressing reload with dependencies worked for me.
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"
@@candorzofain8682 Thanks a lot! It works
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
please help im having this error
NullReferenceException: Object reference not set to an instance of an object
PlayerCollision.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/PlayerCollision.cs:15)
It keeps saying this error NullReferenceException: Object reference not set to an instance of an object
Cube_Collision.OnCollisionEnter (UnityEngine.Collision collisionInfo)
Because of something in my Player collision script. 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
how do i fix this brackeys? ''NullReferenceException: Object reference not set to an instance of an object
playercolllision.OnCollisionEnter (UnityEngine.Collision collisioninfo) (at Assets/running cube script/playercolllision.cs:12)''
I have the same error.
Nugroho Pangestu rewrite the script brother
That's not helpful in the slightest, how about you actually give a real solution. +DragonSlayer98
Is this problem in accordance to disabling the movement after colliding with an obstacle? What are you trying to do; and what is not working?
If anyone is going through this tutorial and getting this error like i was the problem for me was i was using
GetComponent().EndGame()
instead of the correct
FindObjectOfType().EndGame()
can someone help me pls
Assets\Scripts\PlayerColision.cs(13,45): error CS1061: 'GameManager' does not contain a definition for 'EndGame' and no accessible extension method 'EndGame' accepting a first argument of type 'GameManager' could be found (are you missing a using directive or an assembly reference?)
why does mine says "'PlayerMovement' does not contain a definition for 'position' and no accessible extension method 'position' accepting a first argument of type 'PlayerMovement' could be found (are you missing a using directive or an assembly reference?)"
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
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.
mine too
this happened to me and I'm so confused so I went to the comments for a fix lol
@@arasaan If this error comes then it means that there is no problem in coding . Just make sure you have put the coding to the player . Sometimes you write the coding but there is no one effected bcuz you need to deliver it tk any object
@@Namanj07 I deleted everything I made from the tutorial and remade it and it works fine
@@arasaan cool
how do i get visual studio so it shows the stuff that the certain functions can do, because mine doesn't show that stuff like in the video
Can't seem to get "LoadNextScene" function in my animation event drop down list, although already specified the function in visual studio.
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 :)
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
Hi I am having issues with the reset
FindObjectOfType().endgame();
this is the code I am using
this is the errror
Assets\oncollide.cs(8,29): error CS0246: The type or namespace name 'Endgamer' could not be found (are you missing a using directive or an assembly reference?)
Also what extension do you use for vscode as I dont get any refrences to the available functions. Please help
fyi you wrote endgameR with an R at the end
@@masamotox952 Thanks for the reply MasamotoX :) I will update my code
@@Jmonitcom fyi this will also fix your suggestions stuff ruclips.net/video/5LX13Xqc50g/видео.html
The references
Assets\scripts\pang.cs(15,30): error CS0246: The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?)
Hey guys, can anyone help me? I have Unity 5.6 but Visual Studio isn't using Intellisense or auto-complete on my code, it also doesn't highlight it like in this video. It's set up in the Preferences tab and the Build Settings, and I've also imported the package inside Unity itself, but it's simply not working.
Same here.
reinstalling vs worked for me
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
i get this issue "Trying to Invoke method: GameManager.Restart couldn't be called" delay function doesn'tt work, any help ?
Edit:
fixed it, "void Restart ()" was inside End Game function accidentally.
thank you
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.
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.
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.
Hi what plugin do you use for VSCode? Because it does not show me all these options when i type words
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
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...
at 4:06 I got this error can someone help me please?
Assets\scripts\PlayerCollision.cs(13,45): error CS1061: 'GameManager' does not contain a definition for 'EndGame' and no accessible extension method 'EndGame' accepting a first argument of type 'GameManager' could be found (are you missing a using directive or an assembly reference?)
question: @05:27
Why do we use rb.position? Surely we should use the Transform right? I cant even see a position on the RigidBody Component, its all just speeds.
It works, but im confused. Anyone care to explain?
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.
I get Assets/scrp/collision.cs(12,38): error CS1061: Type `gamemanager[]' does not contain a definition for `EndGame' and no extension method `EndGame' of type `gamemanager[]' could be found. Are you missing an assembly reference? if anyone can solve this please
Same here, did u find a fix??
Make sure you copy his script perfectly. Missing a semi colon? ;;;;;;
im sure I've copied his exactly just is still giving a error
Do you have all the correct } in the game manager script?
I also have that problem
after i added the thing to the collision script, i got this error "Assets\GameManager.cs(3,7): error CS0116: A namespace cannot directly contain members such as fields or methods
", what do i do?
The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?)
I got this error and cannot figure out how to fix it. My object in unity IS called GameManager. Theres no typos.
If I change the variable type to something else, like int, the console error will go away. But then I also cannot drag my GameManager object to the variable in Unity.
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
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
@Brackeys In Microsoft Visual Studio I dont get a drop down box like you get after putting a "." after any certain command.. Pls give any solution for it ..
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.
4:15
That feeling when you check your work cuz you didn't get any errors XD
Apparently I already made the reference.
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
Hey I dont have a player collision script because im trying to implement this in a 2d project with 2d collision boxes. Is there an alternative way i can do this? Please help...
can you please tell me why thats not working and why i get this error NullReferenceException: Object reference not set to an instance of an object
PlayerCollision.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/Scripts/PlayerCollision.cs:15)
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!
I have this problem when I hit an object it says this. instead of game over I have done everything to 4:51
NullReferenceException: Object reference not set to an instance of an object
PlayerCollision.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/Scripts/PlayerCollision.cs:12)
Dud e i am also facing the same problem.
:/ Maybe problem with new version of Unity????????????????????????????
im not sure why, but findobjectbytype and getcomponent arent interchangeable. go to that line in the error code and switch it to the other one and see if it helps
Make sure your 'GameManager' is still in the hierarchy. I noticed mine was gone after i had placed it. I made a new empty object and put the GameManager script in it as a component and it worked!
thanks ,this solution work me :)
Hi so how would i do the following. When my timer hits 0 then I want the game to go the score menu and have his score display there ?
If possible code would be helpfull, im still new at this.
Hello, could you help me? I am using Microsoft Visual Studio 2019. While I am typing code, I don't have helping dropdown menu like you have (eg: "SceneManager." - 8:04). Is there any settings in Visual Studio that I need to adjust?
I had the same problem. You need to go to Unity then Edit>Preferences>External Tools> , then choose Visual Studio 2019 as your External Script Editor
@@shaanplayzgames4836 thanks a lot
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.
SOMEONE PLEASE HELP:
For me it shows the Game Over statement in the console when the game starts, when it touches the ground. Someone please explain to me why it's doing this, even though a few videos ago I followed along when Brackeys talked about the player stopping when it hits something other than the ground, and it worked for me.
I NEED TO KNOW!!
I had the same Issue the rechecking the code I noticed that i added a ";" after if (rb.position.y < -1f)
change this line from if (rb.position.y < -1) to if (rb.position.y < -0.5f)
@@magicle855 i had the same problem and I did what you said to do put I did not change, do you know any other way to fix this?
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.
in 2020 i got problem that when i go to lighting panel i don't find any thing under the Fog click nothing just DEBUG settings . so any help ?
tip* that i use a old version it 2017 . ^_^
Hey, when I try use GameManager and PlayerMovement it said it could not be found. Does anyone know a fix?
Viktor Make sure gamemanager is not in a folder, it took me forever to figure this out
@@ceeplaysgames86 Assets\Script\playercollison.cs(7,12): error CS0246: The type or namespace name 'GameManager' could not be found (are you missing a using directive or an assembly reference?) can you help me ?
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 have a question.
I did everything right and it's all working with the reset as it should.
But when i build the game and start the game, when i hit something or fall from the platform the game doesnt reset, it just stop
what should i do ?
My game is not running in Full Screen mode can you please help me 😢
The Error is The Reference script (Unknown) on this behavior is missing
9:20 the set to auto part is not in the version 2020.3.16f1 instead go for the Environment tab in the lighting menu and then look for compression and put it in Uncompressed hope this helps
TY
Tysm
I put it in the uncompressed but it doesn’t work.. can I somehow fix it in another way??
@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
help, please
Assets\Scripts\PlayerCollision.cs(13,49): error CS0122: 'GameManager.EndGame()' is inaccessible due to its protection level
i have the same problem
Hi just asking for opinion, is it OK to detect when the player is out of bound in the GameManager script, like putting it in the Update method then detect the position of the player because I think it would be a lot nicer and easy to manage. Feel free to tell me wrong tho :"
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.
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
Lifesaver! Finally, I am starting to understand Game Manager.
hey im having this problem when the player hits something or falls of the ground an error comes saying NullReferenceException: Object reference not set to an instance of an object
PlayerCollision.OnCollisionEnter (UnityEngine.Collision collisionInfo) (at Assets/Scripts/PlayerCollision.cs:13) what does this mean?
Yo just click clear on the console it doesn't do anything that's why your able to clear
I do I all the time
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
using UnityEngine.SceneManagement does not exist in my visual studio plz tell what to do
i am having the same problem
Change it EditorSceneMangement instead
@@nathanwalsh3990 nope
Assets\PlayerCollision.cs(26,45): error CS1061: 'GameManager' does not contain a definition for 'EndGame' and no accessible extension method 'EndGame' accepting a first argument of type 'GameManager' could be found (are you missing a using directive or an assembly reference?)
also getting this error, did you get it resolved?
@@abenedict85 watch the video carefully. I didn't remember how i fixed it . All i remember is that solution came from the video
How to fix this?
Assets/Scripts/PlayerCollision.cs(12.45): error CS0122: 'GameManager.EndGame()' in inaccessible due to its protection level.
Also under every script there reads "The associated script cannot be loaded. Please fix any compile errors and assign valid script"
same