Hey! Nice video!! On minute 13:00 you mention that it is not the best way with dealing with the attack animation issue (forcing the animation player to finish playing the attack animation by only allowing walk/idle to play if the attack animation is not playing). The purpose of me reaching your video was precisely how to overcome that issue, and I see that your method works! So thanks for that. However, what would be a better way of approaching that issue? Thank you!!
Essentially the better way is to have a state machine that knows what the player is able to do, is currently doing and all the rules for this. Essentially when the player is idle they can change to walk, run, attack, jump. www.gdquest.com/tutorial/godot/design-patterns/finite-state-machine/ You can then tell the animation to blend between the different states (dealing with Animation blending is quite time consuming and there are others out there who have put together far better videos and guides).
It will all depend on how you setup the boss. Consider the following example boss structure: BodyCharacterBody3D - Head -- HeadCollision - Main Body -- MainBody Collision -- Arm --- ArmCollision -- Leg --- LegCollision You could have collision meshes on each part of the body and they would act independently (e.g. allowing for headshots) If you want to move the entire boss around the screen animate and move BossCharacterBody3D. Because all of the collision shapes are children (lower in the tree) of BossCharacterBody3D when you move this node / object all of the others move with it. Also if you animate the head the HeadCollision will move with it.
No worries, I haven't got a 2D version for this but there is a 3D version here (ua-cam.com/video/1XOyr6DMLiM/v-deo.htmlsi=38_hNUhOey0uhlm8) I'll try to get something on this. Look up NavigationAgents (docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationagents.html) Kids Can Code have an example for Godot 3 which will cover the key parts kidscancode.org/godot_recipes/3.x/ai/chase/index.html
Stumbled on this great tutorial while trying to fix my situation. Maybe you can help me out? Idle and moving right is perfectly fine but the collision 2d on my sprite don't stay on the sprite once I move left? The shape moves out further left...
When I flipped the sprite with the scale.x property, only my sprite flips but not my collision shapes. Unless I missed it in the video, how did you flip the collision when the sprite flips during the attack?
how can i do it if i have an animated sprite2d with the texture animations? because i can't keyframe from the animated sprite frames so that i am able to see where to put the collision shape. Like the main problem here is that I can see what is currently going on in the animation so that I have to guess where to put the collider or any other thing if i want to. Now i am using animated sprite 2d because I have one sprite sheet with all the animations rather than separate file for each of them.
Go to the Nodes tab in the inspector (rather than Signals) and you can create groups there and assign other nodes to them. docs.godotengine.org/en/stable/tutorials/scripting/groups.html
when i keep the right button pressed while attacking once, the attack animation plays forever until i release the move button xD Any ideas on how to fix that?
It's probably a matter of using "is_action_pressed()" instead of "is_action_just_pressed()". The latter will only trigger on the frame you press the button. The former triggers every frame you have that button pushed down.
Thanks, I'll take that into account when making more tutorials. Thankfully Godot 4.2 allows you to have a separate code window which means I'll be able to have code filling the entire screen easily.
Beginner here, but on my first try with an animated sprite I couldnt get the attack animation to work well, then with animations on a "normal" sprite it was really easy
cool, i want to learn from your scripts, but the link is not working. I want to know how to make a group of enemy so i can check body.is_in_group(Enemy)
Create and edit groups in the nodes tab of the inspector (the same tab with all the signals). I prefer using layers and masks though. They're super helpful, and if you set them up correctly, the Areas will only detect what you want them to detect! I found this video from Garbaj that's pretty good ua-cam.com/video/ZNcFpDSWRUw/v-deo.htmlsi=USKR0V12eHRV4T0G this applies to PhysicsBodys and Areas
thank you sir
thank you a lot man!!!! now i can finally start to work a lot on my game!!!
No worries, pleased to be of help.
Hey! Nice video!!
On minute 13:00 you mention that it is not the best way with dealing with the attack animation issue (forcing the animation player to finish playing the attack animation by only allowing walk/idle to play if the attack animation is not playing). The purpose of me reaching your video was precisely how to overcome that issue, and I see that your method works! So thanks for that. However, what would be a better way of approaching that issue? Thank you!!
Essentially the better way is to have a state machine that knows what the player is able to do, is currently doing and all the rules for this.
Essentially when the player is idle they can change to walk, run, attack, jump.
www.gdquest.com/tutorial/godot/design-patterns/finite-state-machine/
You can then tell the animation to blend between the different states (dealing with Animation blending is quite time consuming and there are others out there who have put together far better videos and guides).
thanks man you are the bast
How would collision hurtboxes work when the boss is animated eg. A boss who's head is animated to move around the screen in a spinning effect
It will all depend on how you setup the boss.
Consider the following example boss structure:
BodyCharacterBody3D
- Head
-- HeadCollision
- Main Body
-- MainBody Collision
-- Arm
--- ArmCollision
-- Leg
--- LegCollision
You could have collision meshes on each part of the body and they would act independently (e.g. allowing for headshots)
If you want to move the entire boss around the screen animate and move BossCharacterBody3D. Because all of the collision shapes are children (lower in the tree) of BossCharacterBody3D when you move this node / object all of the others move with it. Also if you animate the head the HeadCollision will move with it.
Amazing, working 10/10.
I'm trying to create something like action rpg, can you show how to make the enemy attack me? Ty, amazing video btw.
No worries, I haven't got a 2D version for this but there is a 3D version here (ua-cam.com/video/1XOyr6DMLiM/v-deo.htmlsi=38_hNUhOey0uhlm8)
I'll try to get something on this.
Look up NavigationAgents (docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationagents.html)
Kids Can Code have an example for Godot 3 which will cover the key parts
kidscancode.org/godot_recipes/3.x/ai/chase/index.html
Stumbled on this great tutorial while trying to fix my situation.
Maybe you can help me out?
Idle and moving right is perfectly fine but
the collision 2d on my sprite don't stay on the sprite once I move left?
The shape moves out further left...
When I flipped the sprite with the scale.x property, only my sprite flips but not my collision shapes. Unless I missed it in the video, how did you flip the collision when the sprite flips during the attack?
Page Not Found when clicking your source code man
how can i do it if i have an animated sprite2d with the texture animations? because i can't keyframe from the animated sprite frames so that i am able to see where to put the collision shape. Like the main problem here is that I can see what is currently going on in the animation so that I have to guess where to put the collider or any other thing if i want to.
Now i am using animated sprite 2d because I have one sprite sheet with all the animations rather than separate file for each of them.
you assigned a group "Enemy", but I have no idea how you created said grp.
Go to the Nodes tab in the inspector (rather than Signals) and you can create groups there and assign other nodes to them.
docs.godotengine.org/en/stable/tutorials/scripting/groups.html
@@learnictnow ty for this. It's amazing how many little details about this engine I still haven't discovered
when i keep the right button pressed while attacking once, the attack animation plays forever until i release the move button xD Any ideas on how to fix that?
It's probably a matter of using "is_action_pressed()" instead of "is_action_just_pressed()". The latter will only trigger on the frame you press the button. The former triggers every frame you have that button pushed down.
would be nice if you minimize the output window to see more of the code on screen, thank you
Thanks, I'll take that into account when making more tutorials. Thankfully Godot 4.2 allows you to have a separate code window which means I'll be able to have code filling the entire screen easily.
Why didn't you use an animated sprite 2d node instead of sprite 2d?
Beginner here, but on my first try with an animated sprite I couldnt get the attack animation to work well, then with animations on a "normal" sprite it was really easy
cool, i want to learn from your scripts, but the link is not working. I want to know how to make a group of enemy so i can check body.is_in_group(Enemy)
Create and edit groups in the nodes tab of the inspector (the same tab with all the signals).
I prefer using layers and masks though. They're super helpful, and if you set them up correctly, the Areas will only detect what you want them to detect!
I found this video from Garbaj that's pretty good ua-cam.com/video/ZNcFpDSWRUw/v-deo.htmlsi=USKR0V12eHRV4T0G this applies to PhysicsBodys and Areas