Hello!
I would like to ask for some help. How can I add headshot damage to the hitscan hit? Unfortunately, currently only the enemy’s “CharacterBody3D” CollisionShape3D is detected. I have already tried adding a separate group to the Area3D but it does not detect it either.
If you have a whole body collision for the character, and you want separated collisions for body parts then you have to set the collision layers of the body parts to different layers than the whole body collision, and set your ray cast to only detect the collision layer of the body parts.
Also I think by default ray casts don’t detect areas, only bodies, you have to enable it (can’t remember off the top of my head what’s the variable called)
edit:
new_intersection.collide_with_areas = true
new_intersection.collision_mask = (collision layer of your areas, that are different from the whole body collision layer..)
It only detects the CollisionShape3D added to the CharacterBody3D. If I turn this off, it does not detect hits. I want it to detect the Area3D added to the bones. As you can see in the picture, I added Area3D to the bones. I added the Area3D added to the head bone to which I added the “Enemy_Head” group. I want it to take double the base damage if I hit it. If I hit the Area3D added to the other bones, it takes the normal damage. But for some reason it does not detect the Area3D assigned to any of the bones.
Hello!
I managed to get it to recognize different hits based on group. The problem was that I accidentally added BoneAttachment3D instead of PhysicalBone m. How did this work is a mystery .But unfortunately the old death function does not work. My problem would be the following:
Invalid call nonexistent function ‘death’ in base ‘PhysicalBone 3d’
You’re calling death() based on the CollisionObject3D (which is the PhysicalBone3D in this case), but that function is on the enemy scene’s root node. So, you have to somehow transmit the call through the enemy scene.
You can probably just look for the closest parent node that has a death() function before calling it:
while not enemy.has_method("death"):
enemy = enemy.get_parent()
enemy.death(...)