Collision not working with CollisionShape3D attached to character skeleton

Godot Version

Godot Engine v4.2.2.stable.official

Question

I am following this tutorial and have run into a situation where an instanced bullet scene is colliding with regular level geometry and a general CollisionShape3D node but not CollisionShape3D nodes I’ve set up for the skeleton. The bullets just fly right through the enemy mouse’s head, even after I increased the size of the head collision shape.

All parent individual Area3D node for each CollisionShape3d is grouped as “enemy” and linked to a script to handle the BodyParts and a “body_part_hit” signal. I have also checked the documentation and triple checked my code and that the collision masks on the raycast of the bullet.tscn are compatible. I am completely stumped.

Bullet Script

extends Node3D

const SPEED: float = 40.0

@onready var mesh = $MeshInstance3D
@onready var ray = $RayCast3D
@onready var particles = $GPUParticles3D

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	position += transform.basis * Vector3(0, 0, -SPEED) * delta
	if ray.is_colliding():
		mesh.visible = false
		particles.emitting = true
		ray.enabled = false 
		if ray.get_collider().is_in_group("enemy"):
			ray.get_collider().hit()
		await get_tree().create_timer(1.0).timeout
		queue_free()

func _on_timer_timeout() -> void:
	queue_free()

Enemy Script

extends CharacterBody3D

var player = null
var state_machine
var health: int = 6

const SPEED : float = 4.0
const ATTACK_RANGE : float = 2.5

@export var player_path : NodePath

@onready var nav_agent = $NavigationAgent3D
@onready var anim_tree = $AnimationTree

# Get player node path
func _ready() -> void:
	player = get_node(player_path)
	state_machine = anim_tree.get("parameters/playback")


# Determine enemy pathing
func _process(delta: float) -> void:
	velocity = Vector3.ZERO
	
	match state_machine.get_current_node():
		"Run":
			# Navigation
			nav_agent.set_target_position(player.global_transform.origin)
			
			var next_nav_point = nav_agent.get_next_path_position()
			
			velocity = (next_nav_point - global_transform.origin).normalized() * SPEED
			
			rotation.y = lerp_angle(rotation.y, atan2(-velocity.x, -velocity.z), delta * 10.0)
		
		"Punch":
			look_at(Vector3(player.global_position.x, global_position.y, 
			player.global_position.z), Vector3.UP)
	
	# Conditions
	anim_tree.set("parameters/conditions/attack", _target_in_range())
	anim_tree.set("parameters/conditions/run", !_target_in_range())
	
	anim_tree.get("parameters/playback")
	
	move_and_slide()

func _target_in_range():
	return global_position.distance_to(player.global_position) < ATTACK_RANGE
	
func _hit_finished():
	if global_position.distance_to(player.global_position) < ATTACK_RANGE + 1.0:
		var dir = global_position.direction_to(player.global_position)
		player.hit(dir)

func _on_area_3d_body_part_hit(dam):
	health -= dam
	if health <= 0:
		queue_free()


Processing: GODOT_mousey_tscn_Area3D_08202024.PNG…

Turns out I had not set my bullet’s RayCast3D to collide with Area3D nodes.

This problem is solved.

I too , am following the same tutorial, can you explain me in such way that I don’t make this mistakes. (This is my very first project and I am very new to Godot).
I did had problems with collisions not sticking with Skeleton during animation in Godot 4.3 . Another was that my zombie animations were horrible , in such a way that ,it looked like sitting on floating commode after punching :joy: ,then when I followed further in videos , started scripting for conditions for “attack” and “run”, my zombie just yeet away from player. Now I just deleted the Zombie.tcsn

Anything you can share to help this rookie out :smiley: