- Edited
Hello! I should start off this post by saying that I am fairly new to Godot, but I have a good amount of coding experience and a little game dev experience. I'm currently trying to get a hitbox/hurtbox system working with Area3D objects attached to BoneAttachment3D's but the collisions are not registering. I've read through a good amount of documentation and tried for a couple days to debug it to no avail, so I decided to reach out for help.
The hitboxes are on collision mask layer 3 and the hurtboxes are on collision layer 3. Both the hurtboxes and hitboxes are scenes being instantiated at runtime through code, and have CollisionShape3D's as children of each of them. I currently have this code in my Hurtboxes:
extends Area3D
var material = load("res://Assets/Resources/hurtboxMaterial.tres")
func init(hurtbox):
position.y += hurtbox.sizeY/2
var boxSize = Vector3(hurtbox.sizeX,hurtbox.sizeY,hurtbox.sizeZ)
var box : BoxShape3D = BoxShape3D.new()
box.extents = boxSize/2
$CollisionShape3D.shape = box
var myMesh = MeshInstance3D.new()
myMesh.mesh = BoxMesh.new()
myMesh.mesh.set_size(boxSize)
myMesh.mesh.surface_set_material(0, material)
add_child(myMesh)
self.area_entered.connect(_on_area_entered)
func _physics_process(delta):
pass
func _on_area_entered(area):
print("here")
("here" should get printed whenever a hitbox area enters the hurtbox. Init is called on the creation of a hurtbox. The hitboxes have similar code.)
And this is what my game currently looks like with my created debug mode on:
(Hitboxes/hurtboxes collide, but "here" isn't printed in console)
These CollisionShape3D's do appear in Godot's debugger as blue cornered boxes, but they are very hard to read so I created my own.
Am I not using the signal correctly? Am I misusing Area3D's? If I'm lacking in providing info, I'll add it in a reply. Any help would be appreciated.