How to create a Turn-based Combat System in Godot

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

ความคิดเห็น • 102

  • @zebwest8152
    @zebwest8152 ปีที่แล้ว +204

    If anyone is following this in Godot 4, the format for setting up export variables has changed a bit. It looks like this:
    extends Resource
    @export var name: String = "Enemy"
    @export var texture: Texture = null
    @export var health: int = 30
    @export var damage: int = 20

    • @sableeyedscholar2135
      @sableeyedscholar2135 ปีที่แล้ว +5

      Big thanks, was looking for this comment exactly!

    • @ChuRu386
      @ChuRu386 ปีที่แล้ว +3

      understood the assignment

    • @Kamu34474
      @Kamu34474 ปีที่แล้ว

      Thanks! It helped

    • @Beibai
      @Beibai ปีที่แล้ว +1

      Does anyone know how to fix the breaking point after I put
      set_health($EnemyContainer/ProgressBar, enemy.health, enemy.health)

    • @documentcamera8807
      @documentcamera8807 ปีที่แล้ว

      You're a god send

  • @RegentStatue745
    @RegentStatue745 ปีที่แล้ว +89

    Godot 4 doesn't use yield anymore so be sure to use "await". Here is how I used it for closing the textbox: "await textbox_closed" . And here's how I implemented the timer he creates as well: "await get_tree().create_timer(.25).timeout"

    • @redbul17
      @redbul17 8 หลายเดือนก่อน +4

      very helpful, thank you

    • @jessg0
      @jessg0 4 หลายเดือนก่อน

      sweet, thx!

    • @赵昕昊
      @赵昕昊 4 หลายเดือนก่อน

      You're so sweet,thanks for help

  • @slundal
    @slundal 2 ปีที่แล้ว +87

    I learned more about the UI nodes in 8 minutes from this guy than I have from any other tutorial.

    • @hiiambarney4489
      @hiiambarney4489 ปีที่แล้ว +12

      Same! And the worst part is, they changed them afterwards, so now I don't understand it anymore.

    • @赵昕昊
      @赵昕昊 4 หลายเดือนก่อน

      @@hiiambarney4489 So true,there are too many changes between 3.x & 4.x

  • @rhos-gfx
    @rhos-gfx 7 หลายเดือนก่อน +15

    This is such a nice intermediate tutorial. no waffle or overexplaining, just "here's what i did". I'd love to see more like this.

  • @PostFrontier
    @PostFrontier 2 ปีที่แล้ว +56

    This was, by far, the best tutorial that I've seen for turn based combat in Godot. I'm so happy that I found this tutorial. Great job!!!

  • @Animosity00
    @Animosity00 2 ปีที่แล้ว +10

    I'm watching this trying to self teach myself to make a classic turn-based RPG as an old man with about 12 hours of experience with Godot. Still seems like magic. Great knowledge here to be gained!

  • @RuneDShyznit
    @RuneDShyznit 2 หลายเดือนก่อน +2

    I know it's an older video but better late than never. Just wanted to let you know I learned more about a lot of core aspects of Godot from this video than many other "beginner's guide" videos. Great job explaining stuff in a practical and useful scenario. Thanks.

  • @azaratowcanica2639
    @azaratowcanica2639 2 ปีที่แล้ว +11

    The view count does not do justice to the insanely good informative content! Learnt a lot, Thank you! Hope your channel blows up!

  • @ScarlettTheViewer
    @ScarlettTheViewer 4 หลายเดือนก่อน +2

    This is the most informative and concise video I have ever seen demonstrating specific gameplay with godot. I have spent (admittedly not a ton of time) probably 10 or so hours trying to learn, and hardly got anywhere with it. I know a good bit of python and was honestly considering just using pygame before seeing this. Thank you.

  • @thoof7589
    @thoof7589 2 ปีที่แล้ว +18

    Great tutorial. I didn't know you could yield to signals in that way, very helpful!

  • @rungeon83
    @rungeon83 2 ปีที่แล้ว +14

    This is fantastic, I'm so glad you hit on resources, there is a lot to learn here! Congrats on an amazing tutorial! I'm still finding controls so tricky so your tutorials have been fantastic for helping me get over the fiddlyness :)

  • @owletstree9523
    @owletstree9523 6 หลายเดือนก่อน +3

    Omg I actually managed to re-create everything you did, even 2 years later(with some minor tweaks ofc). Thank you so much!

    • @Abel-fu1xq
      @Abel-fu1xq 6 หลายเดือนก่อน +1

      Hi, can you please let me know how you were able to create the line for the character attack: "set_health($Background/EnemyHealth/ProgressBar, current_enemy_health)"
      It gives me an error message saying:
      "Too few arguments for "set_health()" call. Expected at least 3 but received 2."
      Edit: Nevermind, I completely missed the next argument somehow lol

  • @jackiewatkins1830
    @jackiewatkins1830 11 หลายเดือนก่อน +7

    Im pretty new at this, so i had to slow my man down to like .5 to catch everything he was doing...hes moving fast but excellent showcase of the basic functions that he is covering.

  • @maranr
    @maranr 2 ปีที่แล้ว +9

    Really great. I learned a lot about the use of yield and creating resources. Thanks!

  • @rockerhelgeson
    @rockerhelgeson 2 ปีที่แล้ว +3

    Without a doubt, the best turn based tutorial. Please make more content like this, it has been so helpful!

  • @aneerudh1712
    @aneerudh1712 2 ปีที่แล้ว +3

    I'm convinced you are the fastest typer on the planet

  • @javleds
    @javleds 6 หลายเดือนก่อน

    ¡Gracias!

  • @teo2805
    @teo2805 2 ปีที่แล้ว +1

    Saved for Sunday when I'm done with my exams season... TYSM!

  • @mythology100
    @mythology100 2 ปีที่แล้ว +4

    Greatly appreciated. Glad I subscribed.

  • @filippobegna3512
    @filippobegna3512 2 ปีที่แล้ว +2

    Great job, really liked how you made the video: super clear, fast and efficient

  • @RegentStatue745
    @RegentStatue745 11 หลายเดือนก่อน +7

    The new export format for the "enemy" resource variable looks like this: "@export var enemy: Resource = null"

  • @gustavoalmeidadaribeira1740
    @gustavoalmeidadaribeira1740 ปีที่แล้ว

    This video is helped me a TON with my project.I wish you all the best!

  • @Blackmamba136
    @Blackmamba136 ปีที่แล้ว

    One of the best tutorials I saw!
    Thank you

  • @andersonmaia5767
    @andersonmaia5767 2 ปีที่แล้ว

    Thank you a lot! Using resources to create different enemies is a very handy solution.

  • @theleeyawnshow
    @theleeyawnshow 2 ปีที่แล้ว +1

    I like the tutorial. It's basically all I need for my current project. Also I'm planning on making a tutorial series similar to this one in my own language. I hope it works out fine.

  • @SodaFountainJoy
    @SodaFountainJoy 2 ปีที่แล้ว +1

    Thank you! Very helpful concepts.

  • @wisiel3861
    @wisiel3861 9 หลายเดือนก่อน

    Ja pierdole zajebisty poradnik koleś, wielkie dzięki, doceniam!

  • @anton.s6882
    @anton.s6882 2 ปีที่แล้ว +3

    Thanks man for this tutorial

  • @KEKEISYOU
    @KEKEISYOU 2 ปีที่แล้ว

    This is great! Thank you so much! On a side note i had to watch it at half speed cause you go through everything so fast it's hard to keep up but thank you for this video!

  • @RicardoDavilaTejano
    @RicardoDavilaTejano 2 ปีที่แล้ว +1

    This was VERY informative. Thank you!
    Got the notifications activated so I won't miss your next video. No pressures tho

  • @lukasmorrow8255
    @lukasmorrow8255 2 ปีที่แล้ว

    This was an excellent starting point for me! I'm working on a much meatier combat system, but this really helped with the basics of using my stats resources and getting organized!

  • @buzzbuzz20xx
    @buzzbuzz20xx หลายเดือนก่อน

    Such an amazing video !!!

  • @arttopix7224
    @arttopix7224 ปีที่แล้ว

    Thank you, a lot! This video teaches me more than another tutorial.

  • @musicdudem6673
    @musicdudem6673 2 ปีที่แล้ว

    this is amazing thank you! if you ever want to expand this video into a series, that would be amazing!

  • @shadow-jc3vp
    @shadow-jc3vp 11 หลายเดือนก่อน

    Great quick video. However, I do wish there was more explanation for certain options you chose or things you did in the video. Otherwise, very straight forward. Thanks!

  • @ropepores4688
    @ropepores4688 ปีที่แล้ว

    Thank you! Great tutorial!

  • @broyal_gamers1237
    @broyal_gamers1237 ปีที่แล้ว

    You are a hero thank you!!!

  • @sdalfbg
    @sdalfbg ปีที่แล้ว

    ty, very nice tutorial u helped me a lot

  • @MH-lr6ue
    @MH-lr6ue 2 ปีที่แล้ว +4

    im following your exact instructions but my player's health bar will not expand i can edit the x value but when i play the scene the health bar is just a sliver.

  • @brotherkito
    @brotherkito 3 หลายเดือนก่อน

    In Godot 4, the margin properties have been moved from the HBoxContainer into the MarginContainer object in case anyone is having trouble following that part.

  • @AgriasOaks99
    @AgriasOaks99 8 หลายเดือนก่อน +2

    How do you handle multiple enemies?
    How will the targetting system be like?

  • @lutherbrown8873
    @lutherbrown8873 ปีที่แล้ว +3

    to get timer to work in godot 4+ (I'm using 4.2):
    await(get_tree().create_timer(0.25).timeout)

  • @suthamonhengrasmee8182
    @suthamonhengrasmee8182 2 ปีที่แล้ว

    Thank you very much

  • @keriganknowles2818
    @keriganknowles2818 9 หลายเดือนก่อน +2

    Does anyone know how to change the enemy through code instead of dragging in the editor.

  • @Abel-fu1xq
    @Abel-fu1xq 6 หลายเดือนก่อน +1

    Hi, I got up to the point where he was defining the "func set_health(progress_bar, health, max_health):", but I got stuck on the line "progress_bar.get_node("Label").text = "HP: %d/&d" %[health, max_health]". The progress bar doesn't change at all. what should I do?
    Edit: Nevermind, I just had to chnage it to "HP: %s/&s" %[health, max_health]"

  • @MassiveBreaker
    @MassiveBreaker 2 ปีที่แล้ว +1

    I know that this video is quite old, but is there a way to do screen shake with a shader instead? I don't like the practice of just making the background bigger, say I want to make an fps shake, would I use a shader for that instead?

  • @entityunknown2
    @entityunknown2 ปีที่แล้ว +5

    Speed run

  • @EthernalOynuyor
    @EthernalOynuyor ปีที่แล้ว +1

    How can i do this if some enemies have 2 actions per turn ? the enemies are spawned as instanced scenes.
    i gave the enemies a property called "ActionsPerTurn", and "for n in ActionsPerTurn:" but how would i make it wait until the first action is complete ? there are several attacks the enemies can do and i have a "match" that finds and executes the current action the monster is suppoesed to do. Since i can't do it with signals... i'm lost.

  • @DomZaddy
    @DomZaddy 2 ปีที่แล้ว +1

    I know this is an older video by now but what do I do if when the enemy attacks my player it subtracts less than my enemies damage on the first attack?

  • @KamiSanzo
    @KamiSanzo 5 หลายเดือนก่อน +1

    didn't underrstand anything, 10/10, thanks bro

  • @ZDitohyt
    @ZDitohyt ปีที่แล้ว +1

    When I try to attack again the health bar stays the same, pls some help

  • @ForgottenLight15
    @ForgottenLight15 2 ปีที่แล้ว +2

    You know, you're using _input(event) incorrectly. You're accessing the Input singleton in the _input callback, instead of using the _input callback's event.

  • @the-birbo
    @the-birbo 2 หลายเดือนก่อน

    If you want your UI to move with the camera when it shakes instead of having the camera move past the edges of your UI, create a CanvasItem node and make all your UI nodes children of that node. I have the player panel under a CanvasItem node, but any other UI that you don't want to see past the edges should go there too

  • @PotatoisDry
    @PotatoisDry 2 ปีที่แล้ว +1

    how can i replace the rectTexture with animated sprite in the code?

  • @sanagunx3345
    @sanagunx3345 2 ปีที่แล้ว +1

    This tutorial is so dam good, I learn a lot from this.
    thank you for making this great tutorial for us.

  • @MYNDsEYE
    @MYNDsEYE 4 หลายเดือนก่อน

    How would i take this and trsition a 3d world into this scene?

  • @justarandomgamer5648
    @justarandomgamer5648 7 หลายเดือนก่อน

    Ok how would you go about making like, a magic option or something? Like how would you make it so you could have a menu then pick a spell

  • @irrelevantjoshwaa6156
    @irrelevantjoshwaa6156 ปีที่แล้ว

    where was the function enemy turn first written in the project

  • @Moboscrub
    @Moboscrub 11 หลายเดือนก่อน

    How would you do this if both players are attacking each other at the same time? Like an Auto-battler.

  • @rvn4
    @rvn4 2 ปีที่แล้ว

    Nice video

  • @nerbles7472
    @nerbles7472 ปีที่แล้ว

    is it possible to change what the enemy is? like lets say i kill the dragon and want a different enemy for the next level. would i have to make a completely new scene for that or can change the enemy resource in the script

    • @ghostradiodelete
      @ghostradiodelete 9 หลายเดือนก่อน

      I haven't gone through this whole tutorial yet, but the way I load enemies in my game is (it's a turn-based, 1st person dungeon crawler), for each step, I roll an encounter against a player's stat, if it fails it encounters an enemy. Then I roll a random bit with player's luck added in right, and it pulls from a list of enemies stored for that floor. Not to get too complicated but basically that list is made up of packed scenes. So how I would do it is make a scene and just change out the enemy in that scene - code the enemy AI and stick that as a child on that scene. Then when you load whatever enemy it picked, everything you need is right there.
      Any other questions, happy to answer them. Cheers!

  • @anton.s6882
    @anton.s6882 2 ปีที่แล้ว +1

    When I followed your tutorial, the damage stops at 20 Hp, and 15Hp when the enemy attack, why?

    • @jontopielski6227
      @jontopielski6227  2 ปีที่แล้ว +1

      Double check your logic for when you are reducing the current_player_health or current_enemy_health. You can reference the source code directly here: github.com/jontopielski/Turn-Based-Combat/blob/master/src/Battle.gd

    • @anton.s6882
      @anton.s6882 2 ปีที่แล้ว +2

      @@jontopielski6227 Done, I just need to change -= to =

  • @muziklol69
    @muziklol69 2 ปีที่แล้ว +1

    make a part 2

  • @seedofstun
    @seedofstun ปีที่แล้ว

    my sprite keeps disappearing whenever i put it into a vbox container :/

  • @truenincillo805
    @truenincillo805 2 หลายเดือนก่อน +1

    Please put RPG game tutorial, slow down basic attacks and skills (not turn-based) replace (turn-based battles) with (time in basic attacks and skills) with (icons-buttons) please tutorial 🙏🙏🙏

  • @HProductionsish
    @HProductionsish 7 หลายเดือนก่อน

    I keep getting an error that says the indentifier "State" isn't declared in the current scope" when trying to access the State.gd script. How do I fix this?

    • @yahirfuentes4713
      @yahirfuentes4713 4 หลายเดือนก่อน

      did you figure it out?
      edit: nvm i just did. the name on the autoload wasnt the same so just make sure it matches with your code

  • @Ashiira
    @Ashiira ปีที่แล้ว +47

    This is so difficult to watch as a beginner. I have to pause incredibly often and with great precision, because when he writes something, he'll only display it for a couple of frames and then quickly jump somewhere else, implying that whatever he's done is so obvious that viewers shouldn't even need to see it.

    • @marcelroman6639
      @marcelroman6639 6 หลายเดือนก่อน +7

      Hello! I hope this doesn't come off as rude, but you could watch this video at a slower playback speed

  • @gofastutos
    @gofastutos 2 ปีที่แล้ว +1

    Nive video tutorial but a bit long no ? 😁

  • @gomm888
    @gomm888 17 วันที่ผ่านมา

    If anyone is having trouble with the "yield(self, "textbox_closed")" at 11:25 in GoDot 4. I used "await self.textbox_closed" and it worked.
    My problem was that the game didn't wait for the textbox to close. I hope this helps anyone

  • @justarandomgamer5648
    @justarandomgamer5648 9 หลายเดือนก่อน +2

    small issue I have, on the line: progress_bar.get_node("Label").text = "HP:%d/%d" % [health, max_health]
    when I run it in game it tells me: Invalid set index 'text' (on base: 'null instance') with value of type 'String'.
    can someone help?
    figured it out, had to make the Label a unique name

  • @Beibai
    @Beibai ปีที่แล้ว +2

    Does anyone know how to fix the breaking point after I put
    set_health($EnemyContainer/ProgressBar, enemy.health, enemy.health)

  • @cartian8039
    @cartian8039 10 หลายเดือนก่อน

    Thank you so much