OMG that first point hit home so much with me. For my final year university project we had to build a game over a year as a 6 man team. We had one programmer who believed he was the best programmer in the world. We needed a main menu screen animation so he decided to do it all in a single script, with a giant 50 step switch statement with each part of the animation being a function moving multiple game objects around. Not to mention he wasted 3 weeks "coding" scaling UI even after being told in the first day it came up as an issue that Unity can handle that for us. Rather then spending 3 seconds googling how to scale UI in unity he wasted 3 weeks on it, but at least he wasn't breaking core systems as a result
@@davkings52 yer, like i don't consider myself that great of a programmer. Infact throughout the project i found this channel to be an amazing resource. But this guy would legit refuse to even google like the most basic things rather being like ill just stuggle through on my own. He used raycasts at some poing to do with modifying one of my AI scripts and broke a super important system within the project. And when i asked him how this was possible he replied that he didnt really know how raycasts worked and that he had copy paste the code from the player controller script and edited it abit. And im just like why would you not just google it like the unity scripting api documentation is amazing.
I have a game for STEAM but having trouble putting it up there, there are no up to date tutorials for steam..have you put a game on steam..could you go over the process. I have paid the £80 fee and sorted my admin details
@@random_precision_software we did not release on steam as we did not feel it was up to a high enough quality we released on gamejolt and itch. Io soz but i can't help you in that regard
Mistakes I wish I'd known to avoid? 1: Overreach - Don't jump into Unity as new user with a huge complex game in mind. You'll end up confused, frustrated, and abandoning the project. 2: Prototype - As a programmer, work in iterations. Forget about the art, sound, and making the game fancy. Roughly build / code everything out first, then once you have a working game, iterate over and start replacing the temporary stuff. There is nothing worse than spending days making a level look amazing, only to find out later that you need to completely redesign it, because it just doesn't work well. 3: Knowledge - Learn as much as you can, but don't try and do everything at once. If you try and learn everything first, you'll never get to making a game.
Definitely great points there! I can't count the # of people who's first game was gonna be 'call of duty but an mmo' or something similar :) Shoot small and complete things first, then grow the ambitions :)
I find that working on little tutorial games is very educational, even as an experienced programmer. For one thing, every game, regardless of genre, shares certain key subsystems/architecture - graphics, audio, UI, gameplay loop - so working on something other than your passion project helps distill your focus on the core elements of "what is a game". For another, you never know which tutorial is gonna have some tips/tricks that save you hours/days/weeks down the line. Unity especially has a lot of "hidden features" that can either trap or save you.
@@Unity3dCollege don't just "prototype" Make small games (I call them toys) that experiment with a feature, shader renderer, Release it, film it, tweet it. These little toys, when released into the wild, become projects that can be picked up and modified later, or you want to re-use an idea, but make it wierd, you have that idea encapsulated in a small project you can play with. Once you have your idea fleshed, Make 1 folder, move all your prefabs code models and stuff into a single directory then use unity's asset export package to bundle that up for use in another project, putting it all in one directory keeps your sanity if you want to make changes
I'm not a professional programmer yet i know a few things that should be done first: 1. use templates, images and sprites of of others while you work and make them work in your game the way you intended and when core game mechanics are good make your art/buy your own art and implement. 2. focus on the core game mechanics - not UI, no character looks, and no game objects placement etc... focus on controls and core game mechanics such as combat, motions/controls, skills, traveling, teleporting w/e... 3. plan ahead and make your game scale-able, challenging and engaging, use friends for feedback. 4. focus on one game - we many times have lots of ideas and start creating new game mid-way of the first game. dont do that. you want to finish your game right?
The thing I wish I knew when starting unity: learn the difference between update and fixed update before you start diving in to coding. Nothing kills your flow like realizing that your movement is attached to your framerate. It's a basic one, but one of the more valuable things when familiarizing yourself with the coding structure. One is strictly for rendering and gpu oriented tasks, the other works on a fixed timer and should be used for anything physics/movement/action oriented. I think this happened in fallout 76 where characters would zoom across the map at walk speed because their framerates were so high and their movement speed was attached to that instead of a fixed timer. Ever try to play wing commander on a later computer system and realize everything was going lightspeed? That's why.
Fixed doesn’t care if you’re a laggy potato it does what it does in a specific time. Update is every frame so if you’re a toaster whatever is running in that update will die
As a long-time game developer, the single most important point in this entire video: FINISH THE GAME I cannot highlight that enough..... Also the showing people the game - yes, on places like the io websites, but please, not on the Google Play store - it'll get lost, no one will see it, and we really don't need any more "this is my first ever game" games on there.
I'd add to that - if your first game ever would happen to have some unique mechanic and maybe, just maybe, get a tiny bit popular on Google Play, it may get into crosshairs of studios like Ketchapp, or that other french one, and they'll just clone it but with better visuals, monetize and use the might of their marketing to push it high, but you as the original creator will not see a single penny and if you try to defend yourself you'll probably get sued, like it happened with the original author of the Candy game that King.com cloned (and made their super popular Candy Crush Saga). If you don't believe me - just google it, it was widely covered in game media at the time.
One thing that many people doesn't know is that animator controller could be used as Finite State Machine, even when there isn't any animation to control. You can take advantage of all functionality and event manager for any kind of object that need a FSM
And its a very dangerous state machine if animations ARE there, because this state machine can be at two states at once while going from one animation to another. Cost me a lot of headaches already. Had to write some layer on top of it to behave like a real state machine with just one state at a time.
@@cosmotect this mean that you can attach a Animator Controller on any object and use it to define steps (states), conditions to transition between those steps, even when you don't have animations related with the Animator Controller.
1 - The Asset Store - Someone out there has way more time & interest than you in coding some arcane subsystem. Just make sure there's still active maintenance & plenty of documentation. Same goes for art/music - even a couple hundred bucks (USD) can take your entire game a big step up from "programmer art". Focusing on what you're good at, and outsourcing the rest, doesn't make it any less *your* game. 2 - Version Control - Because your "one-man-team" may someday be 100, or because next year, you won't remember what that clever method actually does. 3 - Play mode tint - So you never accidentally forget that your changes will be deleted when you hit Stop. Great video!
pretty sure you just said "Dont use this method for finding a game object or this one or this one THEYRE ALL SHITE" then proceeded to not give the best method to do this
pls forgibe me senpai you are right. I think he missed to say that we need to use reference technic, when you create property and assign object via editor. I was advised to do so by experienced game makers and found it very useful. Plus try to assign events from editor... once project gets big and you start forgetting who is sending whom data, you no longer can make changes fast. I stead assign all events in Awake or better Start method. I made this mistake and now regret it.., trying to migrate to new, correct way
I was thinking this too lol. At 8:06 it sounds like he mentions very quickly something about caching and using "find object of type"? But people in this thread say that isn't efficient. Is Serializing from the editor the best way then?
After 10 years as a commercial game developer and 3 years Indie, your advice is still a welcome kick in my teeth when I start to get complacent. Thanks for the great vids dude.
@@HAWXLEADER there are tons of uses! There are good talks about them too! Inventory system, audio system, heck even as an event system I have seen them used. You can do many cool things with them!
@@QuesterDesura I wish I could "see" the usefulness of them I bet they are as useful as interfaces and inheritance but I just don't see it yet unless you build a game with multiple types of one thing(like bricks, cards tons of monsters etc...).
Hey Jason thanks for all the great content. Useful video for anyone who wants to learn all the built-in power of Unity3D. I love your channel bc there are so precious few high level coding tutorials on youtube. Endless amounts of beginners teaching programming and most don't consider the bigger picture/ architecture of their project. It's fast and easy to wire stuff up in Unity3D so usually the spaghetti references/code can be fine for smaller works but this approach quickly fall apart on larger scale or long form games. Your architecture videos are super helpful and your videos make me think about code differently! Thanks for all the long winded explanations my friend they are much appreciated :) .
I've started making my game in Xcode. I had to "learn" objective-c and swift. And I was f***ing frustrated on every IOS-update (broken code on release date - on every update!). What causes me to switch to unity. And this was the day as the sun re-appears. We should be happy about having it. And thank you for your tips. For some of them, it's not too late to solve.
If you have lots of UI or heavily animated UI you should separate ir in different canvases. It looks ugly but it’s better for performance because a single change in an ui element in a canvas will make Unity redraw and recalculate everything for that canvas.
Summery -->> 1. Can use unity animation system for object movement sometimes (can use DoTween for simple tween animations as well) 2. Best use of prefabs 3. Don't user mono all the times, can use plain simple class or helper class when needed. Or can use observer pattern to make it more action based rather than making it mono (update) based 4. Use Profiler to check memory or performance spikes 5. Use TextMeshPro instead of unity UI Text 6. Timeline for Tutorial 7. Cinemachine for Camera Controller 8. Don't do all like creating art, sound etc. Focus on programming/development only
Use direct references instead. Example: public class Example { public GameObject AnObject; public void Start() { AnObject.position = new Vector3(1, 2, 3); } }
@@LaurentK That only works if you do drag and drop, which is tedious, slow and unorganized. Let alone Unity like to drops references all the time. It's way smarter to let GameObjects register themselves in their own Start() in a centralized place.
Another great video. I'm learning more and more if I'm trying to code something there is almost always a simpler, quicker and less prone to bugs way to complete that same task. I have to keep reminding myself that the players of your game won't care what's happening behind the scenes. Thanks for the video!
I wish this existed LONG before I really got into Unity. That being said, one thing you really missed out on is talking about Scriptable Objects. In my project, I am currently rewriting all the character variables that frequently get called in outside scripts, such as the player health, is the player alive, etc. Too do this before, I would first have to make sure the player object even existed, find it, and THEN read the entire script off of it game object just to get a single variables value.. This is a quick way to eat performance, especially when you have a lot of stuff in the scene that has to check if the player is still alive before continuing it's processing. I just recently started to transition to scriptable objects for performance reasons. It's helping remove a LOT of the nested programming, making accessing external variables faster and cleaner, AND allows for better control for what gets read and what doesn't.
I am new to Unity, started working on my first 2D game few weeks ago, I felt this video is spot on, except for "Find" and "FindObjectWithTag", I read and heard a lot about how bad they are, but none of them mention an alternative! keep in mind that this is supposed to be for programmers new to Unity. Aside from that I find most of the other points helpful, thank you
A lot of it will be how the rest of the asset is designed. Example: if you're trying to find another part of the same prefab, then you can have the other gameobject (or, better, the specific component) be a public variable that's linked in the prefab editor. When it's instantiated, Unity will do the links automatically. That will be different if the object is something else random in the scene... but then why are you finding it? Could it have been given to you in a collision or raycast, linked public variable in scene editor (not necessarily good but could be better in certain contexts), etc. etc. etc.? A blanket replacement is not really possible. Need to know more.
Man I love you. There's just a real genuine and humble approach to every video you do. You are clearly a smart guy with bags of ability but it feels like you almost gloss over that in an effort to relate to new developers and their struggles. I'm trying to teach myself how to code and you are pretty much the only guy that gives me real hope. Thanks.
Dang first time realize u can move an object with a mouse but locked on the same plane by where u click on the axis . Been using unity for a year. Wow shows how u should learn basics first first. Good vid
Hi! I like how you point it out. as a beginner i find ths very helpful, but it would be very nice if you show alternative way of how to do things if you don't recommend doing that thing. thanks for uploading this video!
The Cinemachine one drives me NUTS. I'm studying game development, and when I hear my classmates gripe about how hard it was to code some 'super fancy' camera I can't help but roll my eyes. Cinemachine does it 10x better and it's so easy to use. They have no excuse not to use it either, since our professor even showed us how to use it.
Some of my mistakes were; 1. I used to declare bunch of unnecessary stuff instead of using lists. 2. Instantiating and destroying instead of pooling. 3. Learned way too late more about the UI system, the beauty of the rect transform, masks and more. 4. TextMeshPro, the ability to add strokes to your text opens so many more visual styles. 5. Not sure what this is called exactly but making your scripts into instances on Awake() so you can access the functions from other scripts
After watching countless videos where people jump right into coding was at first like wow, I have a lot of work to do. But after this my dude I will be checking all the engine tools first before even looking at my coding.
You worked with some of the most influential games in my time. It's sad to hear what killed vanguard, but your videos are helping me craft my vision, thanks!
That last tip is great advice I learned the hard way. I jumped into game development thinking I had to do everything on my own, the programming, the art, the music, etc, but then I realized I was way in over my head, even though the concept I was developing was a simple mobile game. I spent 3 months learning how to do 3D modelling before realizing I can just buy assets that fit my needs on the Asset Store. Not to say I didn't become enriched learning the 3D modelling process, but I definitely could have gone without it.
hey im a brand new game developer I cant even claim the title yet as I have not released anything but I found your video and you give a lot of really great advice / info that's not being mentioned around the "for new dev" campfire so I just took the time to say thank you and im a subscriber now
I always like to think that of everything I'm trying to do, 95% of it is similar to what other people already have done (with few exceptions, this is true). For example, 'because' I had rendering issues, I looked for common ways to solve rendering issues and I learned about LOD groups (Level of Detail, switch between differently detailed meshes depending on its distance from the camera). The best part about this process is that I'm not guessing about my solutions, I'm making a few low poly meshes and KNOW they will work, because it has worked for ten thousands of people already. P.S. Yes, this applies to coding as well. Maybe you are doing a health system not 'quite' like everyone else, but if you're starting out it is a good idea to look what others have done with it.
The main camera problem is a good one! I had that issue for a long long time until I recognized it. That little bugger cost me many a hours before I found a post about it!
Lot of really good tips. I've personally done the whole scripting out a tutorial system as well, and quickly found how much of a pain it is compared to using animations and cinemachine and such. Also, appreciate the tip about Text Mesh Pro, hadn't read up on it yet but I have switched over and not looked back; way more performant.
im impressed by the way you explain things so clear, even to a total newbie. whenever i was thinking: "i hope he'll talk more about this stuff or explains this", you just talked about it :D thanks
My 2 cents. When I started out with Unity I forced myself not to concentrate on art at all, because from earlier experiences I learned that creating art leaves no energy on more important things such as game mechanics, level design, asset management etc. So when my game mechanics were working and I could move my character around I added some old graphical items I created years earlier realized, hey, this is perfectly okay for the time being and I moved on with the code. And when I got tired of coding I invested energy into art creation but didn't spent too much time on any graphical item or piece. So in the end years later I had a game which worked and there was a start and a finale and the graphics just came together in such way I could never even imagine at the beginning. But on the other hand I'm mostly a 3D guy so when I got tired of coding as a relaxation process I always polished the art bit by bit. So game mechanics first, art always as a second. Fortunately I jumped on the prefab wagon right in the beginning and that was a huge time saver. Prefabs and instancing. This came from 3D as I always preferred instances over static objects.
Unity3d College Jason, Great video. i consider you one of the unity-guru's on youtube ;) rohan koshti * TAG-ing * questions in valid. not always you can pre-configured and assign the object to your code with [serializedfield] or public. sometimes objects are instantiated at runtime, having an unmamaged name, all using the same prefab, so they are all having the same initial name + any number. the only method i use for this situation is tagging the prefabs so i can find them. i will be super glad to know if there is a better approach.
Some really great points but it would be really good if you could demonstrate potential alternatives. e.g. Object pooling in practice or what to use instead of FindByTag. You mentioned caching but that will mean nothing to someone starting out in Unity or new to coding. Hopefully my comments are constructive, all your points are valid and I'm more than guilty of carrying out a few of these mistakes.
Well many beginners are unaware of the fact or tend to forget that scripts fields get reset after game play mode is over, and those who don't might know how to keep the changes (using copy properties...) or don't find that efficient. That's where using scriptableobjects would save the day, specially when balancing a game with dozen parameters.
Make a public variable in the script and fill it in the inspector. This is the fastest and easiest way to do it. I highly discourage any find methods that scan the entire scene. It is really bad on performance especially if it's in an update loop. For ex. if you wanted to get the "ship" simply make it a public variable or add [SerializeField] on top of a private variable and drag the "ship" gameobject into the inspector. This does not require a search!
@@jonatan01i There is no good answer for this problem. References in inspector happen to be cleaned. Imagine lurking through whole project and setting everything again.
When profiling also make sure to verify that it's also happening on a standalone build (if building for desktops) or on device. Unity profiler behaves differently in editor than in standalone. :D Other than that good video recommended to some friends.
Great point. And everyone should definitely do testing in a release build as well. In addition to that, I've seen issues that only appeared in the release build and wouldn't show in the editor at all :)
Unity3d College we had a game that was something like a wii sports clone for kinect where you could select a list of minigames to play sequentially, if you tested trough the editor everything was alright but if you played the build every minigame was slightly more slow to load than the previous till it was unplayable. It took us a full month of angry feedback from the clients to find that was happening.
Have u ever used the pathfinder in unity? I think thats way more powerfull, and can even react dynamically. I would never use animation for something like that^^
Pathfinding requires a lot more resources than to make an object take a fixed path from point A to point B. My philosophy with programming in general is to not make any component do more than it needs to work.
@@zak9399 True, for one boat, it doesn't matter whether you use pathfinding or animations, because it's (often) too simple to affect performance anyways. Choose whatever is the fastest to implement or you keep wasting time on useless things.
You dont need to learn how to create artwork (models, animations, materials etc) from scratch. But its important to gain knowledge on how to manipulate existing art to make it fit with you project. EG: graphics editor (Photoshop, GIMP, Inkscape), PBR editor (like Materialize) and 3D editors (Maya, Blender).
Actually, it is not such a big problem. Methods like Awake and Start works once and you can use those methods at there with ease. Maybe you can just use constant types to pull the names. The problem starts if you use those methods in Update method, there it will make things slow. The solution would be to reference game objects from start method if possible, if not capture target objects via collision or trigger events. If this is not the case also, you can consider using object pooling. the main idea is, if you have to use methods like GameObject.FindWithTag() in Update method, just consider to Dispose all objects which are not used anymore in the screen. There are some techniques like publisher-subscriber pattern, therefore you only queue certain actions/game objects into a Service Broker and you listen those events/game objects and work with them. If you search Unity design patterns, there are lots of tutorials for those.
I get your point about the risk of renaming tags and breaking the game. But it's your responsibility as a developer to put safety nets: GameObject[] gameObjects; gameObjects = GameObject.FindGameObjectsWithTag("Enemy"); if (gameObjects.Length == 0) { Debug.Log("No game objects are tagged with 'Enemy'"); }
Right about the Animator! In my opinion, itt is the single most powerful tool in the Unity Suit. Now I use it for everything I can use it for, much better results than using code alone.
Using the Animator is useful and fast, but similar to visual scripting, it can have hard limitations. Learning tweening, and fulling utilizing DoTween can be equally important, and free you from a lot of limitations of always using animation clips.
Huh, I find the combination of animator/Mechanim and scripting to be really freeing. I can do the stuff that's easier to visualize, visually, and control my "hooks" via code. I'm actually looking forward to setting up cutscenes and the like with Cinemachine, based on some cool Unite talks from last year (2018).
Jason, love your content (and loved the Mastery Course you offer on your web site), but I have an alternative way to do the ship movement. Why not just put a navmesh on the water surface, and attach a NavMeshAgent to the boat to make it an "NPC"? Just make a very simple C# script that has an array of GameObject references for your waypoints, and any time the boat reaches its navigation target (within a threshold distance), you assign a random waypoint from the list as the next target. NavMeshAgent will handle all of the movement, smooth turning, and even acceleration and deceleration at the start and end of movement. Also, when you're done, you can easily move the waypoints around, add or delete them, etc., without changing any code or keyframes. An additional benefit of my approach is that you can just prefab the boat with its NavmeshAgent and then "rinse and repeat" to make multiple boats, with the same list of waypoints or with each boat having their own. The only tricky thing about this is if you also need navmeshes for other NPCs, in which case you need to make sure they are separated. As you're no doubt aware, there are several ways to do that, and I won't belabor the point here beyond mentioning it as a consideration to anyone who tries my suggestion. :) If your only other NPCs besides the boats would *also* be patrolling among waypoints, then you don't have to separate the navmeshes. Just make sure all the walking NPCs have their waypoints on land, and the boats' waypoints are all in the water, and use some invisible colliders as static navmesh obstacles to prevent the agents from choosing a path that enters or leaves the water.
BIG TIP FOR BEGINNERS: Break learning stuff into pieces, 1.Learn setting up Unity , Connecting Visualstudio , settingup SDK Learn basics of C#, basic thinks like variables,arrays , classes etc. LEARN how code works and executes 2. Learn About Unity Interface, and DON'T LEARN HOW TO MAKE A GAME DIRECTLY , instead first learn how basics are done- # importing stuff, creating gameobjects, creating and adding scripts , creating materials etc. #what are camera, light , 2d and 3d objects , etc. # learn what are Transforms, colliders, rigidbodies, mesh , renderer. NOW IT'S TIME TO START CODE FOR GAME.. learn different ways to move the gameobject , how physics works , play with movement + gravity . learn targeting and assigning things like materials from an array in a gameobject to randomly change materials of a object on a button click. ( using and assigning buttons and keypresses, and now in new system , using actionscripts. Start with small games, like, Flappy bird any walk and collect coin game simple jump and trigger button , open a chest and collect con feature game then move to shooters, camera changes , 3rd person , fps , camera move with object , following camera etc. learn creating firing system .. learn making UI and different levels , building APK , then move onto bigger projects ALL THE BEST
MonoBehaviour scrips have one huge advantage above normal c# classes, you can easy watch state of every variable in inspector setting on debug mode. To watch state of variable in c# class you must use debugger (VS 2017) and choose with specific variables do want watch Next advantage is option to connect two scripts by dragging one game object to other slot in inspector, in normal programing, without editor you must first create main class who creating and connecting all necessary elements in correct, save order
Thanks. the last point is important for me I think, I publish around 50% off the stuff im doing, but Im still doing the art AND the programming. But sometimes my friends help with the art, so its okay. But I know how it is to make a prototype and never touch it later :d
1) use a public variable and set it from outside with the object to use 2) if you must use find for data driven setups always use string constants instead of in-code stings that way the compiler can spot any typos and you are sure that string matches always hit. Also changing any string to a different name is done just changing the constants value. This also goes for EVERY string in code as far as I am concerned. And see to it that you only use find in awake or start so it is only executed once... then use the reference everywhere else
I remember watching your livestream when you did this tutorial. Love to see the final result. It was really helpful for me since from recently i also try to create unity tutorials, not as good as yours of course but yeah :). Very useful tips! Thanks for sharing!
Yeah I was a little disappointed with that. Knowing the monobehaviour is the view doesn't really help if I don't know where the actual logic is supposed to go...
There is one thing that is missing in the audio system though (for a reason unknown to me): Looping sounds with adjustable return point. What do I mean by that? Well, imagine having menu music in a game. It has a proper start (like fade in, progressively adding more instruments, etc.) and then there's the repetative part of the music that you want to loop forever. In short: when the music position reaches 01:20 jump back to 00:15 to make a loop. This is so frequently needed, and yet Unity has just ordinary looping system (entire clip is a loop, no specific looping points). That's just crazy. I have to create a script and hardcode the loop-start and loop-end points to make this work. And it's still not perfect, because the moment of looping is artificial, there's no proper prefetch, which can cause glitches during looping.
Pure wisdom in this video, agree with everything, and I was actually learning how to use DoozyUI these days (coincidence?). Tip: If you want to achieve the "finish a game" I recommend game jams, they make you learn how to deal with deadlines ;) I participated in 5 or 6 and I need to do it again!
do u have a raycasting vidio for moving in a space scene every one does a 2d on a plain but i need something that does a raycast.direction i get close but it just does not work right do u have one???
Man...you videos are really helpfull i am a new coder / game maker and i havent been able to finish a single game i always reach a point where i drop and reload
Hi. Total newbie here. I'm working on a 2D project. I pull up animator like he says, but it's not showing seconds/minutes, it's just showing frames (I guess) on the ruler. How do I change Animation to show seconds/minutes on the top ruler?
Do you have any suggestions or resources to explore regarding avoiding GameObject.FindObjectWithTag("")? I definitely was feeling I was going off the deep end using this to find objects and if there is a better way I should be working to get comfortable with I would love to know!
Around 4:50 Jason tells that not all your scripts must be a MonoBehaviours (your custom class not always must inherit from MonoBehaviour class), which is true, BUT! I think it is important to mention that this way you are loosing not only nice little Awake,Start,Update and other methods but ability to attach this script to any GameObject in general and, of course, use Editor tool with this script.
I think something is seriously wrong with my Unity. I’ve tried uninstalling and reinstalling multiple times but it always shows 400-500 errors and I can’t build. How do I fix this?
I see prefabs in Unity architecturally as 2 things, a Factory Design pattern with Dependency injection. especially now with the new prefab workflow, now it's more like an Abstract Factory. Another common thing that I see a lot is moving fast objects with transforms, or even using translate for everything, then ppl wonder why things are clipping through walls or even skipping them. You look thinner btw! X)
I usually go for a find object of type or a serialized reference. The biggest issue is find uses names and they're too easy to change without realizing you've broken something
If a unity script doesn't have to extend from monobehavior, then what can it extend from? What other options are there, and what features to they remove from monobehavior? I have a lot of systems I've designed for my game, and I'd love to cull out some unnecessary weight.
when should nad we should not use monobehavior? thats something that makes me really curious and i can't find good info on when i shouldn't use mono behavior
Extra -->> 1. Common mistake --> writing all code in single script. This is the biggest mistake most unity learners do. Instead make tiny scripts which only performs single task at all. Learn Single Responsibility Principle. 2. Building to different devices for unity UI testing. Instead use unity Device Simulator 3. Using same Canvas for all unity UI components. Separate Canvas. 4. Use Git 5. Don't do all by your own like art, sound, game design. You will never ever have mastery on all the things if you try to do all by your own. Focus on one thing at a time. 6. Biggest mistake - Stopping learning. Keep learning, keep practicing, keep helping. 7. Under-estimating Scriptable Objects (yes, don't dare to do so)
Quite often we programmers forget to read api documentation or actual tool which we use for programming, me myself when i work with Unity it feel quite natural (i am not game developer yet), but where i did struggle was in old tutorials , funny enough enough i was able to port the code from js to c# and it executed as expected....
Thanks Jason for this. I always watch your videos with my Evernote open, so I can take notes. I love the first point of using animations for repetitive movements. And also, I am one of the people whose every script inherits from monobehavior. :( Need to change that. xD
lol thanks, glad you enjoy them :) And if you wanna start moving away from every script being a monobehavior, try doing a bit of unit testing. It really helps me find the seams of the code and split things into testable chunks that aren't on monobehaviors :) And very least, it's a fun exercise :)
And unless you're making a hovercraft move around a flat surface using animations will probably take you longer to get things to look realistic using animations in Unity than it would to either animate outside of Unity and import the animation or add a script to simulate movement that's not just lerping from A to B but rather apply forces to a Rigidbody.
In my current project, I was using the terrain system with trees from Speedtree and trying to make a forest with on the borders of the levels. However, after adding a reasonable amount of trees, the game loses performance heavily (10-15 FPS), even with prefabs of mobile version of Broadtree. It's most likely because the game has two active cameras that make the scene render twice. But I'm making a split-screen co-op and hence, absolutely need both the cameras. Any way to make the game more efficient? (I haven't built it yet, only run it in the editor.)
hmmm... I think a lot of this is wrong. Code it yourself, and it's yours, and when you move onto another engine it is still yours. Grabbing prebuilt toolkits means grabbing toolkits that you don't understand and when (not if) they break you have the choice of deciphering what is usually fairly odd code or dropping hours of work. As longterm developers, we had to migrate to Unity, and probably should have migrated again, so this does happen. Understanding why something does whatever makes the job of moving it to another environment... well... possible. Nothing pre-built in or for unity is optimal to your game, it is attempting to be optimal to most games, and that is based on the premise that they know. "All that work" manipulating or animating stuff with code, usually pays, as it is then doing what you want when you want it (pre-update or post frame update can be a breaker on complex interactive objects). Also, do your own art, or better still get someone who is really good to do it for you. That is what makes the world diverse, and not just a mix-match of readymades. Crap is better than a clone of someone else's game.
OMG that first point hit home so much with me. For my final year university project we had to build a game over a year as a 6 man team. We had one programmer who believed he was the best programmer in the world. We needed a main menu screen animation so he decided to do it all in a single script, with a giant 50 step switch statement with each part of the animation being a function moving multiple game objects around. Not to mention he wasted 3 weeks "coding" scaling UI even after being told in the first day it came up as an issue that Unity can handle that for us. Rather then spending 3 seconds googling how to scale UI in unity he wasted 3 weeks on it, but at least he wasn't breaking core systems as a result
" best programmer in the world " HA HA HA HA
@@davkings52 yer, like i don't consider myself that great of a programmer. Infact throughout the project i found this channel to be an amazing resource. But this guy would legit refuse to even google like the most basic things rather being like ill just stuggle through on my own. He used raycasts at some poing to do with modifying one of my AI scripts and broke a super important system within the project. And when i asked him how this was possible he replied that he didnt really know how raycasts worked and that he had copy paste the code from the player controller script and edited it abit. And im just like why would you not just google it like the unity scripting api documentation is amazing.
I have a game for STEAM but having trouble putting it up there, there are no up to date tutorials for steam..have you put a game on steam..could you go over the process. I have paid the £80 fee and sorted my admin details
@@random_precision_software we did not release on steam as we did not feel it was up to a high enough quality we released on gamejolt and itch. Io soz but i can't help you in that regard
@@bringtmirleben8357 it's ok thanks for replying.👍
Mistakes I wish I'd known to avoid?
1: Overreach - Don't jump into Unity as new user with a huge complex game in mind. You'll end up confused, frustrated, and abandoning the project.
2: Prototype - As a programmer, work in iterations. Forget about the art, sound, and making the game fancy. Roughly build / code everything out first, then once you have a working game, iterate over and start replacing the temporary stuff. There is nothing worse than spending days making a level look amazing, only to find out later that you need to completely redesign it, because it just doesn't work well.
3: Knowledge - Learn as much as you can, but don't try and do everything at once. If you try and learn everything first, you'll never get to making a game.
Definitely great points there! I can't count the # of people who's first game was gonna be 'call of duty but an mmo' or something similar :) Shoot small and complete things first, then grow the ambitions :)
I find that working on little tutorial games is very educational, even as an experienced programmer. For one thing, every game, regardless of genre, shares certain key subsystems/architecture - graphics, audio, UI, gameplay loop - so working on something other than your passion project helps distill your focus on the core elements of "what is a game".
For another, you never know which tutorial is gonna have some tips/tricks that save you hours/days/weeks down the line. Unity especially has a lot of "hidden features" that can either trap or save you.
Definitely prototype first before coding! Good tips!
@@Unity3dCollege don't just "prototype" Make small games (I call them toys) that experiment with a feature, shader renderer, Release it, film it, tweet it. These little toys, when released into the wild, become projects that can be picked up and modified later, or you want to re-use an idea, but make it wierd, you have that idea encapsulated in a small project you can play with. Once you have your idea fleshed, Make 1 folder, move all your prefabs code models and stuff into a single directory then use unity's asset export package to bundle that up for use in another project, putting it all in one directory keeps your sanity if you want to make changes
I'm not a professional programmer yet i know a few things that should be done first:
1. use templates, images and sprites of of others while you work and make them work in your game the way you intended and when core game mechanics are good make your art/buy your own art and implement.
2. focus on the core game mechanics - not UI, no character looks, and no game objects placement etc... focus on controls and core game mechanics such as combat, motions/controls, skills, traveling, teleporting w/e...
3. plan ahead and make your game scale-able, challenging and engaging, use friends for feedback.
4. focus on one game - we many times have lots of ideas and start creating new game mid-way of the first game. dont do that. you want to finish your game right?
So fucking true!!!!
The thing I wish I knew when starting unity: learn the difference between update and fixed update before you start diving in to coding. Nothing kills your flow like realizing that your movement is attached to your framerate. It's a basic one, but one of the more valuable things when familiarizing yourself with the coding structure. One is strictly for rendering and gpu oriented tasks, the other works on a fixed timer and should be used for anything physics/movement/action oriented.
I think this happened in fallout 76 where characters would zoom across the map at walk speed because their framerates were so high and their movement speed was attached to that instead of a fixed timer. Ever try to play wing commander on a later computer system and realize everything was going lightspeed? That's why.
Fixed doesn’t care if you’re a laggy potato it does what it does in a specific time. Update is every frame so if you’re a toaster whatever is running in that update will die
@@warsin8641 what if you overwhelm the fixed update with super slow functions?
As a long-time game developer, the single most important point in this entire video:
FINISH THE GAME
I cannot highlight that enough.....
Also the showing people the game - yes, on places like the io websites, but please, not on the Google Play store - it'll get lost, no one will see it, and we really don't need any more "this is my first ever game" games on there.
Have any good io websites for first-time publishers?
Agreed!
I'd add to that - if your first game ever would happen to have some unique mechanic and maybe, just maybe, get a tiny bit popular on Google Play, it may get into crosshairs of studios like Ketchapp, or that other french one, and they'll just clone it but with better visuals, monetize and use the might of their marketing to push it high, but you as the original creator will not see a single penny and if you try to defend yourself you'll probably get sued, like it happened with the original author of the Candy game that King.com cloned (and made their super popular Candy Crush Saga). If you don't believe me - just google it, it was widely covered in game media at the time.
@@NGC7603 any sources on how to publish a mobile game as an indie without having it stolen by big studios?
The single most important aspect of successful software is (drum roll):
IT MUST SHIP!!!
One thing that many people doesn't know is that animator controller could be used as Finite State Machine, even when there isn't any animation to control. You can take advantage of all functionality and event manager for any kind of object that need a FSM
Wow this changed my life, incredible tip!
And its a very dangerous state machine if animations ARE there, because this state machine can be at two states at once while going from one animation to another. Cost me a lot of headaches already. Had to write some layer on top of it to behave like a real state machine with just one state at a time.
What do you mean by "could be used as a Finite State Machine"?
I dont understand what you mean
@@cosmotect this mean that you can attach a Animator Controller on any object and use it to define steps (states), conditions to transition between those steps, even when you don't have animations related with the Animator Controller.
1 - The Asset Store - Someone out there has way more time & interest than you in coding some arcane subsystem. Just make sure there's still active maintenance & plenty of documentation. Same goes for art/music - even a couple hundred bucks (USD) can take your entire game a big step up from "programmer art". Focusing on what you're good at, and outsourcing the rest, doesn't make it any less *your* game.
2 - Version Control - Because your "one-man-team" may someday be 100, or because next year, you won't remember what that clever method actually does.
3 - Play mode tint - So you never accidentally forget that your changes will be deleted when you hit Stop.
Great video!
pretty sure you just said "Dont use this method for finding a game object or this one or this one THEYRE ALL SHITE" then proceeded to not give the best method to do this
pls forgibe me senpai you are right. I think he missed to say that we need to use reference technic, when you create property and assign object via editor. I was advised to do so by experienced game makers and found it very useful. Plus try to assign events from editor... once project gets big and you start forgetting who is sending whom data, you no longer can make changes fast. I stead assign all events in Awake or better Start method. I made this mistake and now regret it.., trying to migrate to new, correct way
Serialize them on the Editor so thet are alreadt referenced
I usually use "FindObjectOfType" for me is the best option
I was thinking this too lol. At 8:06 it sounds like he mentions very quickly something about caching and using "find object of type"? But people in this thread say that isn't efficient. Is Serializing from the editor the best way then?
@Ahmed Yasir until for whatever reason your scene references get nulled out and you have to go back and fix them all
After 10 years as a commercial game developer and 3 years Indie, your advice is still a welcome kick in my teeth when I start to get complacent. Thanks for the great vids dude.
The thing that I regret most not knowing about earlier are: Scriptable Objects.
This is the most worth comment there.
I never needed them,
I can't find the use for them when I have the new prefab system.
@@HAWXLEADER there are tons of uses! There are good talks about them too! Inventory system, audio system, heck even as an event system I have seen them used. You can do many cool things with them!
@@QuesterDesura I wish I could "see" the usefulness of them I bet they are as useful as interfaces and inheritance but I just don't see it yet unless you build a game with multiple types of one thing(like bricks, cards tons of monsters etc...).
@@HAWXLEADER once you used then once you will love them :)
Hey Jason thanks for all the great content. Useful video for anyone who wants to learn all the built-in power of Unity3D. I love your channel bc there are so precious few high level coding tutorials on youtube. Endless amounts of beginners teaching programming and most don't consider the bigger picture/ architecture of their project. It's fast and easy to wire stuff up in Unity3D so usually the spaghetti references/code can be fine for smaller works but this approach quickly fall apart on larger scale or long form games. Your architecture videos are super helpful and your videos make me think about code differently! Thanks for all the long winded explanations my friend they are much appreciated :) .
Rarely do I find such quality tutorials/informational videos on TH-cam. Loved it!
I've started making my game in Xcode. I had to "learn" objective-c and swift. And I was f***ing frustrated on every IOS-update (broken code on release date - on every update!). What causes me to switch to unity. And this was the day as the sun re-appears. We should be happy about having it. And thank you for your tips. For some of them, it's not too late to solve.
I had the same experience! :)
fuck xcode it literally doesnt even work for me anymore
If you have lots of UI or heavily animated UI you should separate ir in different canvases. It looks ugly but it’s better for performance because a single change in an ui element in a canvas will make Unity redraw and recalculate everything for that canvas.
Nice tip!
-personal fave tip covered in video, "if talking about performance, don't guess! - use the profiler."
Excellent info, especially for us experienced programmers coming from non-game dev backgrounds.
Summery -->>
1. Can use unity animation system for object movement sometimes (can use DoTween for simple tween animations as well)
2. Best use of prefabs
3. Don't user mono all the times, can use plain simple class or helper class when needed. Or can use observer pattern to make it more action based rather than making it mono (update) based
4. Use Profiler to check memory or performance spikes
5. Use TextMeshPro instead of unity UI Text
6. Timeline for Tutorial
7. Cinemachine for Camera Controller
8. Don't do all like creating art, sound etc. Focus on programming/development only
For me as a JavaEE developer, your tutorial series is so spot on... Thanks a lot!
then what should i replace with gameobject.findwithtag and gameobject.find then?
Use direct references instead.
Example:
public class Example {
public GameObject AnObject;
public void Start() {
AnObject.position = new Vector3(1, 2, 3);
}
}
@@LaurentK That only works if you do drag and drop, which is tedious, slow and unorganized. Let alone Unity like to drops references all the time. It's way smarter to let GameObjects register themselves in their own Start() in a centralized place.
@@Giga4ever why would using a public variable only work with drag and drop ??
@@LaurentK Because If you already know the gameobject to add the reference from somewhere else, there is no need to find it..
@@LaurentK Yeah, I don't doubt that.
Another great video. I'm learning more and more if I'm trying to code something there is almost always a simpler, quicker and less prone to bugs way to complete that same task. I have to keep reminding myself that the players of your game won't care what's happening behind the scenes. Thanks for the video!
I wish this existed LONG before I really got into Unity. That being said, one thing you really missed out on is talking about Scriptable Objects. In my project, I am currently rewriting all the character variables that frequently get called in outside scripts, such as the player health, is the player alive, etc. Too do this before, I would first have to make sure the player object even existed, find it, and THEN read the entire script off of it game object just to get a single variables value.. This is a quick way to eat performance, especially when you have a lot of stuff in the scene that has to check if the player is still alive before continuing it's processing. I just recently started to transition to scriptable objects for performance reasons. It's helping remove a LOT of the nested programming, making accessing external variables faster and cleaner, AND allows for better control for what gets read and what doesn't.
I am new to Unity, started working on my first 2D game few weeks ago, I felt this video is spot on, except for "Find" and "FindObjectWithTag", I read and heard a lot about how bad they are, but none of them mention an alternative! keep in mind that this is supposed to be for programmers new to Unity.
Aside from that I find most of the other points helpful, thank you
A lot of it will be how the rest of the asset is designed. Example: if you're trying to find another part of the same prefab, then you can have the other gameobject (or, better, the specific component) be a public variable that's linked in the prefab editor. When it's instantiated, Unity will do the links automatically.
That will be different if the object is something else random in the scene... but then why are you finding it? Could it have been given to you in a collision or raycast, linked public variable in scene editor (not necessarily good but could be better in certain contexts), etc. etc. etc.?
A blanket replacement is not really possible. Need to know more.
Man I love you. There's just a real genuine and humble approach to every video you do. You are clearly a smart guy with bags of ability but it feels like you almost gloss over that in an effort to relate to new developers and their struggles.
I'm trying to teach myself how to code and you are pretty much the only guy that gives me real hope. Thanks.
Hey, I used to watch a lot of your videos a few years back, will get back into it, just wanted to say you look way more healthy nowadays, congrats!
thx :) feeling a lot better too!
Dang first time realize u can move an object with a mouse but locked on the same plane by where u click on the axis . Been using unity for a year. Wow shows how u should learn basics first first. Good vid
Hi!
I like how you point it out. as a beginner i find ths very helpful, but it would be very nice if you show alternative way of how to do things if you don't recommend doing that thing. thanks for uploading this video!
Jason this is so awesome and all of your content is fantastic man you’re a legend!
I never even knew about the profiler, until now! This is such a great video, very informative. Thank you so much for posting it!
Thanks for making this! I'm the exact person that needed to see this. I try and remake everything instead of checking for existing tools.
The Cinemachine one drives me NUTS. I'm studying game development, and when I hear my classmates gripe about how hard it was to code some 'super fancy' camera I can't help but roll my eyes. Cinemachine does it 10x better and it's so easy to use. They have no excuse not to use it either, since our professor even showed us how to use it.
Some of my mistakes were;
1. I used to declare bunch of unnecessary stuff instead of using lists.
2. Instantiating and destroying instead of pooling.
3. Learned way too late more about the UI system, the beauty of the rect transform, masks and more.
4. TextMeshPro, the ability to add strokes to your text opens so many more visual styles.
5. Not sure what this is called exactly but making your scripts into instances on Awake() so you can access the functions from other scripts
After watching countless videos where people jump right into coding was at first like wow, I have a lot of work to do. But after this my dude I will be checking all the engine tools first before even looking at my coding.
You worked with some of the most influential games in my time. It's sad to hear what killed vanguard, but your videos are helping me craft my vision, thanks!
These videos are perfect for software devs who are new unity game devs thanks man
That last tip is great advice I learned the hard way. I jumped into game development thinking I had to do everything on my own, the programming, the art, the music, etc, but then I realized I was way in over my head, even though the concept I was developing was a simple mobile game. I spent 3 months learning how to do 3D modelling before realizing I can just buy assets that fit my needs on the Asset Store. Not to say I didn't become enriched learning the 3D modelling process, but I definitely could have gone without it.
hey im a brand new game developer I cant even claim the title yet as I have not released anything but I found your video and you give a lot of really great advice / info that's not being mentioned around the "for new dev" campfire so I just took the time to say thank you and im a subscriber now
I always like to think that of everything I'm trying to do, 95% of it is similar to what other people already have done (with few exceptions, this is true). For example, 'because' I had rendering issues, I looked for common ways to solve rendering issues and I learned about LOD groups (Level of Detail, switch between differently detailed meshes depending on its distance from the camera). The best part about this process is that I'm not guessing about my solutions, I'm making a few low poly meshes and KNOW they will work, because it has worked for ten thousands of people already.
P.S. Yes, this applies to coding as well. Maybe you are doing a health system not 'quite' like everyone else, but if you're starting out it is a good idea to look what others have done with it.
The main camera problem is a good one! I had that issue for a long long time until I recognized it. That little bugger cost me many a hours before I found a post about it!
Lot of really good tips. I've personally done the whole scripting out a tutorial system as well, and quickly found how much of a pain it is compared to using animations and cinemachine and such. Also, appreciate the tip about Text Mesh Pro, hadn't read up on it yet but I have switched over and not looked back; way more performant.
Thank you! This video made me feel better.
Really good tips. I'm coming from enterprise development and I do exactly those mistakes he is mentioning. Thanks for sharing this.
im impressed by the way you explain things so clear, even to a total newbie. whenever i was thinking: "i hope he'll talk more about this stuff or explains this", you just talked about it :D thanks
Alright, you got me with Camera.main. Been using Unity for years too. That's some pretty critical insight to have hidden.
My 2 cents.
When I started out with Unity I forced myself not to concentrate on art at all, because from earlier experiences I learned that creating art leaves no energy on more important things such as game mechanics, level design, asset management etc. So when my game mechanics were working and I could move my character around I added some old graphical items I created years earlier realized, hey, this is perfectly okay for the time being and I moved on with the code.
And when I got tired of coding I invested energy into art creation but didn't spent too much time on any graphical item or piece. So in the end years later I had a game which worked and there was a start and a finale and the graphics just came together in such way I could never even imagine at the beginning. But on the other hand I'm mostly a 3D guy so when I got tired of coding as a relaxation process I always polished the art bit by bit. So game mechanics first, art always as a second.
Fortunately I jumped on the prefab wagon right in the beginning and that was a huge time saver. Prefabs and instancing. This came from 3D as I always preferred instances over static objects.
Unity3d College Jason, Great video. i consider you one of the unity-guru's on youtube ;)
rohan koshti * TAG-ing * questions in valid.
not always you can pre-configured and assign the object to your code with [serializedfield] or public.
sometimes objects are instantiated at runtime, having an unmamaged name, all using the same prefab, so they are all having the same initial name + any number.
the only method i use for this situation is tagging the prefabs so i can find them.
i will be super glad to know if there is a better approach.
imo the best way is to not search (or rather "find") gameobjects at all. if you instantiate you get a reference back, make use of it ...
@@nein3405 i DO use it as my first choice. it sure gives a solid control. 'find' is the poor alternative i'm forced to use :)
Best UNITY Tutorial I've ever seen! Thank you Very much for taking time to help us out!!
Some really great points but it would be really good if you could demonstrate potential alternatives. e.g. Object pooling in practice or what to use instead of FindByTag. You mentioned caching but that will mean nothing to someone starting out in Unity or new to coding. Hopefully my comments are constructive, all your points are valid and I'm more than guilty of carrying out a few of these mistakes.
Well many beginners are unaware of the fact or tend to forget that scripts fields get reset after game play mode is over, and those who don't might know how to keep the changes (using copy properties...) or don't find that efficient. That's where using scriptableobjects would save the day, specially when balancing a game with dozen parameters.
That’s never been a huge issue for me but I used to forget I’m in play mode sometimes
This helps tremendously. I spent weeks on Unity porting my custom animation code that took me years... unity does it better and faster
Great video! I literally learned like 3 different important things in this video! Great job.
7:14 - 9:38
You talk about how not to find things but you didn't tell us how to do that.
Can you please give an advise?
Thank you.
Make a public variable in the script and fill it in the inspector. This is the fastest and easiest way to do it. I highly discourage any find methods that scan the entire scene. It is really bad on performance especially if it's in an update loop. For ex. if you wanted to get the "ship" simply make it a public variable or add [SerializeField] on top of a private variable and drag the "ship" gameobject into the inspector. This does not require a search!
@@CrypticCode This is helpful, thank you so much!
@@jonatan01i There is no good answer for this problem. References in inspector happen to be cleaned. Imagine lurking through whole project and setting everything again.
When profiling also make sure to verify that it's also happening on a standalone build (if building for desktops) or on device. Unity profiler behaves differently in editor than in standalone. :D Other than that good video recommended to some friends.
Great point. And everyone should definitely do testing in a release build as well. In addition to that, I've seen issues that only appeared in the release build and wouldn't show in the editor at all :)
Unity3d College we had a game that was something like a wii sports clone for kinect where you could select a list of minigames to play sequentially, if you tested trough the editor everything was alright but if you played the build every minigame was slightly more slow to load than the previous till it was unplayable. It took us a full month of angry feedback from the clients to find that was happening.
Great presentation man, thanks for the mental download!
Have u ever used the pathfinder in unity? I think thats way more powerfull, and can even react dynamically. I would never use animation for something like that^^
you have point
Pathfinding requires a lot more resources than to make an object take a fixed path from point A to point B. My philosophy with programming in general is to not make any component do more than it needs to work.
@@zak9399 True, for one boat, it doesn't matter whether you use pathfinding or animations, because it's (often) too simple to affect performance anyways. Choose whatever is the fastest to implement or you keep wasting time on useless things.
You dont need to learn how to create artwork (models, animations, materials etc) from scratch. But its important to gain knowledge on how to manipulate existing art to make it fit with you project. EG: graphics editor (Photoshop, GIMP, Inkscape), PBR editor (like Materialize) and 3D editors (Maya, Blender).
7:14~ 9:37 So what's the solution to this problem?? Can anyone tell me, please?
Actually, it is not such a big problem. Methods like Awake and Start works once and you can use those methods at there with ease. Maybe you can just use constant types to pull the names. The problem starts if you use those methods in Update method, there it will make things slow.
The solution would be to reference game objects from start method if possible, if not capture target objects via collision or trigger events. If this is not the case also, you can consider using object pooling. the main idea is, if you have to use methods like GameObject.FindWithTag() in Update method, just consider to Dispose all objects which are not used anymore in the screen.
There are some techniques like publisher-subscriber pattern, therefore you only queue certain actions/game objects into a Service Broker and you listen those events/game objects and work with them. If you search Unity design patterns, there are lots of tutorials for those.
@@reyou7 OK, I got it. Thank you very much !
I get your point about the risk of renaming tags and breaking the game. But it's your responsibility as a developer to put safety nets:
GameObject[] gameObjects;
gameObjects = GameObject.FindGameObjectsWithTag("Enemy");
if (gameObjects.Length == 0)
{
Debug.Log("No game objects are tagged with 'Enemy'");
}
Claps in wisdom
Right about the Animator! In my opinion, itt is the single most powerful tool in the Unity Suit. Now I use it for everything I can use it for, much better results than using code alone.
Using the Animator is useful and fast, but similar to visual scripting, it can have hard limitations.
Learning tweening, and fulling utilizing DoTween can be equally important, and free you from a lot of limitations of always using animation clips.
Huh, I find the combination of animator/Mechanim and scripting to be really freeing. I can do the stuff that's easier to visualize, visually, and control my "hooks" via code. I'm actually looking forward to setting up cutscenes and the like with Cinemachine, based on some cool Unite talks from last year (2018).
Incredibly helpful tips. Thank you for this!!
Jason, love your content (and loved the Mastery Course you offer on your web site), but I have an alternative way to do the ship movement. Why not just put a navmesh on the water surface, and attach a NavMeshAgent to the boat to make it an "NPC"? Just make a very simple C# script that has an array of GameObject references for your waypoints, and any time the boat reaches its navigation target (within a threshold distance), you assign a random waypoint from the list as the next target. NavMeshAgent will handle all of the movement, smooth turning, and even acceleration and deceleration at the start and end of movement. Also, when you're done, you can easily move the waypoints around, add or delete them, etc., without changing any code or keyframes.
An additional benefit of my approach is that you can just prefab the boat with its NavmeshAgent and then "rinse and repeat" to make multiple boats, with the same list of waypoints or with each boat having their own.
The only tricky thing about this is if you also need navmeshes for other NPCs, in which case you need to make sure they are separated. As you're no doubt aware, there are several ways to do that, and I won't belabor the point here beyond mentioning it as a consideration to anyone who tries my suggestion. :)
If your only other NPCs besides the boats would *also* be patrolling among waypoints, then you don't have to separate the navmeshes. Just make sure all the walking NPCs have their waypoints on land, and the boats' waypoints are all in the water, and use some invisible colliders as static navmesh obstacles to prevent the agents from choosing a path that enters or leaves the water.
BIG TIP FOR BEGINNERS: Break learning stuff into pieces,
1.Learn setting up Unity , Connecting Visualstudio , settingup SDK
Learn basics of C#, basic thinks like variables,arrays , classes etc. LEARN how code works and executes
2. Learn About Unity Interface, and DON'T LEARN HOW TO MAKE A GAME DIRECTLY ,
instead first learn how basics are done-
# importing stuff, creating gameobjects, creating and adding scripts , creating materials etc.
#what are camera, light , 2d and 3d objects , etc.
# learn what are Transforms, colliders, rigidbodies, mesh , renderer.
NOW IT'S TIME TO START CODE FOR GAME..
learn different ways to move the gameobject ,
how physics works , play with movement + gravity .
learn targeting and assigning things like materials from an array in a gameobject to randomly change materials of a object on a button click. ( using and assigning buttons and keypresses, and now in new system , using actionscripts.
Start with small games, like,
Flappy bird
any walk and collect coin game
simple jump and trigger button , open a chest and collect con feature game
then move to shooters,
camera changes , 3rd person , fps , camera move with object , following camera etc.
learn creating firing system .. learn making UI and different levels , building APK ,
then move onto bigger projects
ALL THE BEST
MonoBehaviour scrips have one huge advantage above normal c# classes, you can easy watch state of every variable in inspector setting on debug mode. To watch state of variable in c# class you must use debugger (VS 2017) and choose with specific variables do want watch
Next advantage is option to connect two scripts by dragging one game object to other slot in inspector, in normal programing, without editor you must first create main class who creating and connecting all necessary elements in correct, save order
Thanks! This was really useful, especially for object pooling
Thanks. the last point is important for me I think, I publish around 50% off the stuff im doing, but Im still doing the art AND the programming. But sometimes my friends help with the art, so its okay. But I know how it is to make a prototype and never touch it later :d
what are some alternatives to gameobjects.find which work better then?
1) use a public variable and set it from outside with the object to use
2) if you must use find for data driven setups always use string constants instead of in-code stings that way the compiler can spot any typos and you are sure that string matches always hit. Also changing any string to a different name is done just changing the constants value.
This also goes for EVERY string in code as far as I am concerned. And see to it that you only use find in awake or start so it is only executed once... then use the reference everywhere else
One of the best Unity teacher!
I remember watching your livestream when you did this tutorial. Love to see the final result.
It was really helpful for me since from recently i also try to create unity tutorials, not as good as yours of course but yeah :).
Very useful tips!
Thanks for sharing!
Subtle plug. But I’m interested. I’ll watch it vids
A comparison to MonoBheavirour and views was made, so what would be the controller? ScriptableObjects?
Yeah I was a little disappointed with that. Knowing the monobehaviour is the view doesn't really help if I don't know where the actual logic is supposed to go...
There is one thing that is missing in the audio system though (for a reason unknown to me): Looping sounds with adjustable return point. What do I mean by that?
Well, imagine having menu music in a game. It has a proper start (like fade in, progressively adding more instruments, etc.) and then there's the repetative part of the music that you want to loop forever. In short: when the music position reaches 01:20 jump back to 00:15 to make a loop. This is so frequently needed, and yet Unity has just ordinary looping system (entire clip is a loop, no specific looping points). That's just crazy. I have to create a script and hardcode the loop-start and loop-end points to make this work. And it's still not perfect, because the moment of looping is artificial, there's no proper prefetch, which can cause glitches during looping.
Jason is the House M.D. of Unity, but with a nicer public personallity :D
Pure wisdom in this video, agree with everything, and I was actually learning how to use DoozyUI these days (coincidence?). Tip: If you want to achieve the "finish a game" I recommend game jams, they make you learn how to deal with deadlines ;) I participated in 5 or 6 and I need to do it again!
do u have a raycasting vidio for moving in a space scene every one does a 2d on a plain but i need something that does a raycast.direction i get close but it just does not work right do u have one???
Man...you videos are really helpfull i am a new coder / game maker and i havent been able to finish a single game i always reach a point where i drop and reload
You just saved my life with the garbage controller so nice !
Hi. Total newbie here. I'm working on a 2D project. I pull up animator like he says, but it's not showing seconds/minutes, it's just showing frames (I guess) on the ruler. How do I change Animation to show seconds/minutes on the top ruler?
The last few suggestions is very nice, thanks!
Thank you Jason for another great video! :) Very useful!
very welcome!
500 baby!
Do you have any suggestions or resources to explore regarding avoiding GameObject.FindObjectWithTag("")? I definitely was feeling I was going off the deep end using this to find objects and if there is a better way I should be working to get comfortable with I would love to know!
Around 4:50 Jason tells that not all your scripts must be a MonoBehaviours (your custom class not always must inherit from MonoBehaviour class), which is true, BUT! I think it is important to mention that this way you are loosing not only nice little Awake,Start,Update and other methods but ability to attach this script to any GameObject in general and, of course, use Editor tool with this script.
I think something is seriously wrong with my Unity. I’ve tried uninstalling and reinstalling multiple times but it always shows 400-500 errors and I can’t build. How do I fix this?
I see prefabs in Unity architecturally as 2 things, a Factory Design pattern with Dependency injection. especially now with the new prefab workflow, now it's more like an Abstract Factory.
Another common thing that I see a lot is moving fast objects with transforms, or even using translate for everything, then ppl wonder why things are clipping through walls or even skipping them.
You look thinner btw! X)
This is a very good point on prefabs! I like the description :)
You suggested how not to find game objects, but what's your suggestion to getting game objects within script?
I usually go for a find object of type or a serialized reference. The biggest issue is find uses names and they're too easy to change without realizing you've broken something
nice bump in production quality jason!
11:50 what if i need somthing like a gun shooting. How can i avoid that making the bullets spawn?
If a unity script doesn't have to extend from monobehavior, then what can it extend from? What other options are there, and what features to they remove from monobehavior?
I have a lot of systems I've designed for my game, and I'd love to cull out some unnecessary weight.
Thanks for the video! And additional gratitude for mentioning cinemachine, never heard of it before, and it's very cool!
when should nad we should not use monobehavior? thats something that makes me really curious and i can't find good info on when i shouldn't use mono behavior
Do more of these. Love this topic.
Extra -->>
1. Common mistake --> writing all code in single script. This is the biggest mistake most unity learners do. Instead make tiny scripts which only performs single task at all. Learn Single Responsibility Principle.
2. Building to different devices for unity UI testing. Instead use unity Device Simulator
3. Using same Canvas for all unity UI components. Separate Canvas.
4. Use Git
5. Don't do all by your own like art, sound, game design. You will never ever have mastery on all the things if you try to do all by your own. Focus on one thing at a time.
6. Biggest mistake - Stopping learning. Keep learning, keep practicing, keep helping.
7. Under-estimating Scriptable Objects (yes, don't dare to do so)
I rarely subscribe, but this channel worth my click!
Quite often we programmers forget to read api documentation or actual tool which we use for programming, me myself when i work with Unity it feel quite natural (i am not game developer yet), but where i did struggle was in old tutorials , funny enough enough i was able to port the code from js to c# and it executed as expected....
Thanks Jason for this. I always watch your videos with my Evernote open, so I can take notes.
I love the first point of using animations for repetitive movements.
And also, I am one of the people whose every script inherits from monobehavior. :( Need to change that. xD
lol thanks, glad you enjoy them :)
And if you wanna start moving away from every script being a monobehavior, try doing a bit of unit testing. It really helps me find the seams of the code and split things into testable chunks that aren't on monobehaviors :) And very least, it's a fun exercise :)
And unless you're making a hovercraft move around a flat surface using animations will probably take you longer to get things to look realistic using animations in Unity than it would to either animate outside of Unity and import the animation or add a script to simulate movement that's not just lerping from A to B but rather apply forces to a Rigidbody.
What's the alternative to find with tags?
In my current project, I was using the terrain system with trees from Speedtree and trying to make a forest with on the borders of the levels.
However, after adding a reasonable amount of trees, the game loses performance heavily (10-15 FPS), even with prefabs of mobile version of Broadtree.
It's most likely because the game has two active cameras that make the scene render twice.
But I'm making a split-screen co-op and hence, absolutely need both the cameras.
Any way to make the game more efficient? (I haven't built it yet, only run it in the editor.)
LOD and Billboard the ones far from camera.
Hi Jason - I notice that you haven't released a video in a while - hope all is well at your end, and I look forward to seeing your next video
What is the alternative we should be using to find and find with tag?
hmmm... I think a lot of this is wrong.
Code it yourself, and it's yours, and when you move onto another engine it is still yours.
Grabbing prebuilt toolkits means grabbing toolkits that you don't understand and when (not if) they break you have the choice of deciphering what is usually fairly odd code or dropping hours of work.
As longterm developers, we had to migrate to Unity, and probably should have migrated again, so this does happen. Understanding why something does whatever makes the job of moving it to another environment... well... possible.
Nothing pre-built in or for unity is optimal to your game, it is attempting to be optimal to most games, and that is based on the premise that they know.
"All that work" manipulating or animating stuff with code, usually pays, as it is then doing what you want when you want it (pre-update or post frame update can be a breaker on complex interactive objects).
Also, do your own art, or better still get someone who is really good to do it for you. That is what makes the world diverse, and not just a mix-match of readymades. Crap is better than a clone of someone else's game.
Re the art thing:
There's a reason why my art is only in "bad art demos".