One thing to add to this, in this example I used an interface to make the connection abstract from both sides in code, but that's not the only way to do it. For example, in my course, which this example is from, I ended up using a Unity Event. The end result is similar, except that the fire display doesn't need to actively do anything.
Been doing gamedev for around 2.5 years and this is still something that I sometimes struggle with. It has improved the longer I’ve been coding, but sometimes still difficult to decide. Thanks for the video!
the text display in your video is aesthetically pleasing. And the you do a great job in giving options, not doctrines. That's rare in the coding scene :)
Your channel is insanely underrated! I also want to note that the blog's on the website are really useful too! When I am actually working in Unity I prefer reading than watching a video, so it's really helpful!
This is exactly what I'm dealing with right now for my school project. I'm either abstracting everything to eternity or can't seperate a class properly fearing of communication between parts will be pain in the ass in future. I guess practice will be the answer to this problem. I will pick a way and it will cause problems when I decide to change something in future and I will learn from it and improve my decision making in future projects. Not doing anything because of fear of failure is always worse than doing something and fail.
This is how I usually do Unity scripts: Usually if something that has movement its all in a movement script for that game Object and then a separate animations script that handles the animations. For everything else if its a global variable I use containers via scriptable objects. UI script for UI systems. Interactions are usually done on the Game Object's movement script unless its a global then I have a dedicated script that handles like a bullet hitting a game Object so it adds force. I like to have my scripts used in a global setting not just to 1 game Object specifically. A door script can have just a door script to every door or if its a portal then a portal script to every portal and have the scene loaded in as a string array and u pick what scene it will go to from that array etc. This is helpful thinking and I enjoyed the video.
@@GameDevBeginner Ohhh I heard that, what’s the next alternative? Only one I have found that runs good on Mac on par is Rider, paid unfortunately ): But great with Unity
I'll probably try VS Code next, or whatever is offered up with Unity by default, if only for the sake of using what beginners will ultimately use too. I have heard Rider is good though.
Imo, single responsibility is best used when dealing with AI behavior. For most other scripts it's just about a free for all. But doing things like splitting up the jump behavior then allows you to adjust exactly how that jump behavior will work as well. Take it to the next step you can store the behavior as a SO which can be swapped as needed.
@@GameDevBeginner More than an idea, it's my usual approach, honestly I'd love to share my state machine architecture with anyone I come across, if you are interested. I have 0 talent for doing videos but I feel the SM would benefit a lot of people.
@@chizuru1999 It is and it's a shame because, even though VS Code has gruvbox themes, none of them look exactly like my visual studio one, which I love!
@@GameDevBeginner Yes bro. They feel totally different lol. And I guess its something to do with apple not allowing it. And its a headache to maintain the visual studio for linux/mac. Last time I checked it works on mono only. Thankfully I mostly use win for work 😁
So in your example, does the fireDisplay still subscribe to OnThrust action defined in IMoveable? And all IMoveable objects can invoke that action when they move?
to be fer i use all kind off method's. for example the player movement for my game have movement,jump,ground check all on the same code and it's interesting for all the other codes. however some code in my game is like chin because i haven't though for better system for example on the game im working on is multiple game and many off my weapons i will have the same type off ammo, that means i need to have 2 codes one for the ammo type and one for whatever weapon the use the same ammunition. in general i prefer to make evry code impeding with each other in few words to work on it's own but unfortunately for that is not possible for my project the reason is because my game is complex and some system's have to refresh other codes one good example for this is the PlayerHelth for my game it have 3 or more code in the order to work's correctly 1. one code that it's just the player health. 2. that is hurt box. 3. whatever object dealing damages to the player my point no matter what wii do wean i make health for my player i have to use at least 2 code one for the health and the other in the order to do the damage or heal the player. and i don't even mention all the other part that effects by the for health like kill death ect, that it's crucial in multiplayer PvP fps Game.
The Action? it's a ready made delegate, with a void return type and that takes, in this case, a float. I only put system in front of it because I hadn't added the System namespace to the top of the class. See this video for more: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-J01z1F-du-E.htmlsi=RWUbPiRSqMOxD8UG&t=398
From what I've heard here, I don't think I'd ever want to work with you. Instead of using the simplest principles to write good code, it seems like you write bad code and then put a lot of thought into justifying your misdeeds by misinterpreting those principles.