Search code examples
collision-detectiongodot

I want to see if player is on or below enemy in godot


I want To see if my player is on top or beside the enemy in Godot. I want to kill the player if he goes beside the spider and kill the spider if the player jumps on it. my player and enemy are both KinematicBody2D's. I know how to kill the player or enemy(queue_free()) except I cannot detect if the player is on top or below the player. How would I go about doing this?


Solution

  • On CollisionShape2D you can enable one_way_collision for both player and enemy choose collision way (top in your case), if it colides from the top just use queue_free()