Turn-Based Combat in Unity

  Рет қаралды 576,653

Brackeys

Brackeys

Күн бұрын

Пікірлер: 701
@kunz4164
@kunz4164 4 жыл бұрын
Just an extra tip and heads up for the fellow learners: You can still attack during enemy's turn because your Attack & heal buttons still show up and is enabled during enemy's turn so make sure you add an extra method that either disables or hides the button when its the enemy's turn and then ReEnables/Unhide the button when its your turn. Should be really easy to implement, just look up the tuts, they are easy to find.
@epion660
@epion660 4 жыл бұрын
*enemy begins attack* *_player violently slaps them again_*
@vickrpg
@vickrpg 4 жыл бұрын
Actually you cannot because of the state machine. The buttons are still there, but they do nothing during gamestate.enemy turn. still a good UI tip though
@bienvenualexis4564
@bienvenualexis4564 4 жыл бұрын
If you spam the attack button during your turn, it will start the coroutine several times until the first one to change the state. This will still perform several attacks in one turn.
@caidenbond1988
@caidenbond1988 4 жыл бұрын
IF statements work for this, correct? Like if it's the enemy's turn, disable attack or something?
@kunz4164
@kunz4164 4 жыл бұрын
@@caidenbond1988 yeah it will
@cam4722
@cam4722 4 жыл бұрын
This tutorial rocks. Thanks, man.
@marvpeelow3137
@marvpeelow3137 4 жыл бұрын
ba tum tsss... I see what you did there buddy
@mreverything7056
@mreverything7056 4 жыл бұрын
What are you playing? Yotsuyu Yagiyama stand ...What?
@lslightningstrike284
@lslightningstrike284 4 жыл бұрын
Mr Everything 70 what
@itsrachnime
@itsrachnime 3 жыл бұрын
Noice joke my dude
@BroomieHERE
@BroomieHERE 2 жыл бұрын
Ice-y what you did there pal
@NagyerdeiKorisok
@NagyerdeiKorisok 4 жыл бұрын
There is a mistake in the logic that handles Player's turn and Enemy's turn. 20:35 You need to set the ENEMYTURN flag immediately after the player has chosen an action. Right now as you can see it waits for 2 seconds, in that timeframe we still have our PLAYERTURN, meaning we can spam the attack button and start as many attack coroutines as we can. By changing to ENEMYTURN immediately, we block the attack button's function as it is only available in the player's turn.
@hotlinefrenzy
@hotlinefrenzy 2 жыл бұрын
My man you got it
@AuraBreaker
@AuraBreaker 2 жыл бұрын
Thanks for pointing that out wow
@Bolku94
@Bolku94 2 жыл бұрын
I did it like this: IEnumerator PlayerAttack() { bool isDead = enemyUnit.TakeDamage(playerUnit.damage); if (isDead) { state = BattleState.WON; enemyHUD.SetHP(enemyUnit.currentHP = 0); EndBattle(); } else { state = BattleState.ENEMYTURN; enemyHUD.SetHP(enemyUnit.currentHP,); dialogueText.text = "You deal " + playerUnit.damage + " damage..."; yield return new WaitForSeconds(2f); StartCoroutine(EnemyTurn()); } } AND: IEnumerator PlayerHeal() { playerUnit.Heal(5); state = BattleState.ENEMYTURN; playerHUD.SetHP(playerUnit.currentHP); dialogueText.text = "You healed for 5."; yield return new WaitForSeconds(2f); StartCoroutine(EnemyTurn()); }
@cosmicrenegade
@cosmicrenegade Жыл бұрын
I handled this by having an intermediate state called WAITING. This is a "blank" state that prevents the button spam, keeps me conscious about state switching as I'm programming, and also a state I can use later to let animations play out.
@Danidev
@Danidev 4 жыл бұрын
mmmmm yes
@nezbitnezbit5397
@nezbitnezbit5397 4 жыл бұрын
Lots of yes
@fridgejuice
@fridgejuice 4 жыл бұрын
Mmmmmm mmmmilk
@emeraldmation7019
@emeraldmation7019 4 жыл бұрын
Milk
@vathsalas4886
@vathsalas4886 4 жыл бұрын
It is real
@kooperninja5459
@kooperninja5459 4 жыл бұрын
Ahhhh yeeeeeeeeeees
@warlockconnor5861
@warlockconnor5861 4 жыл бұрын
I literally spent a week building a turn based combat system then this comes out
@lethn2929
@lethn2929 4 жыл бұрын
He's a bastard for that isn't he?
@Axodus
@Axodus 4 жыл бұрын
@Lethn Why are you being so rude.
@lethn2929
@lethn2929 4 жыл бұрын
@@Axodus Why are you being so dumb?
@waelalr9203
@waelalr9203 4 жыл бұрын
@@Axodus r/woosh you soo hard
@Axodus
@Axodus 4 жыл бұрын
@Lethn [Sees you're getting super defensive over a single comment] I think this proves I'm right, why would you get defensive otherwise unless you realized you _were_ being rude. Me: [Presses F to Doubt I'm the dumb one in this scenario]
@andreferreira2456
@andreferreira2456 4 жыл бұрын
I can't believe that after years online I actually saw an Ad that is actually useful! Milanote sounds like what I've been looking for years!
@zahhym
@zahhym 4 жыл бұрын
you can just use trello, much easier
@se9979
@se9979 4 жыл бұрын
Probably bot
@Brahvim
@Brahvim 4 жыл бұрын
Evernote?
@alexsouthworth4978
@alexsouthworth4978 4 жыл бұрын
@@se9979 No, milanote actually seems really good from what little I've done with it. Perhaps there's some paywall that i haven't come across yet, but it does actually seem really helpful for planning stuff. I definitely sound like a bot. I recommend you give it a go though.
@purple_fox_arts
@purple_fox_arts 3 жыл бұрын
Milanote is great 👌
@SamFoit0
@SamFoit0 4 жыл бұрын
When you're just starting to create an RPG game and this pops into your recommended...
@se9979
@se9979 4 жыл бұрын
I need help: do you know some way to make random encounters or some video that talks about it?
@redgeoblaze3752
@redgeoblaze3752 3 жыл бұрын
@@se9979 If you're thinking about a random encounter system like Pokemon, Add a property to tiles for if they are dangerous or not. Have a list of encounters your player can encounter in that general area, and perhaps set the ID for these encounters in individual tiles if you want to get more specific. Perform a random roll when the player steps or turns within one of these dangerous tiles, (Pokemon also makes the chance at an encounter more likely if the player is running.) Then store relevant level data before transitioning to the battle scene, and when it's over, load your player back where they were. (I'm still really new at game design, but I think this is how it's done from a logistics standpoint.)
@KaosWater
@KaosWater 3 жыл бұрын
@@redgeoblaze3752 That sounds right.
@chillmadude
@chillmadude 2 жыл бұрын
a role playing game game?
@agitated_cat
@agitated_cat 3 жыл бұрын
most repeated words of 2019: "so let's go ahead and get rid of our start and update functions"
@irishbruse
@irishbruse 4 жыл бұрын
How to create pokemon the copyright free version
@Catervus
@Catervus 4 жыл бұрын
Ayy it's you! :D you helped me with code earlier today!
@forget6917
@forget6917 4 жыл бұрын
Or just ROM hack (since then you have all the Pokémon data)
@OCPyrit
@OCPyrit 4 жыл бұрын
I spend a week setting up the canvas before doing anything.
@MorRochben
@MorRochben 4 жыл бұрын
pocket rocks!
@Zihan118
@Zihan118 4 жыл бұрын
@@user-zl5cv6vw2m come on help the poor guy, yeah that videos quality is a bit low but come on! I shared all what is important aye?
@Hyde233
@Hyde233 4 жыл бұрын
After I followed this tutorial, I found Infallible Code's video "How to Code a Simple State Machine (Unity Tutorial)." It shows how to create a state machine and the tutorial is based somewhat off of the battle system shown in this video. I recommend that you guys check it out; it'll help you organize the code for each individual action (attacking and healing) better.
@sheenufilms
@sheenufilms 4 жыл бұрын
This was an awesome tutorial. You are one of the best Unity tutorial channels I've ever run into! However, I found a HUGE problem in the way this battle system works. There is now way to check if the player is spamming the Attack or Heal button, so when the button is spam clicked, you can attack or heal multiple times. I fixed it by creating new BattleStates called "PLAYERATTACKED" and "PLAYERHEALED" and immediately switching to that state when the PlayerAttack() or PlayerHeal() is called.
@NorthGMD
@NorthGMD 4 жыл бұрын
Thank you so much!
@DakarrtheTerminator
@DakarrtheTerminator 3 жыл бұрын
when adapting the contents of this tutorial I decided to change one key aspect. I find it a little silly to adapt a creature's stats to a prefab, create objects from prefabs every single encounter and every time you catch something etc. So instead, I just load the specific sprite that matches the fighter's name from Resources and keep all the fighter-specific data in its own instance of class Creature. That way it persists across all systems of the game.
@DanCreaMundos
@DanCreaMundos 4 жыл бұрын
I love your videos, and specially more nowadays. You've improved so much. I was watching for example one of your old videos a out parallax effect in 2d games and I have to say it, oh God it was so hard to watch. In those days you explained everything while you were writing the code like in live video, it was so slow and painful compared to your new videos lol still very useful all of them, but maybe you should remake a few of the more dense and long ones to this new format.
@danielwitt7645
@danielwitt7645 4 жыл бұрын
Perhaps the changes in Unity 2020 will be reason enough to update old video tutorials in the new style
@sharif47
@sharif47 4 жыл бұрын
Blender Guru did something similar when Blender 2.8 came out. So, why not the same for Brackeys?
@KaosWater
@KaosWater 3 жыл бұрын
I learned a lot from this. I am currently trying to make a rpg with 6 party members and each taking a turn. Now to sit at the code screen and stare till things come to me.
@DoorsExciteMe
@DoorsExciteMe 4 жыл бұрын
The sheer quality of this tutorial is amazing
@TheDuccyGaming
@TheDuccyGaming Жыл бұрын
for people who are about to watch this video, 100% WORTH IT!! Follow along the whole 30 mins. completely customizable and very user friendly!
@Athinis_Crettos
@Athinis_Crettos 3 ай бұрын
I know you recently came back from the gates of death *spooky* and started to make new videos!! I loved the content, thank you for that, I'm not a programmer but I could finished the turned base combat you purposed and the most great party of it is that I was able by myself to clear all the bug I had and made it work!! I feel really happy for achieving that!! Thank you, Brackeys!! Your contents are awesome!! We're glad you are back =]
@chaosmastermind
@chaosmastermind 3 жыл бұрын
"A wild The Rock approaches..." I love that you kept it like that. LOL
@Neox999
@Neox999 4 жыл бұрын
There is a small problem in this project. You can spam the Attack and Heal buttons for 2 seconds because the battle state doesn't get changed immediately. I would suggest to add a new battle state like "PLAYERACTION" and change the state to that on line 62 at 20:12 before you call the Coroutine (or inside the Corioutine but before the 2 seconds wait).
@JR-ky5sm
@JR-ky5sm 2 жыл бұрын
what would that look like?
@abigorm.9056
@abigorm.9056 4 жыл бұрын
4 Minutes in and its pass 3 PM ... Great guide ! having fun modifying with free art and thinking what changes could be made to the UI Would love to see more guides for rpg , Especially how to trigger the turn base combat from another menu. Thanks for the video !
@LeAlexo
@LeAlexo 4 жыл бұрын
I think it’s the first time ever that a sponsor convinces me to try the product that it sells!
@inodedentry8887
@inodedentry8887 4 жыл бұрын
tbf the advertisement was also really clever, with him using the product being advertised throughout the whole video to show it off at the same time as teaching you gamedev skills. i'd say it was Brackeys that convinced you more so than the sponsor did :)
@worldismyne
@worldismyne 4 жыл бұрын
THANK YOU SO MUCH FOR MAKING THIS!!!!! Seriously I can't express how difficult it has been to find a comprehensive tutorial on this subject (paid for or for free). You have saved my game man. I'm seriously so grateful. OTL
@Chevifier
@Chevifier 4 жыл бұрын
Wow I didnt know we could call "yield return WaiforSeconds" multiple times in one IEnumerator!! So much cool ideas just popped up in my head XD
@patrickmorter9097
@patrickmorter9097 3 жыл бұрын
Hey Asbjørn, so much to say. Firstly a massive thank you for helping me get into game dev. Less than two years ago I knew nothing of this world, but since watching your videos and using them almost exclusively as a learning resource, I've gone from zero to...competent coder (bet you thought I was going to say hero). I was saddened to hear your announcement on ending your Brackey's videos, but as the old saying goes, don't be sad that it's over, smile because it happened and thanks to the medium, your youtube videos remain and are still a vital resource that I plunge into on a regular basis. Your professional approach to making clear and informative tutorials were (and still are) an absolute God send. I have you personally to thank for this new skillset and wish you the best of luck for the future. EndlessGratitude(); Patmaaan return;
@user-fj1kq9kj2i
@user-fj1kq9kj2i 4 жыл бұрын
Thank you for great videos every week!! This's I've been waiting for. By the way, I found a bug in the code. If I click the attack button or heal button again and again in my turn (before WaitForSeconds() ends), I can attack or heal many times in 1 turn. After my turn ends, I get attacked many times in 1 turn. A solution for this is add new BattleState named "PLAYER_CHOOSED_ACTION". When the attack button or heal button was pressed in player's turn, change the state PLAYER_TURN to PLAYER_CHOOSED_ACTION and fix the if statement such like "if (state != BattleState.PLAYER_TURN && state == BattleState.PLAYER_ACTION_CHOOSED) return;". Of course to fix this, we can change the UI as soon as the attack button or heal button was pressed. Thanks for reading and happy coding!
@MaxParasite
@MaxParasite 4 жыл бұрын
I had the same issue and solved it similarly: public enum ButtonState { ACTIVE, INACTIVE } Initiate it to ACTIVE in the Start function and set it to INACTIVE in the Button Functions before PlayerAttack or PlayerHeal are called. Reset it to ACTIVE when the Enemy Turn ends.
@rigradgaming253
@rigradgaming253 3 жыл бұрын
@@MaxParasite Alright, I'm confused. Where exactly am i putting the inactive and active and how do i make them affect the buttons i want?
@ugurcankarakas6554
@ugurcankarakas6554 4 жыл бұрын
Dude you're a life saver. This is a great place if you're new to unity and learn. Thanks for everything.
@Halfscreen
@Halfscreen 4 жыл бұрын
The best youtube channel if you want to learn unity3D! Thanks!
@rpgtogether7022
@rpgtogether7022 4 жыл бұрын
I made different attacks possible by making a scriptable object to store attack data and a ratio probability system for enemies
@rosh6369
@rosh6369 4 жыл бұрын
Good tip!!
@Handidev
@Handidev 4 жыл бұрын
That's cool ! "The Rock vs An actual Rock" 🤣
@GameDevExperiments
@GameDevExperiments 4 жыл бұрын
This tutorial gave me nostalgia and inspired me to create a small pokemon game clone. I've also created a pokemon game tutorial series in unity to help anyone who wants to create something similar.
@Maxb0tbeep
@Maxb0tbeep 4 жыл бұрын
Thank you! This is just what I needed at like the (strangely) perfect time!
@micaiahstevens8840
@micaiahstevens8840 4 жыл бұрын
Gotta say that was the BEST AD EVER! It was nicely integrated, teaches people how to use a cool tool and IS part of the larger Game Development tutorials that MOST don't seem to show. YAY I did all this, with a TON of work but its like 10 mins of video. I mean great job, I think Milinote is great, I like its drag and drag. I know a Dark Theme would help, from my browser, but those sites REALLY are missing that, not sure if it has it.
@micaiahstevens8840
@micaiahstevens8840 4 жыл бұрын
Just signed up, COOL you can increase the font, and SO far does work NICELY with the Dark Theme browser extension I use. MY GAWD Why is Unity not charging me $1000 for my use of Dark THEME! - ITS free Unity IMAGINE that!
@nezbro2011
@nezbro2011 4 жыл бұрын
Seems like something you should continue haha.
@Warpgatez
@Warpgatez 4 жыл бұрын
I was literally looking for milanote after I saw a indie dev using it but I didn't know what it's name was. I thought it was notion but couldn't find the templates that matched this look so ruled it out. Thanks brackets! Not only for the great tutorial but also finishing my quest to find it!
@JoshyMRaj
@JoshyMRaj 4 жыл бұрын
Hi Asbjorn, we missed you in Unite India. But happy to see you in FaceTime. Met Andreas and I conveyed my hearful thanks to Brackeys team. Wish you all the happiness in life. Thanks Guru.
@MatrixRex05
@MatrixRex05 4 жыл бұрын
"dwayne" johnson the "rock"....... Thanks for the tutorial. You are awesome.
@Soundy777
@Soundy777 4 жыл бұрын
Good intro to the topic, wouldn't mind a whole series on fleshing this kind of system to show off better coding techniques & some juicy fx! \o/
@borisandunity7912
@borisandunity7912 4 жыл бұрын
Great video! As usual, useful content right when needed.
@danh9676
@danh9676 4 жыл бұрын
I like this system. I also added my own implementation of the ATB meter from the final fantasy series.
@youtubewatcher6124
@youtubewatcher6124 4 жыл бұрын
How
@YulRun
@YulRun 4 жыл бұрын
Been wanting a basics turn based combat system forever, thanks!
@WagnerGFX
@WagnerGFX 4 жыл бұрын
Awesome video and awesome AD, perfectly integrated in the content and actually showing how it can be useful for development.
@raviolipopcorn668
@raviolipopcorn668 4 жыл бұрын
As always brackeys, you have an answer for every problem I encounter. Thanks man!
@marosmierka1904
@marosmierka1904 4 ай бұрын
about 2:00 - potential error (i had trouble here later when stuff spawned) its better to create emptz objects and insert picture underneath it why- if you need to scale the picture, it would scale the object that spawns on it as well, with empty object it does not have to scale yet you get scalable picture
@TheKrou
@TheKrou 2 жыл бұрын
How would you change the BattleSystem code to have multiple enemies or multiple player-controlled characters, like in Final Fantasy?
@michalstary9920
@michalstary9920 3 жыл бұрын
All my questions answered in one video. Thanks! I have no idea how he manages to speak and type this fast at the same time though...
@connorschultz380
@connorschultz380 Жыл бұрын
I am personally attmepting to recreate a childhood flash game in unity, it had a turn based combat system and a lot of mechanics! So thank you!
@AlexanderFrischbutter
@AlexanderFrischbutter 4 жыл бұрын
Please make a video about camera and scaling the ui, it is so hard for me to get this right :) btw, love your content!!!
@antominom8175
@antominom8175 4 жыл бұрын
I recommend changing the UI scale mode on the canvas to: scale with screen. It’s a lot easier to work with trust me.
@iminyourwallsthereisnoescape
@iminyourwallsthereisnoescape 4 ай бұрын
HES BACK
@danielsaix2160
@danielsaix2160 4 жыл бұрын
Just worked this out, works great! Only difficulty I have is that whenever the enemy attacks, all it says is "enemy (clone)" rather than the name I assigned it. Aside from that tiny issue, everything works great!
@RagoxHatena
@RagoxHatena 4 жыл бұрын
That is because you are likely referencing the name of the object "enemy(clone)" instead of their assigned name. Perhaps you could make their name a bit more clear, that way you can make a clear reference to the unit?
@danielsaix2160
@danielsaix2160 4 жыл бұрын
@@RagoxHatena I just figured it out last night, but thank you for the reply!
@PatrickAngel525
@PatrickAngel525 4 жыл бұрын
Here is a quick breakdown of what would be really nice for milanote to be able to * Create references to other boards anywhere (like a hyperlink) * Create a KanBan board that can connect to all todo lists (KanBan boards are used by a lot of professionals for organizing which todo tasks are more important to least important and include a backlog) * Better tutorial and/or documentation if not already available on how to use milanote, if available make it easier to access I'll add onto this if/when I come up with better and/or more ideas. This is just my first impressions messing around with Milanote for an hour. Let me know what you think :) Otherwise this is a really good tool for organization!!!!
@xyhc-cnc
@xyhc-cnc 4 жыл бұрын
Oh shoot, I was just gonna have to research about programming turn-based combat and the report is due tomorrow then I saw this in my subscription feeds! Thank you!!!
@orange1304
@orange1304 4 жыл бұрын
That's funny. Just today I've been wondering how to implement something similar. Great!
@birgerevan
@birgerevan 4 жыл бұрын
Are you going to make tutorials for Unity ECS once Entities 1.0 is released?
@MegaGameCore
@MegaGameCore 4 жыл бұрын
Honestly, i doubt that he understands ECS. I also doubt that ECS is something that will be well recieved by the larger part of the community.
@lucianomcardoso
@lucianomcardoso 4 жыл бұрын
kzbin.info/www/bejne/f33Jhqh4gcutfas
@nandorbacso4625
@nandorbacso4625 4 жыл бұрын
It's amazing how you help people to grow in game development. I love your channel :D
@Sketchy144
@Sketchy144 3 жыл бұрын
*palm in face* i wish he would have done a tutorial for this tutorial where he explained how to get his scene set up.
@Gers217
@Gers217 4 жыл бұрын
A video about SOLID principles in Unity would be pretty nice
@raffe7889
@raffe7889 4 жыл бұрын
yayy it's apparently Sunday again! good to see you post :)
@itsmeolee6710
@itsmeolee6710 4 жыл бұрын
As a solo developer, I tried Milanote and found it to be a much better, tailored experience than something of the likes of Trello. I had been using Trello up until now, and while it serves its purpose well, I will be using Milanote from now on. Thanks @Brackeys :D That awfully sounded like a paid comment, yikes lol
@In-N-Out333
@In-N-Out333 4 жыл бұрын
You can simplify GameObject playerGO = Instantiate(playerPrefab, playerBattleStation); playerUnit = playerGO.GetComponent(); to just playerUnit = Instantiate(playerPrefab, playerBattleStation).GetComponent(); That way you can instantiate the object while also setting a variable to one of its components. You also don't need the 'playerGO' variable.
@oisinmcl
@oisinmcl 4 жыл бұрын
What if you need another component? Your version is less flexible and maintainable. Shorting code to one liners is rarely better if at all.
@StefanLopuszanski
@StefanLopuszanski 4 жыл бұрын
Nice. I'm sure a lot of students I know would love to see this stuff. Great first step.
@UzanLatif
@UzanLatif 3 жыл бұрын
That script was very structured love it
@lukek.5773
@lukek.5773 4 жыл бұрын
HOLY FUCK, this couldn't have come at a more perfect time, I have a tactics move system that's broken and this may help me buff up the turn based manager
@frozenhat420
@frozenhat420 3 жыл бұрын
That Battle shown in the checklist is the battle from pokemon ruby and sapphire where you choose your starter to save Professor Birch from the poochyena
@eduardodominguesfenner6277
@eduardodominguesfenner6277 2 жыл бұрын
For some reason, the unity doesn't recognise the Unit. It says "The type or namespace 'Unit' could not be found" Edit: found the answer. Unit is not a "variable". Is the name of the script you use in the player and enemy
@Melvin88ify
@Melvin88ify 4 жыл бұрын
Thanks for sharing the IEnumerators, they should be heard!. I discovered them very late and no one really talks that much about their full potential. Now almost nothing runs in the updates function and i also cut down on using the animator because of the IEnumerators. Very powerfull and fairly cheap
@rosh6369
@rosh6369 4 жыл бұрын
do you have some videos/documentation where I could learn more about IEnumerators? I've been seeing them a lot recently whilst I'm learning and, like you mentioned, couldn't find much in the way of information on them.
@Melvin88ify
@Melvin88ify 4 жыл бұрын
​@@rosh6369 Not really actually.. it just kinda clicked at some point, seeing them being used in all kinds of different ways over time. I'd say this video does a good job, maybe Brackeys can do a more in-depth topic on this ?? :) For me one of the most powerful things is that it can fire on one frame using the startcoroutine and then have its own independent update running, you can even loop it until you tell it to stop which is very useful for frame by frame animations and tweening positions.
@rosh6369
@rosh6369 4 жыл бұрын
@@Melvin88ify Does this not contribute to memory leaks, though? they seem very powerful, I should do some digging.
@DravicPL
@DravicPL 4 жыл бұрын
@@rosh6369 good question. I have no idea if it contributes to memory leaks over time. I would assume it's unwise to keep an IEnumerator working for longer than a few seconds but who knows. I am sure that they fall under garbage collection after they end executing all of their code.
@endorphingames2957
@endorphingames2957 4 жыл бұрын
@@DravicPL you can keep a coroutine running as long as you like. It gets stopped on scene change/gameobject removal.
@SkyLoad100
@SkyLoad100 4 жыл бұрын
is there any chance someone know how to manage multiple character in one team such as FF
@XEqualsPenguin
@XEqualsPenguin 4 жыл бұрын
I need to make a Turn-Based Combat system for an AI tech demo for a class, so this was timed AMAZINGLY!
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Nice video, helps me a lot.
@itsjoffrey1476
@itsjoffrey1476 4 жыл бұрын
I was just looking for this... Perfect timing
@khalilboss2855
@khalilboss2855 4 жыл бұрын
Best unity tutorial channel ever!
@TheJaviJB
@TheJaviJB 4 жыл бұрын
In the TakeDamage method you could directly return currentHP
@timbelion3765
@timbelion3765 4 жыл бұрын
You looks great today! Ou btw congrats on 900k subs!!
@crazy4videogames_
@crazy4videogames_ 4 жыл бұрын
Hey nice tutorial, would there be a chance for an extended tutorial which covers multiple combatants and different attacks/actions per combatant?
@wadegamez1824
@wadegamez1824 2 жыл бұрын
Просто спасибо тебе за твои гайды, ты просто лучший. Столько всего пересмотрел на ютубе и твои гайды просто лучшие
@Muphet
@Muphet 4 жыл бұрын
finally, i waited for this
@Zethneralith
@Zethneralith 4 жыл бұрын
5:54 It was at this point that I got the joke. Dwayne vs The Rock. Well played, Brackeys. Well played.
@Ebrodrool
@Ebrodrool 8 ай бұрын
Merry Christmas from Majou ;)
@1singe_
@1singe_ 4 жыл бұрын
You should call this episode "Definitly not a Pokemon combat tutorial"
@Coda02
@Coda02 4 жыл бұрын
This is actually what I need and its not really that difficult, thanks again!
@wis6688
@wis6688 4 жыл бұрын
Just in time for my project! Love your videos btw.. Great content! Will you make an advanced tutorial about water and maybe swimming?
@Ethanol3310
@Ethanol3310 4 жыл бұрын
if anyone wants a simpler script for the attack and heal button, I made one myself: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using UnityEngine.SceneManagement; public enum BATTLESTATE { PlayerTurn, EnemyTurn, Win, Lose, Start, Heal } public class BattleSystem : MonoBehaviour { public BATTLESTATE state; public GameObject player; public GameObject enemy; public Transform spawnPoint1; public string YourTurn; public string enemyTurn; [SerializeField] private string newLevel; public bool isDead; public GameObject yourTurn; public GameObject enemysTurn; public Text turn; public string healText; public Slider healthbar; public float Enemyhealth = 100f; public float damage = 20f; public Slider playerHealthBar; public float playerHealth = 100f; public Canvas playerUI; // contains player's action buttons, which start either Attack() or Heal() public Button heal; public Text healbutton; public bool isPressed; public void Attack() { state = BATTLESTATE.PlayerTurn; turn.text = YourTurn; if (state == BATTLESTATE.PlayerTurn) { StartCoroutine(PTurn()); } } public void Heal() { state = BATTLESTATE.Heal; if(state == BATTLESTATE.Heal) { playerHealth = playerHealth + damage; heal.enabled = false; StartCoroutine(DisableHeal()); } } public IEnumerator DisableHeal() { yield return new WaitForSeconds(1f); healbutton.text = healText; } public IEnumerator PTurn() { yield return new WaitForSeconds(1f); Enemyhealth = Enemyhealth - damage; state = BATTLESTATE.EnemyTurn; playerUI.enabled = false; if (state == BATTLESTATE.EnemyTurn) { turn.text = enemyTurn; StartCoroutine(Eturn()); } } public IEnumerator Eturn() { yield return new WaitForSeconds(2f); playerHealth = playerHealth - damage; playerUI.enabled = true; turn.text = YourTurn; } void Update() { playerHealthBar.value = playerHealth; healthbar.value = Enemyhealth; } }
@trackernivrig
@trackernivrig 3 жыл бұрын
Extremely helpful video. Really helped out, and while I will definitely add more to it, and change it so that it fits my vision for my game more, this is really useful for getting the basics down. However, I did notice that if you keep clicking on the player attack, it will cause the damage to just continually go down. I think I was able to solve this by changing the state in the PlayerHeal and PlayerAttack methods before waiting, since that will make it so that the attack and heal methods just return without doing anything else.
@radquwhack
@radquwhack Жыл бұрын
When coding the TakeDamage function REMEMBER TO CHANGE “void” INTO “bool”!! I missed this the first time watching and was losing my mind why calling one TakeDamage function as a bool was fine while a different TakeDamage function had an error for trying to call it as a bool.
@AndersonReis42
@AndersonReis42 4 жыл бұрын
I say thank you. You're a real lifesaver, i've been trying to do this since march! Been struggling with those unholy finite state machines with variable degrees of success.... If i ever finish my game i'll be sure to thank this channel
@AndersonReis42
@AndersonReis42 4 жыл бұрын
I've just tried it. It has worked perfectly fine (well, with minor bugs but nothing serious). This tutorial is easy to follow, and it is really easy to modify the code. I've been researching a bit and some people do actually use corroutines as FSM. WELL, my other projects will surely work really fine now!
@MonochromeChromosome
@MonochromeChromosome 4 жыл бұрын
@@AndersonReis42 great job:) by the way, what are you working on? Might wanna play!
@AndersonReis42
@AndersonReis42 4 жыл бұрын
@@MonochromeChromosome oh, nothing too ambitious. Just a "chicken fighting game". Chicken fights are a brazilian meme :) But i'll use the algorithm later to develop a game where you train a boxer to his way to success. Things are in a very early development stage however
@codegnatstudios
@codegnatstudios 4 жыл бұрын
Thanks so much! These tutorials make my day a whole lot better!
@melodicfish7833
@melodicfish7833 4 жыл бұрын
Sweet man! Thanks for making this :)
@dotaportalvideo
@dotaportalvideo 4 жыл бұрын
This was a great video. Learned a lot from implementing it while following your example.
@jackreacher963
@jackreacher963 4 жыл бұрын
@Brackeys ... Nice Video as always. 2 Video Ideas from me.. 1. second part of this video with a more advanced system 2. enemy sight in 3D.. nothing good out there imo
@hunterbanks3746
@hunterbanks3746 4 жыл бұрын
Thank you so much I have been looking for a good turn based tutorial
@asahi7648
@asahi7648 3 жыл бұрын
Thanks for the help i am working on an rpg for my coding class and this was a big help
@patrickknauer96
@patrickknauer96 4 жыл бұрын
Either I skipped something you did or mashing your attack button can actually call multiple coroutines in a row and since the damage is calculated before the GameState tansition (due to the yield new Wait...) we can instantly damage the opponent to death with a few clicks per second. I added another GameState called WAITand set it to WAIT in the OnAttackButton() before the coroutine is called. Good solution? Did I miss something? Great video btw, you really help me get into the unity classes and UI!
@rigradgaming253
@rigradgaming253 3 жыл бұрын
Hey there, I'm trying to do the exact same thing but I'm unsure where exactly to put the WAIT gamestate? I'm fairly new to Unity and coding in general, please forgive me.
@pacofrost5015
@pacofrost5015 4 жыл бұрын
Great video, can you make one about machine lerning please?
@JarlThorson
@JarlThorson 4 жыл бұрын
I really like the working off the checklist... I wonder if you would consider doing a few video's on how you figure the architectural design before you do the coding? This is the area where I get crippled with choice.
@DravicPL
@DravicPL 4 жыл бұрын
Use your imagination and put yourself in the shoes of a player who does not know anything about your design other than what he sees right now and has seen up until this point. Then go step by step meticulously. What does the player need to see? What has to be hidden from the player? Where will the UI be most visible but least obstructing? Etc.
@JarlThorson
@JarlThorson 4 жыл бұрын
@@DravicPL I appreciate the answer, but I think you are talking about design. I am talking about architecture. I can make something in five different ways where the end user can't tell the difference. Choosing which method to go with is the issue I am talking about.
@xxyxxyyyx
@xxyxxyyyx 4 жыл бұрын
can somebody explain me 12:00 - 13:10 Well I did everything like in the video and it works, but I don't really understand what is happening and would like to: So what does the" GameObject =" actually mean? And what does the Unit component do?
@DarkGrisnak
@DarkGrisnak 4 жыл бұрын
Hi, a bit late for a response but anyway... I hope it will help. The idea is, when you use Instantiate, you copy a prefab and create a GameObject in the scene. That specific GameObject is returned by the Instantiate function, so you can store it in a variable. The Unit component is the script that you've just created, it handles all the stuff linked to the creature like health, damage etc ... We actually only need the Unit component here, not the GameObject, so we could simply do unitPlayer = Instantiate(player, ...).GetComponent();
@ghua
@ghua 4 жыл бұрын
quick question: what plugins would you recommend for: -building levels from prefabs (snapping them together) -organizing hierarchy thx
@MrHunter75012
@MrHunter75012 4 жыл бұрын
if you're still looking for a snap to grid in Unity after all this time, there's ProGrids package in unity
@Jacob-bd9vw
@Jacob-bd9vw 2 жыл бұрын
"The player should be a rock. That's just inherently cool" Lmao.
@energyeve2152
@energyeve2152 4 жыл бұрын
This is awesome! I’m just starting to learn and this was very helpful. Thank you ^_^
@ziraw5941
@ziraw5941 4 жыл бұрын
OMG I LOVE U This is EXACTLY what I wanted YESS ❤
@Argenuto
@Argenuto 3 жыл бұрын
Brackey saving my day... Again! thank you very much!
@curiositytube5924
@curiositytube5924 3 жыл бұрын
This guy is something
MELEE COMBAT in Unity
21:07
Brackeys
Рет қаралды 1,6 МЛН
How Do You Improve Turn Based Combat?
17:43
Design Doc
Рет қаралды 784 М.
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 97 МЛН
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 93 МЛН
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2 МЛН
How to MAKE YOUR GAME LOOK GOOD!
13:02
Brackeys
Рет қаралды 593 М.
How to make a tactics game in only two weeks
19:00
The Shaggy Dev
Рет қаралды 77 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 355 М.
An Aseprite Crash Course In 30 Minutes
31:47
AdamCYounis
Рет қаралды 1,1 МЛН
How I Learned to Create GAMES (No School Required)
9:47
Goodgis
Рет қаралды 572 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 183 М.
Creating SMART enemies from scratch! | Devlog
5:40
Challacade
Рет қаралды 325 М.
choosing a game engine is easy, actually
15:08
samyam
Рет қаралды 479 М.
Turn-Based ENEMY AI for SRPG Games - Tactics Toolkit Devlog #9
17:11
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 97 МЛН