What version are you using?
While Unity has been pretty stable with the way it looks between versions since the get go, sometimes items go missing or menus are moved around. I remember when Unity went to a new version and the button I used to turn fog on and off disappeared. It took me ages to find it. It used to be a setting on the camera. It's now in the Lighting menu.
If you are using a different version of Unity than the one your instructor is using, then I can almost guarantee you are going to run into problems.
If you are using a different version of Unity than the one your instructor is using, then I can almost guarantee you are going to run into problems.
If the instructor doesn't tell you what version of Unity to use, you can find it on the top of the window they are using in plain sight.
Using the same version they are using is going to get you started on the right foot to recreate what they are showing you.
It's like trying to learn to drive a Ferrari while watching a tutorial on using a sit on lawn mower! Well not that bad, but you get the idea.
Using the same version they are using is going to get you started on the right foot to recreate what they are showing you.
It's like trying to learn to drive a Ferrari while watching a tutorial on using a sit on lawn mower! Well not that bad, but you get the idea.
Don't refactor too soon.
You might think you know better than the instructor and maybe you do. We certainly don't know everything but if you are following a 20 hour course and writing a game from scratch and you start using variable names that are different from the instructor's, what do you think is going to happen when you walk away from the course for a couple of days?
Of course that's not refactoring as such but it is making your code different to the one you are trying to follow on from. Let's say the instructor wants you to implement a sorting algorithm using an array and you decide to use a dictionary instead. Unless you really, really, really, really know what you are doing and are fine with fixing your own bugs, then stick with the content being taught. If you need to make it run faster, then by all means, once the course is finished and you've got a working project, do all the refactoring you like.
Mine is exactly like yours but it doesn't work.
As instructor's we hear this A LOT. If your project is exactly like the instructor's then it should work..... 98% of the time and it did work for the instructor as there is video evidence, however granted sometimes it doesn't work because of the computer hardware, operating system or a software bug.
So what should you do if you think your code/project is the same but refuses to work? First, don't panic, it can be fixed. Second, see if there is a working version of the code/project supplied by the instructor. If there is, download it and compare with your own. This is a great learning experience and will help you find the bugs quicker in your own code as you develop your skills.
If you can't find the issue, don't paste the entire code into a forum. The issue might not be in the code, and out of context the code means nothing to other programmers and students. Unity is an integrated development environment with many settings outside of the code that can cause errors.
Try to be as specific as possible, as to the nature of your issue. List the version of Unity you are using (and remember if you are using a different version of Unity to the instructor this might be your actual problem), give details of what you are trying to achieve and what the nature of the issue is, a screenshot of anything useful such as how the project is setup or what is in the Inspector and a screenshot of any errors. Someone may immediately know what's happening for you and be able to give you help.
If someone needs to see your code in order to help out, they will ask.
If you can't find the issue, don't paste the entire code into a forum. The issue might not be in the code, and out of context the code means nothing to other programmers and students. Unity is an integrated development environment with many settings outside of the code that can cause errors.
Try to be as specific as possible, as to the nature of your issue. List the version of Unity you are using (and remember if you are using a different version of Unity to the instructor this might be your actual problem), give details of what you are trying to achieve and what the nature of the issue is, a screenshot of anything useful such as how the project is setup or what is in the Inspector and a screenshot of any errors. Someone may immediately know what's happening for you and be able to give you help.
If someone needs to see your code in order to help out, they will ask.
Null Exception and Other Errors
If you've used Unity then you've received a nice red exclamation mark in the console. This means you are dealing with an error. And be warned, your game might even still run with the error but not in the way you expect.
So first of all, before you think the funny effects you are getting in your game are the issue, if there's an error in the console you should endeavour to remove it before trying to pinpoint any other issues. Errors will stop the immediate script from running, but other script might happily keep going.
The most common error is a Null Exception. It means that you have a property that you are trying to use without a value assigned to it. For example,
The most common error is a Null Exception. It means that you have a property that you are trying to use without a value assigned to it. For example,
Google It
Yeah, yeah, everyone says this. But if you don't know what you are looking for, it isn't that easy. I mean I can Google an error and find a solution relatively quickly but I've been coding for over 30 years and I can quickly assess if the results from the Google search are going to work for me.
If you are a noob, then it's a minefield of solutions that sort of, kinda, maybe, match your issue and then the solutions are even more difficult to understand than the original issue.
So what should you do?
If you are a noob, then it's a minefield of solutions that sort of, kinda, maybe, match your issue and then the solutions are even more difficult to understand than the original issue.
So what should you do?
If you have a Console error, then definitely copy and paste it into Google to see if there is an easy fix, but make sure you strip the error of any extraneous information. So instead of Googling:
UnassignedReferenceException: The variable target of Shoot has not been assigned.
UnassignedReferenceException: The variable target of Shoot has not been assigned.
You probably need to assign the target variable of the Shoot script in the inspector.
Shoot.Update () (at Assets/Shoot.cs:9)
I would reduce it to focus just on the error because the error doesn't always appear on line 9 of a script called Shoot.cs. Instead Google:
UnassignedReferenceException Unity
I've thrown Unity in there to focus the search on the software.
Trying this just now I came up with close to 4000 articles. Less than I had expected but still a lot. Which ones do you choose to look at? The one at the very top is not necessarily the best one. You want to stick with known or authority sources. Chances are, any of the Unity forums such as answers.unity.com, forum.unity.com or even stackoverflow.com are good options. You will still find you need a good understanding of what you are trying to achieve to decipher some of the solutions and there might be more than one thing you've done wrong to cause the issue!! A minefield indeed.
What I would suggest to you, rather than looking through heaps of possibly irrelevant text is to try YouTube. On the previous search I came across: https://youtu.be/HVucS70Z6Q4 which actually shows you the issue and how to fix it in 2 minutes, and there will be simple fixes for not only this issue but many other common Unity errors in short videos.
One other suggestion is to ensure the fixes you are seeking out are for your version of Unity or weren't written over 3 years ago.
I would reduce it to focus just on the error because the error doesn't always appear on line 9 of a script called Shoot.cs. Instead Google:
UnassignedReferenceException Unity
I've thrown Unity in there to focus the search on the software.
Trying this just now I came up with close to 4000 articles. Less than I had expected but still a lot. Which ones do you choose to look at? The one at the very top is not necessarily the best one. You want to stick with known or authority sources. Chances are, any of the Unity forums such as answers.unity.com, forum.unity.com or even stackoverflow.com are good options. You will still find you need a good understanding of what you are trying to achieve to decipher some of the solutions and there might be more than one thing you've done wrong to cause the issue!! A minefield indeed.
What I would suggest to you, rather than looking through heaps of possibly irrelevant text is to try YouTube. On the previous search I came across: https://youtu.be/HVucS70Z6Q4 which actually shows you the issue and how to fix it in 2 minutes, and there will be simple fixes for not only this issue but many other common Unity errors in short videos.
One other suggestion is to ensure the fixes you are seeking out are for your version of Unity or weren't written over 3 years ago.
H3D Forums, Community, Discord and Facebook
For the fastest assistance from fellow students you will find them lurking in the Facebook Group (http://bit.ly/H3DFacebook) or on Discord (http://bit.ly/H3DDiscord) at all hours of the day and everyone likes to help each other out there. These are mostly for advanced and personalised Unity projects and not for help with our specific courses. For that you should post in the Community on this site or in the Udemy Q&As.
Take Aways
Use the closest possible version of the software that the instructor is using.
Never use software that is completely different to the software that is available to you. It will only confuse you before you even start. If the software no longer exists.... then ditch the tutorial and find a more up-to-date one.
Refactoring too early is a no-no.
If it is a follow along tutorial then follow along. Don't make up your own code and don't change the names of variable, properties and methods. It will just confuse you.
If there's an error with the project it's unlikely it is exactly the same as the instructor's.
Check your Unity version, compare your project with a working download if it exists and ask for help being as specific about the issue as possible.
Do you have Red Console Errors
Fix them. The project may seem to be running, but if there are red errors this can cause parts of your code to be skipped. The error in the console will also give you a clue as to what line of code the error is on and in which script.
Try Searching
Google can be your friend. It can also be very scary when you don't know what you are looking for. Only through lots of practice can you determine how it can best serve you.
Forums
Forums are a valuable source of information. They are basically crowd sourced solutions to your issues. But be mindful of other people's time and willingness to help.
Becoming a Successful Debugger
In the end, being able to solve your own programming and game development issues is a valuable task and let's face it you can't rely on the help of others forever (especially if you land that job). Becoming an independent learner takes a lot of work but is worth it in the end. After programming for a while you will start to see the same issues come up time and time again and you will know exactly how to fix them. I might even go as far as to say that eventually your subconscious will predict impending issues and you will start avoiding them altogether, but it just takes practice and lots of hard work.