I took a look and actually this an old issue with godot physics: Collision Detection between CharacterBody2D and RigidBody2D not working(properly) · Issue #70671 · godotengine/godot · GitHub
As workaround you can use an Area3D to check for collisions (copy-paste in any text editor and save as .tscn as well)
[gd_scene load_steps=8 format=3 uid="uid://bvqveqxt5ooy"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_q6fky"]
[sub_resource type="GDScript" id="GDScript_t8asg"]
script/source = "extends RigidBody3D
func _ready() -> void:
pass
func _on_area_3d_body_entered(body):
# Ignore collision with yourself
if body == self:
return
print(\"Collided with: \", body.name)
func _on_area_3d_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
# Ignore collision with yourself
if body == self:
return
print(\"Alt-Collided with: \", body.name)
"
[sub_resource type="SphereShape3D" id="SphereShape3D_wguyn"]
[sub_resource type="SphereShape3D" id="SphereShape3D_yhuhx"]
radius = 0.51
[sub_resource type="GDScript" id="GDScript_66kcn"]
resource_name = "player"
script/source = "extends CharacterBody3D
func _physics_process(delta: float) -> void:
velocity.y = -0.5
move_and_slide()
"
[sub_resource type="SphereShape3D" id="SphereShape3D_wawyx"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_wfik0"]
[node name="MinimalCase" type="Node3D"]
[node name="Obstacle" type="RigidBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.719876, 0)
physics_material_override = SubResource("PhysicsMaterial_q6fky")
max_contacts_reported = 32
contact_monitor = true
can_sleep = false
script = SubResource("GDScript_t8asg")
[node name="CSGSphere3D2" type="CSGSphere3D" parent="Obstacle"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Obstacle"]
shape = SubResource("SphereShape3D_wguyn")
[node name="Label3D" type="Label3D" parent="Obstacle"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.907448)
text = "Obstacle"
[node name="Area3D" type="Area3D" parent="Obstacle"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Obstacle/Area3D"]
shape = SubResource("SphereShape3D_yhuhx")
[node name="Player" type="CharacterBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.20147, 0)
script = SubResource("GDScript_66kcn")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
shape = SubResource("SphereShape3D_wawyx")
[node name="CSGSphere3D" type="CSGSphere3D" parent="Player"]
[node name="Label3D" type="Label3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.907)
text = "Player
"
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.721601, 2.92241)
[node name="ground collision" type="StaticBody3D" parent="."]
collision_layer = 3
collision_mask = 3
[node name="CollisionShape3D" type="CollisionShape3D" parent="ground collision"]
shape = SubResource("WorldBoundaryShape3D_wfik0")
[connection signal="body_entered" from="Obstacle/Area3D" to="Obstacle" method="_on_area_3d_body_entered"]
[connection signal="body_shape_entered" from="Obstacle/Area3D" to="Obstacle" method="_on_area_3d_body_shape_entered"]