2D Platformer Attacks and Enemy Setup ~ Godot 4 Tutorial

preview_player
Показать описание
Guide on how to set up basic platformer attacks and enemies inside of Godot 4. This is the final part on my mini-series.

➣ Downloadable Assets, Video Courses, and Other Places to Follow Me

00:00:00 - What to Expect
00:00:29 - Download Below
00:00:40 - Starting Point
00:00:56 - Attack Animation
00:03:15 - Attack 2 Animation
00:04:26 - Animation Tree Attack 1 and Attack 2 Nodes
00:06:09 - Create Attack State
00:07:25 - Switch to Attack from Ground
00:10:23 - Attack State Logic
00:15:13 - How to Get AnimationTree Playback
00:15:53 - Switching from Attack 1 Animation
00:16:41 - Move to lower case move
00:17:20 - Travel to Ground / Attack2 Animations
00:18:34 - Centering Player Sprite2D
00:20:04 - Sword Hitbox
00:22:42 - Make Test Enemy
00:24:05 - Snail Enemy Setup
00:26:20 - Making Objects Damageable
00:27:42 - Sword Hit on Damageable Object
00:29:31 - Debug Print Damage on Hit
00:30:00 - Disabling and Enabling Sword Hitbox
00:32:12 - Show Damage Text on Hit
00:36:28 - Health Text Manager
00:38:40 - Floating Text Label
00:41:53 - Floating Text Label Scripting
00:43:59 - Set Text Color
00:45:15 - Snail Dead Animation
00:46:20 - Snail Animation Tree
00:47:08 - Snail State Machine
00:47:57 - Hit State
00:50:56 - State Interrupt
00:53:50 - Snail Character Movement Script
00:55:25 - Remove Character after Dead Animation
00:56:33 - Snail Movement
00:58:15 - Removing Player Enemy Collisions
01:00:15 - Snail Movement Logic
01:01:10 - Hit Knockback on Sword Hit
01:03:42 - Exit Hit State on Timer
01:05:17 - Directional Knockback (Left / Right)
01:09:08 - Flipping Sword Hitbox Position Left / Right
01:13:46 - Show Visible Collision Shapes for Testing
01:14:28 - Mass Snail Duplication
01:15:01 - Fix: Character Not on Ground at Start
01:16:24 - Wrapup
01:17:08 - Finished Project Download Below
Рекомендации по теме
Комментарии
Автор

I love how thie video begins by explaining what are we going to expect follows by some of the basic mechanics instead of many tutorials straight jump into the editor and coding to leave the viewers wonder if those tutorials are what they need. As a complete godot beginning, it definitely give me a good guide

kuangmengg
Автор

cant express enough how grateful i am for you taking the time to make these tutorials brother. i have 0 programming knowledge and was able to get enough from these to mess around and make some cool shit.

Psydefex
Автор

took me about 2 weeks to finish this course in my free time. Im grateful for the work you've put into this. I hope to see more done on your channel with godot4!

OHMSdev
Автор

these tutorials are amazing! I just started working with my first game engine and started with these tutorial series, I'm learning so much, thank you so much for all the work you do.

daniel
Автор

Great work! Really recommend you to make a HitBox & HurtBox scene, so that you could use them in almost everyone of your game with just a little modification

WeirdGoat
Автор

Thank you so much for continuing this tutorials

pascalcasier
Автор

oooh, lucky me, i just finished your other tutorials and was looking for a attack and enemy setup

raoinshishiza
Автор

What I love about your tutorials is the fact that you show how to resolve my same issues (chain attack, multiple sprite sheet for animations, sprite offset, state machine etc). I really appreciate it.
Other tutorials are somehow done ad hoc with their assets, your is most realistic ever. Thank you.

CosimoDavideViggiano
Автор

This course is incredible! So well structured and clearly explained. For damaging the enemy, instead of creating the Damageable class and looping through all of the body's children to find if the body has that class, I like to use and implement a method take_damage(damage : float) in any character I want to be 'damageable'. Much more performant than looping through the children of every body you collide with. Thanks for the course! :)

NicholasKJ
Автор

Please keep uploading this longs videos! I'll watch in detail!

khzzzzzzzz
Автор

These tutorials are so great! All other ones that I try and watch are in a previous version of Godot. You’re awesome!!!

Jestertdye
Автор

FYI if you ever have to change the name of a variable, if you highlight it and hit ctrl R (cmd R on Mac I guess) it'll give you a prompt to set the new variable name and replace all so you don't have to go searching for it.

davidank
Автор

with reference to the flipping of the sword collision shape, a much simpler solution is to add this code to the update_facing_direction function func update_facing_direction():
if direction.x > 0:
sprite.flip_h = false
if sign( == -1:
collision_shape_2d.position.x *= -1
elif direction.x < 0:
sprite.flip_h = true
if sign( == 1:
collision_shape_2d.position.x *= -1

richardsymes
Автор

Thank you for your tutorial I do love it, but I facing a problem where copy of my snail do not apply the knockback effect (the knockback effect only apply to the first snail). Can you help me

atif-szqp
Автор

Hey mate, these tutorials are fantastic. I've been following you all the way and i've learned a ton, so massive thank you. The pace is difficult to keep up with though! I know you've got a lot to get through, but spare some thought for me in the next one xD

hbora
Автор

These videos are honestly so helpful for learning about godot!!!

acidjuice
Автор

Awsome tutorial, an option for the change of combo attack animations is to use the animator. This can be good if your attack animations have a recovery animation included that you ither want to skip or make it so you cant combo when the recovery starts.

Ofc some change to the code is also needed if you go this route, if anyone wants to try it you have to split the functionality in the animation_finished function and create another function, mine was named Combo and also a bool that is Exported so the Animator can set the bool, this is used instead of a timer so you can get rid of that one.

Then the Animation Finised function only handles the Next_State if the animation have finished and only returns to the return state.
The Combo function is activated when you press the attack button while the canCombo bool is true (that gets set in the animation keyframes) and it checks for what node is currently active.
As an example it attack_1 is active the attack function would call playback.Start(attack_2).

HansChristian-bjpt
Автор

Don't get me wrong I've learned lots from this video and the previous one BUT I really feel liked you messed up use of the state machine, like playing animations for the next state when these obviously should have been in the on_enter for the next state. Jump logic in the Ground state where there should be a Jump state IMO. Just like you did the state_input and state_process I added an on_animation_finished too, which was useful in the Attack state and Dead state which helped to simplify the code. Adding a previous state parameter to the on_enter method was really useful too for the Attack, InAir and Hit states.

malcolmcolindixon
Автор

If you go through the trouble to set up a state machine, each state should handle playing it's own animation in it's on_enter() function. That way you only have to set up the next state, and never have to remember to call travel() to change the animation as well.

lenonkitchens
Автор

55:20 Except, we don't get the death animation. The snail turns immortal instead.
Update: If you have the same problem, it was a node naming and calling discrepancy. I straightened that out and it worked.
I had 2 other typo related problems that gave me errors after this timestamp. Fixing all of those got me to the end of the vid, following along.
I followed along with Godot ver. 4.0.2. Best of luck to everyone else!

noiJadisCailleach