How to use the Command Pattern (Skill Combos Example)

preview_player
Показать описание
Unity C# Architecture: Learn the powerful Command programming pattern by example, building a Skill Combo system for our Hero!

#unity3d #gamedev #indiedev

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬

0:00 Command
5:30 Command Manager

*Assets Shown In This Video* (Affiliate Links)

*Follow me!*
Рекомендации по теме
Комментарии
Автор

Hi everyone! I mention Animancer PRO in this video - there is also a FREE version, link in the description for you. Enjoy! 😆

git-amend
Автор

Amazing! I'm working on a little cinematic, and your video helped me tremendously. I wanted to chain some animations (skills) together, and the command pattern came in handy. Thank you, git-amend-san!

asafelbaz
Автор

Love your videos man.
Now that's what i would like to see and hopefully for other videos to come, A concert example with Design patterns on Unity even if with just cubs.

baselpro
Автор

Aha, now i realize i could have used Command Pattern for match-3 game! After matching, lots of things happening, explosions, reordering, refilling board.. they might be all planned with command pattern!

TheKrckeR
Автор

Thanks for this. I got it to work, but I had a diff implementation. I wanted it to kick out of commands not based on duration, but on an animation event. I also did not want to have entity have all the methods in it, so through a bunch of inheritance and generics I'm not even sure how I set up, I got it so that I can just call whatever method I want for a particular command directly from the character class, which all the game's characters will inherit from. So no more entity, just "character", and the commands can be custom made for each character, there's no shared method pool in IEntity.

It does require me to declare empty classes that fill in the "T" types for the generic base class though, not sure if that's great practice, but hey it works.

catpyjamas
Автор

your channels is fascinating. thank you.

kkh
Автор

Another fantastic tutorial, trying to get my head around how I'd use this in a dynamic combo system, that is you are part way through attack and if you time the next input correctly it does the next one in the combo. I probably need to build it and play with it first

Broudy
Автор

thanks a lot for all these guides for design patterns, so much has learned thanks to you!
I wonder if you don't have ideas ahead for more guides, could you make a guide example for DOTS ECS .. i've been really trying to learn it but no success and there aren't any updated guides that are easy to understand like you explain things
Waiting for more content ahead!

SirSone
Автор

Thanks a bunch for your videos. It's quite difficult to find tutorials that look at code organisation in a game (or any app), which is so useful! Even though quite a bit of it is way above my head... But wax on wax off and I'll master the crane one day. 🤣

nightonmars
Автор

Like my great-great-grandpappy used to say, a git-amend a day keeps the git-blame away...Command pattern, check!

Cloud-Yo
Автор

i could imagine this pattern in a auto battler where the player arranges the commands and than they fight each other

Hazzel
Автор

Hey, that is a great video thank you !
However, I'm quite confused about one thing : in this implementation, the view seems tightly coupled to the logic. What I mean by that is that the logic is waiting for the view to resolve. I would assume that this is the role of the command buffer, but I wonder how this would work in a turn-based game for example, or anything that relies on an MVC framework ? Thank you !

thekaribousband
Автор

so for group of characters i should do
List<Character> to have list of actually selected characters
Queue<ICommand> to queue commands for all of them or maybe i should do something like Queue<ICommand, Character>
MoveCommand that would take Vector3 to order them to move to given position
so it would work like in Baldurs Gate 3?

manofapocalypse
Автор

Going to watch this video later but just wanted to say that I always felt crazy when I complained about the limitations unity’s mecanim to others as I would feel they would gaslight me into thinking I just didn’t know how to use it ( as if there even is much to learn, literally making tons of layers, blend trees and sub machine states to organize the mess) but glad to know someone of your background thinks the same. Imo the problem with mecanim isn’t the enforcement of the visual aspect (although I am not a fan) but rather how you are forced to interact with it’s FSM from the outside rather being able to do it from the inside. The Whole point of an fsm is to make the information easy to manage and you are literally forced to use parameters exclusively via string references to access animations which leads to a lot of code bloat. Animancer is cool but having to pay to use all the features always felt crappy to me imo (no shade on the creator, it just feels as though it should be a standard unity feature.)

dudeBro
Автор

Awesome stuff! I've been leveling up so much recently from your content, thank you!

How would this system hold up if the player were to pause in the middle of a command, e.g. half way thru a spin?

BrandonHan-ll
Автор

I've heard that using Task async can cause problems in an actual built game, as opposed to coroutines. Do you know if there's any truth to that? You clearly operate at a high level and can communicate complex concepts rather eloquently, so would be useful to see you do a full video explaining the entire Task async workflow and when to use it, as well as other oft-unspoken topics like IEnumerator.

MarushiaDark
Автор

so quick question. bwtn this and the strategy pattern, is the only real difference that with command you can pass the functionality you create to other entities or really where ever you want? so strategy is used just for that single entity? (Hope this makes sense, still trying to learn all the amazing things youve put on you channel)

Sevrc
Автор

How could we improve this if the user is clicking 3 in a row, and start a skill combo? For example in Tribes of Midgard game, when we spam mouse, it will create a attack combo like right, left and front. But at some point it stops, what i mean is, If we constantly add this attack requests to command, even if the player is in 3. attack and we spammed like 15 times, they will be added and player will be attacking a lot of time when he released mouse, How do developers balance that? For example, every attack runs like 0.5 seconds, and player is spamming mouse to attack, we added we added, we added, player spammed like 10 times but we it should stop at some point, how we should decide where to stop. I hope i expressed enough about that.

TheKrckeR
Автор

Hi, I'm still very new to your content, as I only discovered you last night. Did a quick binge of all the programming patterns and I'm curious if there's any specific reason you didn't use a scriptable object for commands? Is that just because each command would only have a single instance of itself or is there some other reason?

I imagine using scriptable objects to hold the commands would make it a lot more friendly to newer developers. I'm particularly interested in using this pattern for a time management game where each work station could have it's own command. Then, each workstation command could have it's specific command implementation decided in the inspector (if using scriptable objects it's just a drag and drop, otherwise it could be a serialized enum and a switch statement to set the command).

Correct me if I'm wrong or if that isn't a great way to implement the pattern for that specific use case (or maybe there's a different pattern that would work better)? Either way, loving your content and it was an instant subscription.

Sticks_Dev
Автор

Is there a public github repo for this?

metaling
visit shbcf.ru