Improve Your Unity Code with MVC/MVP Architectural Patterns

Sdílet
Vložit
  • čas přidán 25. 06. 2024
  • 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
  • Hry

Komentáře • 125

  • @git-amend
    @git-amend  Před 5 měsíci +12

    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
    @carlwong1919 Před 4 měsíci +12

    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  Před 4 měsíci +2

      Right on! Glad to hear that!

  • @Hersatz
    @Hersatz Před 5 měsíci +11

    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  Před 5 měsíci

      Well said! Thanks for the comment!

  • @orbalmas7539
    @orbalmas7539 Před 2 měsíci +1

    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! 👍

  • @IdealIdleIncremental
    @IdealIdleIncremental Před 5 měsíci +5

    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!

  • @jordanbarker803
    @jordanbarker803 Před 4 měsíci

    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!

  • @jvizcode4845
    @jvizcode4845 Před 4 měsíci +3

    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.

  • @k3ln
    @k3ln Před 4 měsíci +1

    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

  • @VladaPersonal
    @VladaPersonal Před 4 měsíci +3

    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  Před 4 měsíci +4

      Thanks for the comment! Unfortunately having an episode number on CZcams 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.

  • @antijulius
    @antijulius Před 5 měsíci

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

  • @baselpro5228
    @baselpro5228 Před 5 měsíci +2

    Your videos are fantastic keep it up 🙌

  • @TheArghnono
    @TheArghnono Před 5 měsíci +1

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

    • @git-amend
      @git-amend  Před 5 měsíci +1

      Thanks for the kind words!

  • @junaidywijaya6413
    @junaidywijaya6413 Před 4 měsíci

    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 😄

  • @user-kv4fr3qm8v
    @user-kv4fr3qm8v Před 3 měsíci

    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!

  • @halivudestevez2
    @halivudestevez2 Před 4 měsíci +1

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

  • @abraiyan7984
    @abraiyan7984 Před 5 měsíci

    Lets goooo! Thanks for this.

  • @ekekw930
    @ekekw930 Před 5 měsíci

    Awesome stuff!!

  • @echoness_
    @echoness_ Před 5 měsíci +2

    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  Před 5 měsíci +4

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

  • @rehrocks
    @rehrocks Před 4 měsíci

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

  • @TheKarchi
    @TheKarchi Před 4 měsíci

    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?

  • @mhouney
    @mhouney Před 6 dny

    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 Před 6 dny

      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.

  • @Cloud-Yo
    @Cloud-Yo Před 4 měsíci

    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  Před 4 měsíci +1

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

    • @Cloud-Yo
      @Cloud-Yo Před 4 měsíci +1

      @@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 :)

  • @uhhmir
    @uhhmir Před 4 měsíci

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

  • @Broudy001
    @Broudy001 Před 4 měsíci +2

    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  Před 4 měsíci +1

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

    • @Broudy001
      @Broudy001 Před 4 měsíci

      @@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 Před 4 měsíci

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

  • @kr1s85
    @kr1s85 Před 5 měsíci +1

    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  Před 5 měsíci +2

      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
    @MaxVinopalDev Před 4 měsíci +1

    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  Před 4 měsíci +2

      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 Před 4 měsíci

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

  • @ronnistrm1167
    @ronnistrm1167 Před 4 měsíci +1

    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  Před 4 měsíci

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

  • @techdave99
    @techdave99 Před 5 měsíci

    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  Před 5 měsíci

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

    • @techdave99
      @techdave99 Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci +1

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

    • @nuin9937
      @nuin9937 Před 5 měsíci

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

    • @techdave99
      @techdave99 Před 4 měsíci

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

  • @Kingdomax
    @Kingdomax Před 4 měsíci

    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  Před 4 měsíci +1

      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.

  • @arjanb7158
    @arjanb7158 Před 4 měsíci

    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  Před 4 měsíci

      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.

  • @Kritikkkk
    @Kritikkkk Před 3 měsíci

    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  Před 3 měsíci +1

      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.

  • @mehmedcavas3069
    @mehmedcavas3069 Před 5 měsíci

    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  Před 5 měsíci +2

      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.

  • @sandrawiedel5411
    @sandrawiedel5411 Před 4 měsíci

    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  Před 4 měsíci

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

  • @claudiogallardo6383
    @claudiogallardo6383 Před 4 měsíci

    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  Před 4 měsíci +1

      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 Před 4 měsíci

      @@git-amend gr8! thanks

  • @techdave99
    @techdave99 Před 4 měsíci +1

    @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  Před 4 měsíci

      Alright thanks, will look at it

  • @mitchellg8469
    @mitchellg8469 Před 4 měsíci

    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  Před 4 měsíci

      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.

  • @DadMakesGamez
    @DadMakesGamez Před 4 měsíci

    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  Před 4 měsíci +3

      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 Před 4 měsíci

      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.

  • @BrontoKroxig
    @BrontoKroxig Před 4 měsíci

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

    • @git-amend
      @git-amend  Před 4 měsíci +1

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

  • @ekekw930
    @ekekw930 Před 4 měsíci

    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  Před 4 měsíci +1

      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

  • @MarushiaDark316
    @MarushiaDark316 Před 4 měsíci +1

    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  Před 4 měsíci +1

      Yeah, that's pretty much it.

  • @chicho9238
    @chicho9238 Před 3 měsíci

    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  Před 3 měsíci +1

      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.

  • @damonfedorick
    @damonfedorick Před 4 měsíci

    Nice.

    • @git-amend
      @git-amend  Před 4 měsíci +1

      Thank you! Cheers!

    • @damonfedorick
      @damonfedorick Před 4 měsíci

      @@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  Před 4 měsíci +1

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

  • @christian-loock
    @christian-loock Před 2 měsíci

    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  Před 2 měsíci

      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.

  • @krishx007
    @krishx007 Před 4 měsíci +1

    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.
    czcams.com/video/v2c589RaiwY/video.html

  • @Patricebrouh
    @Patricebrouh Před 4 měsíci +1

    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  Před 4 měsíci +1

      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 Před 4 měsíci

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

    • @attevirginie96
      @attevirginie96 Před 3 měsíci

      I am interested in this functonnality too.

  • @junaidywijaya6413
    @junaidywijaya6413 Před 4 měsíci +1

    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  Před 4 měsíci +2

      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 Před 4 měsíci

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

  • @omeryilmaz1021
    @omeryilmaz1021 Před měsícem

    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  Před měsícem

      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 Před měsícem

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

  • @aleksapetrovic7088
    @aleksapetrovic7088 Před 2 měsíci

    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  Před 2 měsíci +1

      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
    @KuroUsagi1010 Před 2 měsíci

    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  Před 2 měsíci

      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 Před 2 měsíci

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

  • @StratoCatster
    @StratoCatster Před 4 měsíci

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

    • @git-amend
      @git-amend  Před 4 měsíci

      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
    @krishx007 Před 5 měsíci

  • @JasonLovettGameDev
    @JasonLovettGameDev Před 5 měsíci

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

    • @git-amend
      @git-amend  Před 5 měsíci +2

      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 Před 5 měsíci +1

      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 Před 4 měsíci

      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 Před 4 měsíci +3

      @@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 Před 4 měsíci +1

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