Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Martik |
I’m working on a level generator node. This node places RigidBody2D’s within a predefined area. I don’t want them to overlap so they should be deleted as soon as they collide. If they are not deleted, they will inform their parent node that they have been placed so that the desired number of them will be generated. If I was using the old Godot this solution would have worked:
func _ready():
if is_colliding():
queue_free()
else:
get_parent().placed += 1
What is the equivalent of this in Godot 3? I don’t have time to call the move_and_slide function as it should be done instant and only once. Maybe there is an alternative way to detect overlapping?
Have you tried using the signals which are a part of theRigidBody2D
class? Signals such as body_entered()
and body_shape_entered()
?
Ertain | 2021-10-26 08:20