How to use collisions? Godot collision detection 2d tutorial

preview_player
Показать описание
I want to share an idea for a stomp detector in the Godot engine. I hope you will enjoy this tutorial and learn something from it. I'm talking about killing an enemy using stomp collision and layers, there is also a little part about animation using AnimationPlayer.

---------------- Ways to Support ----------------

---------------- Useful links ----------------

---------------- Contact and social media ----------------

---------------- Music ----------------
🎶 "Dodge the ghosts" - mine :)
🎶"Tupelo_Train" - from YouTube

---------------- Timestamps ----------------
0:30 Download project from GitHub
0:41 Project presentation
1:47 Main Tutorial

Don't forget to leave a comment to let me know if you enjoyed this video, it's important for me! :)
Hope you'll like it!

#godot #tutorial
Рекомендации по теме
Комментарии
Автор

I beleive in the actual Super Mario games, whether Mario stomps on an enemy or he dies when he touches the enemy is purely to do with the y position of Mario relative to the enemy. If I remember correctly, I've seen speedrunners jump on enemies when they left the ground just a few frames before, but because Mario is high enough it registers as a stomp rather than charging into the enemy. So for your game, you'd have just one CollisionShape2D that detects the player, and the enemy dies or the player dies depending on whether the player's y is smaller than the enemy's y.

KlausWulfenbach
Автор

Thank you so much! I've been trying to get collision to work for about a month, and I finally figured it out!

poplel
Автор

I really love how you save ideas from other people. I will have to make a request myself soon I guess :D

mixlaproduction
Автор

You're so wholesome! Great video.

thiagobastos
Автор

Nice tutorial! For the issue of both dieing at the same time, just check whether the player is dead using a flag or state variable before the enemy is killed

mrzero_
Автор

What if I want to do a thwomp enemy from Mario? the stone enemies that fall and hurt you if you walk under them. I'm trying to make one and:
I have one small problem: both player and thwomp are kinematicbody2d, and when the player jumps on top of the thwomp while the thwomp is going up (after falling to the floor, like in mario games), the player stops the thwomp from going up and the thwomp won't move until I restart the scene. How do I make the thwomp push the player up too?

bubblemage
Автор

This is a great Tutorial, but i'm kindof stuck! I can run into my enemies and have them kill my character, but when they run into my character they dont do anything. Been stuck trying to figure this out for hours.

Kaepora
Автор

Here you can find more my public Godot projects ;)

RafaFiedo
Автор

I know this tutorial is pretty old at this point, but I had a question. In the code, you use body.die() to call the players die() function. How do can you make the body that it collided with do something instead? Like for example if you wanted the enemy to jump after you collided with it.

qLeila
Автор

Why the poor cool guy always die after killing the bad guy in the end of the video?? :(((

christianbatista
Автор

sir, please make a video on npc collision detection and direction changing after detecting collision

vaibhavpandey
Автор

pelase, next time leave timestamp where the tut starts

Haykke
Автор

please teach us how to make a fighting game . thanks so much ! :)

ivanmectin
Автор

Bardziej Polskiego akcentu nie da się mieć

szklankaherbaty