Game Architecture Tips - State Machines - Unity

  Рет қаралды 16,726

Dapper Dino

Dapper Dino

Күн бұрын

Package: github.com/Dap...
Join Our Community: student.dapper...
-----------------------------------------------------------------------------------------------------------
Just Here To Plug My Social Media Stuff:
/ dapperdino
/ dapper_dino
/ dapperdino4
/ dapper-codin. .
github.com/Dap...
/ discord
-----------------------------------------------------------------------------------------------------------
If you liked the video then please respond with a like and a subscribe to show your support for the channel and I'll repay you by creating more tutorials for you to enjoy :D

Пікірлер: 24
@danieldoyle-ahern3468
@danieldoyle-ahern3468 5 жыл бұрын
Thanks Dino - I'm working on a project right now that this would actually be really useful for!
@beardordie5308
@beardordie5308 5 жыл бұрын
Yes, your state machine system is superior than the one I'm using that comes with "Surge". Great job. I'm using Odin also.
@Octamed
@Octamed 4 жыл бұрын
Rider now shows usages of UnityEvents in editor. It's SO HANDY for setups that use a lot of inspector assignments like your SM.
@koremeltdown7258
@koremeltdown7258 3 жыл бұрын
Dude, this is awesome.
@fahimfaysal1753
@fahimfaysal1753 5 жыл бұрын
I was actually making a FSM like this using the new serialisation support since I don't have Odin. The serialisation itself worked but I needed to make editor code to for assigning stuff and that was a huge pain to be worth it. As you said, I had to give up and use monobehaviors for polymorphism. Elaborated example: I have a list. I want to add conditions in the editor. I have a custom serialised class that implements the condition interface. With a bit of custom editor scripting I could fetch all types that implemented the interface in a drop-down menu and add it to the list. But I couldn't make it work with the undo system and gave up lol. If you end up implementing the whole thing with [serialised ref] system without editor code, I'd like to see it.
@badublackwater6556
@badublackwater6556 4 жыл бұрын
Same here. Can't get my head around this Editor Scripting stuff :(
@Change-jy1rl
@Change-jy1rl 5 жыл бұрын
hi a question i want to make a advanced, state machine for a player something like that : move, auto move, jump, fall, stunned , root, fall, die, fear but transitions become very hard to control and gives a cases when you cant die if you'r stunned or when you revive, you go to stunned because before you die you were stunned that's easy to fix but gives room for a many bugs that's not yet discovered i'd like a more efficient way or a technique that make it easier i'm new to unity and i don't have a lot of experience what can you advise me to do thank you
@nerdydrow
@nerdydrow 5 жыл бұрын
you should read this book gameprogrammingpatterns.com/ the section on States should help
@jerryhu9733
@jerryhu9733 4 жыл бұрын
I'm a bit confused. So how would we go on to make specific logic for states without creating a concrete State class? Should we put everything in Behaviour scripts, which are then put on the main object? Then, we would still have to create a large switch statement that checks in which state it is to choose the correct logic for the state?
@oatcube3961
@oatcube3961 4 жыл бұрын
A question: It seems that state machines are a good way to create logic for objects that states change fast, for example AI. In my game I have a space ship with a asteroid scoop that idles until it sees a catchable asteroid. At that moment it reaches out and catches the asteroid when the asteroid collides with the handle. Next it pulls it in and once it's in the ship the asteroid can be mined by workers. Should this be done with state machine? At the moment it's basically a chain of methods that activate through the collider. Since the state transitions are always linear( spawn, if collides: play catch animation + reel in. When it's reeled in miningPossible is true, once materialCount reaches 0 the scoop reaches out again). I'm trying to wrap my head around on what is the best method on creating "loops" like that. State Machine sounds great but it's not the way I should be doing this system?
@DanieleScali
@DanieleScali 5 жыл бұрын
Well done!
@indraayy849
@indraayy849 5 жыл бұрын
Great video! How do u made value comparison dropdown in VelocityCondition? P.s I have odin inspector too
@zapposh
@zapposh 5 жыл бұрын
Has the package been removed? The link seems to be broken, thanks.
@DapperDinoCodingTutorials
@DapperDinoCodingTutorials 5 жыл бұрын
I fixed the link, sorry about that :D
@zapposh
@zapposh 5 жыл бұрын
@@DapperDinoCodingTutorials Fantastic, thanks. Just amazed that 1300 viewers watch the video without noticing. :-)
@dogfaceboye2906
@dogfaceboye2906 4 жыл бұрын
AMAZINGGGG share!!!!
@DxBALLxD
@DxBALLxD 4 жыл бұрын
Demons and orcs. Dorks.
@TripleZmediA
@TripleZmediA 5 жыл бұрын
i think the intro is for another video 😂
@DapperDinoCodingTutorials
@DapperDinoCodingTutorials 5 жыл бұрын
Thanks for pointing that out haha. I've removed the start of the video now so it just goes straight into it :D
@TripleZmediA
@TripleZmediA 5 жыл бұрын
@@DapperDinoCodingTutorials cool no problem, very helpful video thank you :)
@alexkhazov7264
@alexkhazov7264 5 жыл бұрын
You mentioned the Unity animator, and the cool thing about it is that it already comes with a StateMachineBehaviour base class built right into Unity that you can extend and add to different states in the animator. You can then visually create the conditions between the different states, and don't need to go through all the hassle of managing all the states on your own :) docs.unity3d.com/ScriptReference/StateMachineBehaviour.html
@DapperDinoCodingTutorials
@DapperDinoCodingTutorials 5 жыл бұрын
I'm well aware of statemachinebehaviour and I purposely don't use it. It's a lot more hassle to do it that way because you have to inherit from that particular class meaning that you will have duplicate code if you want to have similar logic in your states and elsewhere. It also means that you have to hard-code your state logic rather than plugging together whatever you want. With the way I showed you have much more freedom. Also, there are limited condition types with the Animator state machine whereas with this you can make any state you want.
@alexkhazov7264
@alexkhazov7264 5 жыл бұрын
@@DapperDinoCodingTutorials I see. I think that Unity's SMB would be nice for a simple example, but I agree with you that your method is much better for a more complicated and extendable use-case. Also, you can hook it up to scene objects directly through UnityEvents.
@magnusm4
@magnusm4 4 жыл бұрын
I've always thought of fixing up and releasing my code for free from my future games. I'm just afraid of people using it to make really bad games and then release them in masses like they're doing with unity assets or worse, sell assets with my code
How to Program in Unity: State Machines Explained
18:56
iHeartGameDev
Рет қаралды 239 М.
The 6 Design Patterns game devs need?
24:20
Jason Weimann (GameDev)
Рет қаралды 377 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
What's New In Fusion for January 2025 | AI Fastener Detection for Drawings
7:16
Learn Everything About Design
Рет қаралды 858
The 8 Game Code & Architecture Mistakes We ALL Make - Unity3D
25:45
Jason Weimann (GameDev)
Рет қаралды 123 М.
Events & Delegates in Unity
13:20
Game Dev Beginner
Рет қаралды 68 М.
Improve Your Unity Code with MVC/MVP Architectural Patterns
15:32
Code Class - Build your own State Machines!
36:42
AdamCYounis
Рет қаралды 63 М.
The State Pattern (C# and Unity) - Finite State Machine
10:04
One Wheel Studio
Рет қаралды 70 М.
Build AI Behaviour Trees FAST in Unity with C#
23:12
Mina Pêcheux
Рет қаралды 86 М.
Build a Better Finite State Machine in Unity
20:58
git-amend
Рет қаралды 32 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН