Game Architecture Tips - Unity

Game Architecture Tips - Unity

Dapper Dino

4 года назад

136,275 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

SMcoding
SMcoding - 05.11.2023 13:47

You get it! Im an Android Developer learning Game Development and struggling to find good videos on architecture and keeping things testable. Nice to see example on how these principles are applied in Unity development. Thanks a lot

Ответить
Roman Lemberg
Roman Lemberg - 16.10.2023 10:44

== for float realy bad idea ;)

Ответить
fokeyjo
fokeyjo - 24.07.2023 02:01

I got distracted wondering if it's more efficient if you have a lot of timers in your code that you register them with a central class that has your Timer class. If you implement it so that it's costly to add, by placing new timers into an ordered list (or part-ordered or whatever, lots of optimizations possible). Then, in the update loop, you only need to make one check for the soonest timer to fire. when it fires, you pop it off, and keep repeating the check on the new soonest for any other timers that should fire until there aren't many more that should fire.

Ответить
kawieo Mto
kawieo Mto - 07.03.2023 09:02

thanks for this awesome helpful tutorial yes we need more this kind of video... may be I am too late

Ответить
Crimson
Crimson - 27.02.2023 22:33

Is the community link down?? any updates !! would be very much intrested in joining that ..

Ответить
UnMeilleurMonde
UnMeilleurMonde - 07.10.2022 11:29

I wish there were more content like that on YT as game architecture is the stuff everyone should learn before starting developping a real game.

If you start a game without thinking about your architecture, there's a point in your progression where you will be forced to spaghetti code and your game will become more and more unmaintenable as it grows.

Found a bug ? Good luck to identify it if you didn't put any layers in your code logic.

Thanks for this video man

Ответить
Curt
Curt - 22.09.2022 03:25

Thank your video,it is really useful😊

Ответить
Drakkari
Drakkari - 16.09.2022 12:16

Two years latar and it still helps :D thank you for this tutorial!

Ответить
WS Project
WS Project - 14.09.2022 20:12

I actually dont like UnityEvents. It feels like coupling. And we can't really trace it down like in IDE. Since Unity 2021+ also has very long compile times.. It really feels better to just use Actions.. And UnityEvents are only Scene referenced. So any prefab that spawns later wont be able to subscribe to it. :(

Ответить
Unity Gamer
Unity Gamer - 09.09.2022 18:29

While watching the video I thought it was 1.5x speed lol

Ответить
Max G
Max G - 05.08.2022 17:21

I don't know much or have much exposure with unit tests, but the idea seems intriguing. The large majority of time I spend programming isn't spent on the writing of code itself, its more the debugging and playtesting of the game. I wonder how much of that time I could cut down on through unit testing?
The thing is, there seems like a lot of situations where unit tests don't really tell you a change needs to be made or an error occurred. Like with playtesting and tweaking AI behaviour, you kind a need to play the game to get a feel of how the entity is behaving to know if it needs a change or not. But maybe it could help avoid straight up error and bugs, like yesterday I spent 45 minutes trying to fix a null reference error, only to realize that it was a totally different variable that was throwing the error, and after that I fixed it in 5 seconds.

Ответить
arch entity
arch entity - 21.07.2022 21:48

That dino is indeed quite dapper...

Ответить
Miquel Torrents
Miquel Torrents - 09.07.2022 00:42

good content. you would really top it off if you stepped up your audio quality and video aesthetics

Ответить
Róbert Nagy
Róbert Nagy - 28.06.2022 16:34

I need to make the database for a unity game, and the game has a bunch of different data, attributes, etc. I want to store these as one huge string VARCHAR(300) in SQL, should I do that, or should I make like 30 different columns in the database? which one is more efficient?

Ответить
kappeli kapeli
kappeli kapeli - 15.04.2022 10:32

I didn't ubderstand any of this haha. Maybe I'll come back to this later.

Ответить
GameZoRT
GameZoRT - 04.04.2022 16:10

I’m just learning about events in unity and I’m always seeing events being subscribed and unsubscribed to. In the timer example, would you unsubscribe to the OnTimerEnd event using -= in an OnDestroy/OnDisable method? Or am I completely off base?

Ответить
Jomoko
Jomoko - 20.03.2022 07:11

Looks really useful and I may use some of these. I'm mostly a hobbyist so most of my time is used on getting things to work. It's nice to know that I can still do that part and then come back and refactor my code using this type of architecture.

Ответить
Eka
Eka - 05.02.2022 12:07

Thanks for the video. You used to have a Udemy course going Thru the Open Project 1? I saw the link on the codecks cards but I can't find it. Was removed? I would really like a tutorial/course that goes thru the design of that project, looks really well made.

Ответить
Satium Mithril
Satium Mithril - 30.01.2022 16:39

why not using fixed update? then he would not calculate like 60 times per second but in the physic step. ergo more performance? because you use deltatime anyway

Ответить
little face
little face - 28.01.2022 20:14

Dipper Dino

Ответить
atila correia
atila correia - 28.01.2022 19:30

Your parameter "duration" for the timer class should be "durationInSeconds".
It's also a good practice to use OnDestroy and remove the delegates you assigned and nullify some instances you created and no longer need it.
Would be interesting to see a situation where 1 Monobehavior ticks many different objects, since it's a common performance situation with Unity where you avoid many objects updating individually (to avoid reflection call of Update).

Ответить
The1Taboo
The1Taboo - 24.11.2021 14:45

I need to learn about events and function invoking and getters and setters,

Wish I had like a roadmap to progressively acquire the right programming tools

Ответить
doge9
doge9 - 16.11.2021 10:31

makes perfect sense!

Ответить
Subrata Roy
Subrata Roy - 31.10.2021 10:30

Make tps multiplayer mobile game plz

Ответить
RespriteApp
RespriteApp - 28.10.2021 04:14

make simple complex

Ответить
Thomas B. Charlie
Thomas B. Charlie - 03.10.2021 15:37

Wouldn't a timer be best used with a coroutine? Ticking a bunch of timers every Update feels excessive

Ответить
Joseph P
Joseph P - 24.09.2021 19:49

I highly recommend playmaker...

Ответить
seithim
seithim - 20.08.2021 14:29

I recommend people read The Pragmatic Programmer. You will thank me.

Ответить
seithim
seithim - 20.08.2021 14:25

Is there a reason you initialize the UnityEvent to null?

Ответить
Seldin Gardane
Seldin Gardane - 06.08.2021 16:50

Why do two separate checks for whether the timer is 0? You check once for if the time is 0 and then later you check if it's greater than 0 with the else setting it to 0 if it runs lower. But you don't really even need the first check. The second check handles both conditions. The same is true if you checked less than or equal to 0. In that case you would set the timer to 0 and then return.

Ответить
Aaron Carter
Aaron Carter - 31.07.2021 22:55

A lot of people who make tutorials don't really know C# and have no other experience with it apart from simple Unity scripting. So they really don't know anything about OOP and design, just attaching MonoBehaviour scripts to GameObject. Kind of bugs me when I'm watching tutorial videos to learn the Unity API and no one seems to know basic C# concepts lol. But this video was refreshing. I try not to use many MonoBehaviour objects unless they actually need to hook into Unity directly. I've been thinking about creating my own sub-engine to connect to Unity and manage some extra things and deal with syncing multiple threads.

Ответить
Allan MacDonald
Allan MacDonald - 29.07.2021 18:52

This was great. Having the example at the real world use case and benefits was nice. I wonder if leading with a few of those before getting into the how-to of it would be better format, set that hook kinda deal. Thanks.

Ответить
Gregory Tippett
Gregory Tippett - 26.07.2021 03:49

Where are your SOLID videos? Looked through your channel but not finding them.

Ответить
Divain'sYoutube
Divain'sYoutube - 25.06.2021 19:53

First of all, thanks for all your tutorials and hard work! Much appriciated!
I have a question to ask.
In your "Timer" class, you're passing Time.deltaTime as an argument so you won't have to use the "UnityEngine" namespace, but in your "Movement" class you're clearly using it, what's the different? Why using the namespace in one and not the other?

Ответить
Kleyder Mendoza
Kleyder Mendoza - 24.06.2021 06:21

Thank you, i was needing a video about software architecture in video games, so THANK YOU :D

Ответить
Dick Spargel
Dick Spargel - 21.06.2021 19:18

I'd like to see this same thing, but also some stuff about dlls

Ответить
Kik Profik
Kik Profik - 17.05.2021 03:39

Great video, easy to understand and follow. Explanation is simple and to the point. Deserves a sub 👍

Ответить
H Miri
H Miri - 12.05.2021 16:36

Quite an informative video, as well as enjoyable. Thank you!

Ответить
Alexander Huliakov
Alexander Huliakov - 12.05.2021 08:59

Sorry, the video is good and all, but the title is misleading.

Ответить
Nikunj Kareliya
Nikunj Kareliya - 05.05.2021 16:08

Great example of using design pattern! Keep it up

Ответить
BarnesN Plebian
BarnesN Plebian - 04.05.2021 17:55

This is a pretty cool way of setting up things

Ответить
EasyCode [Unity3d]
EasyCode [Unity3d] - 19.04.2021 15:25

Wow, timer, nice.
But what would you do if this timer is a part of mobile game where users each time fold the game window once they got a new message in some kind of messanger?
Timer will be paused as well as game itself.
How to handle this by the proper way?

Ответить
Jon
Jon - 18.04.2021 14:46

As a professional c# developer looking to learn unity, it's infuriating watching all of these tutorials making poor architectural and design choices and never mentioning anything about how this might look in a production system (or doing it so quickly that it isn't helpful). Thank you for this!

Ответить
Sergio Rello
Sergio Rello - 29.03.2021 09:20

I would pay for a full course on this topic

Ответить
HAWXLEADER
HAWXLEADER - 21.02.2021 23:38

But all this boilerplate code makes it really hard to understand what stuff does.

Ответить
n2ks co
n2ks co - 12.02.2021 15:19

More videos like this please!!!

Ответить
clamum
clamum - 02.02.2021 08:31

I get this error in Visual Studio on the line for "timer.OnTimerEnd += HandleTimerEnd();" : Cannot implicitly convert type 'void' to 'System.Action'. If I make the method in the Unity class the following: "private Action HandleTimerEnd() { onTimerEnd.Invoke(); }" that works, but I still get an error on that method saying "not all code paths return a value" since it needs to return an Action (I have no idea what that is).

I'm also getting an error on the following line: "onTimerEnd.Invoke();" in the HandleTimerEnd() method in the Unity class (TimerBehavior in your code; I just put this code in my Unity MonoBehavior class, without the wrapper). The error is that "onTimerEnd" is null because it's never instantiated in the Unity code (or wrapper in your code), it's just defined as "private UnityEvent onTimerEnd = null;"

My code is the same as yours, I looked at your code on GitHub. I just put the code you have in your TImerBehavior class right into my Unity MonoBehavior class.

Ответить
Apache Gaming
Apache Gaming - 01.02.2021 16:38

Could you give an overview of how to set up for TDD and Clean Architecture within Unity?

I'm coming into Unity Games Development as a highly experienced C# developer for Web and Desktop Applications. I've been highly concerned that Unity seems to break C# Coding Standards with regards to naming conventions; intellisense looks horrible, and there's no XMLDocs. Also, the accepted use of public fields is highly concerning, as it breaks encapsulation.

So far as I can see, this would be your structure:

Domain: POCO classes, base abstraction layers.
Application: Business Logic for specific projects.
Infrastructure: Unit Tests, Integration Tests, Assembly-CSharp (Unity UI Adaptor).

You should be able to swap out your Assembly-CSharp front end, for your Unit Test Suite, and be able to test all the business logic; none of which depends on Unity. Then integration tests give coverage for your implementation of all the Unity code-behind.

But, where would you write your first uncompilable tests? I prefer Plan-Do-Study-Act to Red-Green-Refactor, it's easier to understand and explain. But, what's the best way to implement that PDSA pattern within Unity? Is it better to start with a failing integration test, and fall down through the layers?

Ответить