Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | behelit | |
Old Version | Published before Godot 3 was released. |
Hello everyone!
I’m in the process of creating a platformer with kinematic bodies as both the player and the enemies. I’ve been looking at the examples in the demos, but I’ve having trouble finding an appropriate collision detection example I can wrap my head around. The question is this… What is the simplest path to detecting a collision between two kinematic bodies? For example, I’ve got a punch animation and I want to detect if a kinematic body is present inside the area of the punch, so I can then take action on it. Can someone give me a super simple example that would print the string “success!” when this occurs? Or even better, something that prints the name the kinematic body.
Or am I grossly misunderstanding how collisions are supposed to work?
Here is code I’m using in a child to try and detect collisions, but no matter what it overlaps with, the printed result is always
extends Area2D
export var done = false
func _ready():
set_fixed_process(true)
get_node("Timer").start()
print(get_overlapping_bodies())
print(get_overlapping_areas())
func _on_Timer_timeout():
queue_free()
Could REALLY use some help on this guys, I’ve been stuck on this for days.
Your question is about kinematic bodies or areas? both things are completely different.
eons | 2018-01-26 00:38
Honestly, I don’t care how I get there. It could be kinematic bodies, areas, or rigidbody. The moral of the story is, when I stick out my fist, I want to detect what it touches. The end goal is if I punch a wall, I want to get pushed back. If I punch an enemy, I want to be able to register the hit. I’ve managed to get basic collision detection working with area and get_overlapping_bodies, but I’m looking for something a little more descriptive than it simply telling me if I’m touching a body. I want to be able to do if conditions on the result of the collision. I’ve yet to find something that lets me do that, which seems silly to me as it is the basis for most physical interactions in video games.
behelit | 2018-01-26 00:44