Improve Your Unity Code with MVC/MVP Architectural Patterns

Ойындар

Demystify MVP and MVC Architecture for Unity in simple terms focusing on the Separation of Concerns and a practical example building an MMO style hotbar using a Model, View and Controller.
🔔 Subscribe for more Unity Tutorials / @git-amend
Discord: / discord
#unity3d #gamedev #indiedev
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 MVC/MVP Overview
3:51 Hotbar Overview
4:17 Model
6:17 View
9:30 Controller
Source code:
MVC Ability System: gist.github.com/adammyhre/af9...
ObservableList: gist.github.com/adammyhre/fa6...
Preconditions: gist.github.com/adammyhre/82d...
Timer.cs : github.com/adammyhre/3D-Platf...
Assets Shown In This Video (Affiliate Links)
Cartoon Fantasy UI: assetstore.unity.com/packages...
Eole Foliage Shader: assetstore.unity.com/packages...
Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
Kronnect Beautify: assetstore.unity.com/packages...
Kyeoms VFX: assetstore.unity.com/publishe...
Follow me!
linktr.ee/gitamend

Пікірлер: 125

  • @git-amend
    @git-amend5 ай бұрын

    Hey everyone, hope you find this video helpful in understanding Separation of Concerns with the MVC or MVP patterns. Code links are in the description. Let me know if you have more questions and if we need a 3rd episode on this topic!

  • @carlwong1919
    @carlwong19195 ай бұрын

    Finally found a tutorial that not only talks about the three core MVC components, but also shows how to create and connect them. Really helpful.

  • @git-amend

    @git-amend

    5 ай бұрын

    Right on! Glad to hear that!

  • @Hersatz
    @Hersatz5 ай бұрын

    Great explanation and contextualization, as always. MVC, MVP, and MVVM are staples of proper UI architecture in video games. I'm glad that someone is finally taking the time to show people an actual implementation of one of them.

  • @git-amend

    @git-amend

    5 ай бұрын

    Well said! Thanks for the comment!

  • @IdealIdleIncremental
    @IdealIdleIncremental5 ай бұрын

    Thank you for this super-useful video! Every time I see an update on your channel, I immediately know that there's a new video worth watching. Please keep up the good work!

  • @git-amend

    @git-amend

    5 ай бұрын

    You're very welcome!

  • @jordanbarker803
    @jordanbarker8035 ай бұрын

    Incredibly well done. The way you showed the diagram first, explained it, then jumped back and forth between code and diagram to show which part was being implemented was really helpful. Just found your channel, looking forward to checking out the rest of your content. Keep up the great work!

  • @git-amend

    @git-amend

    5 ай бұрын

    Thank you very much!

  • @orbalmas7539
    @orbalmas75392 ай бұрын

    First thing, great video! I have been working as an Android Developer for 7 years now, implementing MVC, MVP and then MVVM in all my projects. One note about the video, It is not best practice to tightly couple the Controller to the view, as then you lose what you wanted, which is separation of concerns. In order to achieve that, you could use the Observer pattern and remove the dependency of the view from the controller. This is desirable because it makes the code more testable, and you get the extra benefit that if you are going to make changes to your view, no changes are needed to your controller as it is truly separated. I love your videos. I started my long-standing dream of game development and have been glued to all your videos since. Keep up the great work! 👍

  • @jvizcode4845
    @jvizcode48455 ай бұрын

    Your videos work for me as glue. Making all that I have learned come together. Now I have a new perspective and that's a big help, more than I could ask. Thank you very much.

  • @git-amend

    @git-amend

    5 ай бұрын

    You are so welcome!

  • @k3ln
    @k3ln5 ай бұрын

    you're the greatest man, I needed this so much! I've been doing this all the time in my past years on web development, it didn't occur to me to try something similar for game development, this is great, thanks

  • @git-amend

    @git-amend

    5 ай бұрын

    You're very welcome!

  • @VladaPersonal
    @VladaPersonal5 ай бұрын

    It is rare to have unity tutorials that go this deep. But this is exactly what I need to get to the next level! Thanks alot! I just feel like having the videos in a series might be a good idea? When I watch this video there are some things I missed and having a structure/order in which to go through the videos would be great! Even if the reality is to watch all of them, episode number for example would indicate it well. But I understand the title has other needs as well...

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks for the comment! Unfortunately having an episode number on KZread is a bit problematic because new viewers don't want to jump in if they feel like they need to commit to watching a bunch of earlier content, which makes it really hard to grow the channel. While I try to make every video stand on its own, if I reference something from an earlier video - like the Event Bus - I try to include a card in the video with the link. If you really want to watch it all, start with the Patterns playlist and then the Architecture one after that. These playlists are in the order the videos were made.

  • @baselpro5228
    @baselpro52285 ай бұрын

    Your videos are fantastic keep it up 🙌

  • @git-amend

    @git-amend

    5 ай бұрын

    Thank you! Will do!

  • @antijulius
    @antijulius5 ай бұрын

    Seriously, thank you so much for putting out this level of content.

  • @git-amend

    @git-amend

    5 ай бұрын

    My pleasure!

  • @junaidywijaya6413
    @junaidywijaya64135 ай бұрын

    This is something I've heard for quite a while and seen a bit of it but never understand what it really is and how to really implement it, thank you for this video to make me understand a bit of it, might need to watch it couple times so i can really grasp the true idea, but as always a great video from Adam.. keep it up man, i know u will be big 😄

  • @git-amend

    @git-amend

    5 ай бұрын

    Thank you!

  • @TheArghnono
    @TheArghnono5 ай бұрын

    Another great video! Glad to see there is at least one Unity youtuber who writes modern code.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks for the kind words!

  • @user-kv4fr3qm8v
    @user-kv4fr3qm8v3 ай бұрын

    Loved the Unity Game Architecture series! Suggesting a playlist reorder for better flow: Start with 'SIMPLE Tip,' then 'Improve Your Unity Code with MVC/MVP,' and end with 'Learn Unit Testing.' Amazing work and best wishes!

  • @git-amend

    @git-amend

    3 ай бұрын

    Thanks! More to come!

  • @echoness_
    @echoness_5 ай бұрын

    Thank you for the detailed walkthrough. It would be awesome if you can introduce how to structure MVVM and data binding in Unity.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thank you - actually data binding is on my list, I'll get to that one soon!

  • @mhouney
    @mhouney9 күн бұрын

    I hopr some people can learn from my mistake: I used the Event-Bus inside a system, which lead to a confjsing structure inside a mvp system. I learned that the Event-Bus is very nice for communicating between different mvp systems. Inside a system I used then simple public Actions on my view that forwards the events to the presenter and the presenter decodes what to do. I dont know if this is the best approach, but it worked pretty well for me.

  • @mhouney

    @mhouney

    9 күн бұрын

    Another question: Would it be a good idea to have multiple views? (E. .g with 3 different interfaces) Currently I solve this by using 1 view that contains other "views" woth SerializeField.

  • @abraiyan7984
    @abraiyan79845 ай бұрын

    Lets goooo! Thanks for this.

  • @git-amend

    @git-amend

    5 ай бұрын

    You bet!

  • @halivudestevez2
    @halivudestevez25 ай бұрын

    finally someone is using diagrams for teaching and telling. The diagram at 4:00 makes many things clear.

  • @git-amend

    @git-amend

    5 ай бұрын

    Good to hear!

  • @ekekw930
    @ekekw9305 ай бұрын

    Awesome stuff!!

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks!

  • @rehrocks
    @rehrocks5 ай бұрын

    Nice video as always, and I've already started the MVC course on Udemy to learn more about it.

  • @git-amend

    @git-amend

    5 ай бұрын

    Great to hear!

  • @TheKarchi
    @TheKarchi4 ай бұрын

    Great tutorial! Do you think you could use a bigger font in the IDE in your future videos to make the code easier to read when watching on mobile?

  • @Cloud-Yo
    @Cloud-Yo4 ай бұрын

    I was wondering if you were considering doing a video on developing features for a game w TTD? awesome stuff as always!

  • @git-amend

    @git-amend

    4 ай бұрын

    Maybe... but game devs don't like tests so much...

  • @Cloud-Yo

    @Cloud-Yo

    4 ай бұрын

    @@git-amend I certainly dont, and I have studied them some, but a lot of studios hiring seem to love to post them in the requirements for positions. In any case, I guess I hope you can get around to it, but its fine if not :)

  • @Broudy001
    @Broudy0015 ай бұрын

    Another great video, I need to implement it to get my head around it though. I'd be interested to see you go through a set of tutorials where you build out a game using the patterns, like a vertical slice of a game using the patterns. Would be a huge amount of work though I'd expect, and I would assume you already have plenty on your plate :D. Could be a paid course, I'd definitely pay for it.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks for the comment! One of these days I'll take that course suggestion on, just need a month off work!

  • @Broudy001

    @Broudy001

    5 ай бұрын

    @@git-amendI imagine it would be a lot of work to setup. Either way I've learnt a ton from your videos , and look forward to every new one that comes out

  • @mongreldesigns9195

    @mongreldesigns9195

    4 ай бұрын

    +1 for a larger paid course, your videos are gold.

  • @techdave99
    @techdave995 ай бұрын

    @git-amend There is a rogue if statement in the posting of the ability mvc system. In the gist line 145. The if statement doesn't belong to anything (not in a method) and throws an error. Also, AbilityCommand is not defined. Will post this in discord too.

  • @git-amend

    @git-amend

    5 ай бұрын

    Alright thanks, will look at it

  • @Kingdomax
    @Kingdomax5 ай бұрын

    Thanks for the demonstration. I wonder what other use cases can be used with MVC/MVP pattern(apart from UI system).

  • @git-amend

    @git-amend

    5 ай бұрын

    You're welcome. In that demo scene I actually also have the score system and the player controller implemented as MVC, but the ability system seemed to be the best one to show for the video since the view was more involved.

  • @uhhmir
    @uhhmir5 ай бұрын

    ObservableList? i can feel a reactive programming episode coming😳😳

  • @git-amend

    @git-amend

    5 ай бұрын

    Haha maybe so!

  • @kr1s85
    @kr1s855 ай бұрын

    Coming from Java Enterprise development, it's nice to see examples of how to implement those patterns in Unity. Great work! ⚔⚔⚔⚔ Where would you trigger SFX cues? Would you build an observer that listens to the Event Bus or inside the view?

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks! My first thought was just to say, yeah I'd have a separate observer on the Bus. However, maybe not for all sfx. If it was UI sfx, that really is part of the View I would think, like mouse click sounds etc, and doesn't have to be played in 3D space either. And, potentially you could also have sfx be played directly by the ability command with AudioSource.PlayClipAtPoint which creates an audio source at any point in the world. I guess in the end, it really depends... but I think for most, I would raise an event onto the bus and let another system handle it.

  • @MaxVinopalDev
    @MaxVinopalDev5 ай бұрын

    Great content as always, said it before, but it is so great to have these intermediate videos in sea of for-beginner stuff! One question - in a game like Dragon age, where player can switch between different characters, would you have the MVC/MVP combo for each of the characters, or would you have just one and build the switching logic inside? Having it for each of the characters makes more sense for me, but id like to know your perspecitve :) Thanks!

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks! That's an interesting question. I think for a Dragon Age style I can see how having one for each character would make sense. Just be careful of any state that needs to be shared between them and take that into account somehow if necessary in case you have any data they all need access to or if they need to communicate with each other.

  • @MaxVinopalDev

    @MaxVinopalDev

    5 ай бұрын

    @@git-amend Will keep that in mind, thanks!

  • @ronnistrm1167
    @ronnistrm11674 ай бұрын

    Through out the years I have been bitching to my fellow software developer friends on how shitty every youtuber is when it comes to programming in unity. (from the perspective of a programmer) I will like to thank you for spending time figuring out how to utilize great patterns and concept from the world of programming inside unity. Working as professional software developer I know and work with a lot the patterns you show. But I never really have the time to figure out how use it probably in unity. Thank you for saving us time on "inventing the wheel" Keep up the good work!

  • @git-amend

    @git-amend

    4 ай бұрын

    That is very high praise, thank you very much. More to come!

  • @mitchellg8469
    @mitchellg84694 ай бұрын

    Thanks, this has been really helpful and detailed! If I want to change what is being presented on the UI depending on what the player has selected, how would you go about that. Should the model be changed depending on the selection? Also if the data is to be changed at runtime I would guess I would probably not use a scriptable object and just use a normal c# class? For my use case I want to have selectable towns that have stats that change during play. Thanks again!

  • @git-amend

    @git-amend

    4 ай бұрын

    I would add functionality to the Controller so that it can change your model at runtime. The data could still be in scriptable objects, just pass the SO to the Model from the Controller. The Model can then change from using one SO to the new one for it's data. Remember that the Model isn't necessarily the same as data that you want to persist - but you can use it to read and write to a scriptable object.

  • @mehmedcavas3069
    @mehmedcavas30695 ай бұрын

    Yess part 2. can you also make a video how UI should me made with old UI system. I mean how to handle multiple canvases to decrease rerender the whole canvas or even make a separated UI scene

  • @git-amend

    @git-amend

    5 ай бұрын

    Not a bad idea, I'll put that on the list. There have been a lot of requests about UI Toolkit as well, but I think most people are still on the old system.

  • @arjanb7158
    @arjanb71585 ай бұрын

    Great stuff, thanks! The past two videos made me wonder a couple things: * What sort of gameplay stuff would you still do on MonoBehaviours? Do you delegate collision events and Transform-changes to non-Monobehaviours, too? (As with the Update(deltaTime) function.) * I can see dependencies being injected in the non-MonoBehaviours, but would you still use the editor to specify dependencies for MonoBehaviours? * Would all your MonoBehaviours depend on concrete classes, since the editor doesn't serialize interfaces? What does this mean for mocking in your tests?

  • @git-amend

    @git-amend

    5 ай бұрын

    You can still make use of methods like OnTriggerEnter, Update, FixedUpdate etc, but many progammers will gravitate more and more towards encapsulating the logic associated with these things into pure C# classes that can be easily tested and swapped. As far as MonoBehaviours depending on concrete types, often yes this is unfortunately the case. However, I have another video planned regarding serializing Types which you will probably find interesting, in a few weeks or so. You can also use Odin to reference interfaces through the Inspector.

  • @sandrawiedel5411
    @sandrawiedel54115 ай бұрын

    Thanks for excellent tutorial .. like always. May i ask, what software do you use for you diagrams? They look really nice!

  • @git-amend

    @git-amend

    5 ай бұрын

    You’re welcome! Right now I use SketchWow but I’m going to try Excalidraw this week

  • @Kritikkkk
    @Kritikkkk3 ай бұрын

    Thanks for the video, it is a rare occasion to see such topics about MVC and Unity. Although MV* patterns (as well as Zenject and UniRx) are considered standard in post soviet countries (and I thought that it is caused by the fact that many devlopers came to game development having a enterprise app background where such features are a must). I am wondering how popular are MV* patterns in development studios? What other techniques are considered standard in your opinion? Also the topic of separation of concerns is very interesting to me, and is there any other methods like MV*?( as I understand that it isn't supposed to fit all scenarios)

  • @git-amend

    @git-amend

    3 ай бұрын

    To be honest, not too many people apply these kinds of patterns to their Unity games, but I would also say that MVVM could be included. But it's application might be as simple as separation of concerns with data binding. I think data binding will be the topic of a future video.

  • @techdave99
    @techdave995 ай бұрын

    Another video worth getting up early to watch. I thought that mvc/p would be hard to implement in Unity. Looks like it is worth using.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks for watching! You must be west coast like me.

  • @techdave99

    @techdave99

    5 ай бұрын

    @@git-amendYes I am. I am on Vancouver Island. For some reason I thought you were on the east coast.

  • @git-amend

    @git-amend

    5 ай бұрын

    Nice, I lived in Sidney for about a year back in 2019.

  • @nuin9937

    @nuin9937

    5 ай бұрын

    ​@@techdave99 fellow vancouver island fella, you doing/did global game jam?

  • @techdave99

    @techdave99

    5 ай бұрын

    @@nuin9937 no. i'm not really a jammer. Did you? what did you make?

  • @claudiogallardo6383
    @claudiogallardo63835 ай бұрын

    Great video as always! I am a seosoned Spring MVC developer and this explanation makes Unity so much approchable for me. Following your videos there is so much code and utilities I see myself using in my test after test projects. Would you recommend me to create my own unity packages with the systems you have explained? I guess the EventBuss would be tricky due to the assambly part...

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks! I think you could create packages if you wanted, it can be useful sometimes. Just remember that if you are creating an embeddable package it becomes immutable. I was thinking about making a video about this at some point. The Unity documentation is actually pretty good: docs.unity3d.com/Manual/CustomPackages.html and I recently moved the Unity-Utils repo to be a package that you can install from the git, you could look at that as an example.

  • @claudiogallardo6383

    @claudiogallardo6383

    5 ай бұрын

    @@git-amend gr8! thanks

  • @chicho9238
    @chicho92383 ай бұрын

    Hey, I've been following your awesome channel for some time and I've been able to really capitalize on all the programming design knowledge you share. That being said, I'm having some trouble applying MVP (or rather framing it) for my current project: I have some purchaseable upgrades, each of which I want to put on a button on a scrollable list with its name on the button. When you hover over one of these an info window appears right next and inlcudes the name of the upgrade (again), its cost and a description. When you click the upgrade button it tries to spend your resources (which I've got in an ScriptableObject) and purchases and applies the associated upgrade. Though, I've tried a couple of times and consulted sources (as you said in the video, everyone puts a twist on the model), I'm not sure if I'm extracting the right things that each part of the architecture should expose. My thoughts are that: View is an observable and a "settable" that gets passed to the Presenter (either if view creates it or not); Model is again an observable for when it changes and a settable; Presenter gets the Model and View injected by the constructor and subscribes to view events and model events, additionally it exposes methods to take input from other systems. In my tries to model the architecture for my project I've tried to abstract these roles to reutilize them, because you can see it somewhat a complex list of views to update and handle correctly. But it just doesn't click that much.

  • @git-amend

    @git-amend

    3 ай бұрын

    It's clear you're putting a lot of thought into applying the MVP pattern to your project. It's important to remember that these architectural patterns lare fundamentally about separation of concerns. For your upgrades and scrollable list of buttons, consider the following: View: The View should be as dumb as possible - it displays what the Presenter tells it to and signals the Presenter about user actions (e.g., hovering over or clicking a button). The View doesn't know what happens when a button is clicked; it just knows to inform the Presenter of the click. Presenter: Receives inputs from the View (e.g., a button click) and decides what to do with them. It might check if the player has enough resources for the upgrade, update the Model accordingly, and then tell the View to display a success or failure message. The Presenter should be the one knowing which View to update and how, based on interactions and data changes. Model: Should notify the Presenter (not the View directly) when data changes, so the Presenter can update the View. Your ScriptableObject that tracks resources could be part of the Model. Your thoughts on making the View and Model observable and "settable" and having the Presenter manage interactions and updates are on the right track. The flexibility of MVP comes from the ability to abstract and reuse the Presenter and View logic for different parts of your UI, not from strict adherence to rules about what each component does. In practice, the boundaries can blur, especially in complex or interactive UIs. The key is to keep the core idea of separation of concerns in mind rather than sticking too rigidly to definitions. For instance, if it makes more sense for a complex interactive element to handle some of its own logic for performance or user experience reasons, that's okay as long as the overall structure remains clear and maintainable. Finally, it's perfectly normal to iterate on your architectural design as your project evolves. Sometimes, you only find the right abstraction level or component responsibilities through trial and error. Keep experimenting, and adjust the roles of Model, View, and Presenter as needed to best fit your project's needs.

  • @DadMakesGamez
    @DadMakesGamez5 ай бұрын

    Great episode, it explains the topic very well, it’s pleasant to listen and watch. Being on the architectural patterns, can you say what you think about ECS? At first glance, it has the same advantages as MVC (encapsulation, data separation from behavior, etc.) but with contiguous memory usage and better performance. I would love to know your opinion.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks for the comment, I appreciate that. ECS is very powerful, and I've been asked to talk about it many times - but I also wonder why. Do people struggle with it because it's a different (and more complex) paradigm, or possibly because Unity dragged it's feet in this area for so long that people lost interest - or has nobody been able to explain it in a manner that makes it approachable. I suspect it's the first reason. I wonder if showing a hybrid solution might get people interested. Maybe I'll read through some of the comments on a some newer content about it and figure out what's holding people back, might make a good video. What do you think holds people back the most from using ECS?

  • @DadMakesGamez

    @DadMakesGamez

    5 ай бұрын

    It seems to me that for a long time, the problem was the instability and backward incompatibility between versions. Looking at versions 0.5 and 1.0, it’s like a night and day (though in a good way). I even considered using svelto.ecs instead of Unity’s for quite a while. But yes, I agree with you that the main problem is the paradigm shift in thinking.

  • @christian-loock
    @christian-loock2 ай бұрын

    I am currently trying to implement this kind of pattern. What I am struggeling with right now is, how to integrade third party assets, like for example a character controller, since a lot of the character control logic lives inside those assets.

  • @git-amend

    @git-amend

    2 ай бұрын

    The approach is always different depending on the Asset. Most often for integration you might need to consider using an Adapter or Bridge to act as a middleman. This will create a nice Seam between your code and the Asset. We're going to talk about Seams as a way of separating code quite a bit in tomorrows video.

  • @ekekw930
    @ekekw9305 ай бұрын

    How did you create your UI? Is it an asset pack? Im checking for some good looking globes I can use and these look amazing

  • @git-amend

    @git-amend

    5 ай бұрын

    That one is from the store - assetstore.unity.com/packages/2d/gui/cartoon-fantasy-gui-74743 The globes aren't animated though, so I would probably replace them with either ones from Moon Tribe: assetstore.unity.com/packages/2d/gui/icons/ultimate-health-bar-collection-178690 or Kronnect: assetstore.unity.com/packages/vfx/shaders/liquid-volume-pro-2-129967

  • @BrontoKroxig
    @BrontoKroxig5 ай бұрын

    I'm really curious about which software are you using to draw your diagrams :O

  • @git-amend

    @git-amend

    5 ай бұрын

    I have been using SketchWow, but I think I might try Excalidraw for the next video

  • @Patricebrouh
    @Patricebrouh4 ай бұрын

    Hi! Great video. I am also interested in PC movement. I notice that when PC jumps, camera doesn't follow. How do you achieve it? Thanks

  • @git-amend

    @git-amend

    4 ай бұрын

    Thanks, and great question. One day I'll make a longer video about building a custom player controller like this. Basically, under the top most game object I have two children - one branch for the model and another branch for camera items. In the camera branch there is a 'camera target' game object which the camera aims at. So if something in the model branch moves, nothing in the camera branch moves, but the entire player moves them all. So essentially I'm achieving this by separating the model from the camera, but they both have the same parent.

  • @Patricebrouh

    @Patricebrouh

    4 ай бұрын

    @@git-amend Thank you for your answer. It helps me so much. I look forward to watching this video about player controller 🙏🏽

  • @attevirginie96

    @attevirginie96

    3 ай бұрын

    I am interested in this functonnality too.

  • @omeryilmaz1021
    @omeryilmaz1021Ай бұрын

    is there any utility folder or collection that I can find of yours which includes features like CountDownTimer, observablelist and etc.

  • @git-amend

    @git-amend

    Ай бұрын

    A lot of the small helpers are just in Gists - you can find all of that here: gist.githubusercontent.com/adammyhre/ Otherwise, check the Unity Utility repository here: github.com/adammyhre/Unity-Utils

  • @omeryilmaz1021

    @omeryilmaz1021

    Ай бұрын

    @@git-amend thank you very much I will work on them

  • @junaidywijaya6413
    @junaidywijaya64134 ай бұрын

    Hey Adam, i have a question and maybe an idea, so whenever i want to create a new feature often i don't really know how many modules I'm gonna need and how deep it's going to be, so do you have tips on planning it like your flow chart.. thanks in advance

  • @git-amend

    @git-amend

    4 ай бұрын

    What I would do is start with a skeleton UML diagram so you can see it visually. A tool like excalidraw.com/ is very useful. Draw out your first draft and draw lines where you see dependencies - make sure none of them form a loop! Once you being coding, don't be afraid to refactor. Then go back to your diagram and update it, so you make sure it still makes sense to you. Just practice and never stop learning new things, and you'll get better and better at it. Your best tool is going to be experience and knowledge. Have a read through the object and class diagrams sections of this page: www.c-sharpcorner.com/UploadFile/nipuntomar/uml-diagrams-part-1/

  • @junaidywijaya6413

    @junaidywijaya6413

    4 ай бұрын

    @@git-amend thank you will check it for sure 👍

  • @MarushiaDark316
    @MarushiaDark3165 ай бұрын

    I've always found the terminology around MCV to be rather unintuitive, but if I understand correctly, it's basically just saying to keep your Logic, Data, and Visuals all separate from each other.

  • @git-amend

    @git-amend

    5 ай бұрын

    Yeah, that's pretty much it.

  • @aleksapetrovic7088
    @aleksapetrovic70882 ай бұрын

    How/where would you execute the abilities logic? What I've often encountered is that I have spells/abilities/whatever which highly vary in the things that they do. My first assumption is to have an abstract method where each concrete implementation would handle the logic in their own way. The issue I've encountered with that many times is that they often require different data passed onto them to perform the necessary logic, while the abstract definition clearly defines which parameters must be passed. It's a really annoying thing I've never managed to solve properly..

  • @git-amend

    @git-amend

    2 ай бұрын

    Typically I use the Command pattern for this. Each command is different, but can employ it's own Strategies for targeting, effects and so on.

  • @KuroUsagi1010
    @KuroUsagi10102 ай бұрын

    Hello, the "Key" and the "Keyboard" in the AbilityButton class. from which namespace was it? it's not appearing on my Visual Studio. and when i tried the System.Windows.Input. the Keyboard class doesn't know about the "current" . sorry about the newbie question

  • @git-amend

    @git-amend

    2 ай бұрын

    docs.unity3d.com/Packages/com.unity.inputsystem@1.8/api/UnityEngine.InputSystem.Key.html The Key enum is from Unity's New Input System.

  • @KuroUsagi1010

    @KuroUsagi1010

    2 ай бұрын

    @@git-amend Oh thanks! I'll check later if it's available in Unity 2022.2f

  • @damonfedorick
    @damonfedorick5 ай бұрын

    Nice.

  • @git-amend

    @git-amend

    5 ай бұрын

    Thank you! Cheers!

  • @damonfedorick

    @damonfedorick

    5 ай бұрын

    @@git-amend you don't need to respond if you don't want too, i just want to boost the algorithm.

  • @git-amend

    @git-amend

    5 ай бұрын

    @@damonfedorick Any you've boosted it again - which I appreciate haha!

  • @krishx007
    @krishx0075 ай бұрын

    Thanks for saying that there is something called "Over engineering". 😅🙏 People often conflate separation of concerns with over engineering but there's a big difference between writing quality code and adding unnecessary features. Over engineering happens when we lose sight of our actual needs and start building for hypothetical situations that may never occur. Quality code is about creating a system that's maintainable scalable and understandable. kzread.info/dash/bejne/qGaXl5pygsTPp7w.html

  • @git-amend

    @git-amend

    5 ай бұрын

    You're welcome! 😀

  • @StratoCatster
    @StratoCatster4 ай бұрын

    Hello! How do you unsubscribe a button if you subscribed a method to it via a lambda?

  • @git-amend

    @git-amend

    4 ай бұрын

    You can completely clear out the delegate list of a Unity button's onClick event by setting it to a new instance of the event, like button.onClick = new Button.ButtonClickedEvent();.

  • @krishx007
    @krishx0075 ай бұрын

  • @git-amend

    @git-amend

    5 ай бұрын

    Thanks!

  • @JasonLovettGameDev
    @JasonLovettGameDev5 ай бұрын

    Why does this feel like it makes things way more complicated than it has to?

  • @git-amend

    @git-amend

    5 ай бұрын

    These patterns may appear complex at first, but are effective in handling complexity in larger or evolving projects. While less critical in smaller projects, the principle of Separation of Concerns is still a mark of quality coding in projects of any size.

  • @Briezar

    @Briezar

    5 ай бұрын

    yeah it doesn't matter if you're making something as simple as Flappy Bird and development would stop there. But once your project gets bigger, something as "simple" as a character controller in a Mario game with logic execution, data, and UI all in 1 MonoBehaviour class will make the class bloat to several thousand lines and heavily coupled. Any change to any element would affect multiple places, and bugs would become hard to track and unexpected. It's usually at this point when the programmer starts to think back and wondered if he had structured the code better, constrained the UI to what it does best (visual update) and only allow passing in necessary information for it to update, then he wouldn't have to shuffle up the entire class. Ease of access = ease of bugs. Something wrong with the visual? It's probably in the View class. The character turns left when your press right + down? Probably in the Controller. The character deals too much damage with an ability? Probably the model (stat bug) or controller (math bug). At the end of the day, it's all about preferences. If you find it unnecessary for your project, by all means just do it. Your coding style will develop as you code more, and you would gradually understand the important of code engineering.

  • @JasonLovettGameDev

    @JasonLovettGameDev

    5 ай бұрын

    I guess I’ve never worked on a project of that size that warrants this yet. I’ve made literally a hundred games without these and it’s been fine, but they were hyper casual games/ indie games. I find if I did this in those games it would have slowed us down quite a lot, but I had to rapidly prototype. So it seems this is really preferable for very large scale projects, in which case I would probably use Unreal anyway lol

  • @Briezar

    @Briezar

    5 ай бұрын

    @@JasonLovettGameDev the gain isn't in the development speed, it's in the maintenance. Slapping singleton and public static on everything is the fastest way to make games, albeit not very scalable nor maintainable. From what I've experienced, anything larger than hyper-casual requires some engineering else it would be a nightmare to fix, update, and add features. Unreal is probably when you wanna make AAA games lol.

  • @JasonLovettGameDev

    @JasonLovettGameDev

    5 ай бұрын

    Thanks for the replies, I actually agree. Really appreciate the feedback as it helps crystalize it in my mind.@@Briezar

Келесі