Raycast says it isn't colliding...when it is?

Godot Version

4.6.1

Question

I have a raycast that always points at the player and will check if it’s colliding. I do know how to make the raycast only send a signal/func when it touches the player specifically, however I have this weird issue where when the raycast collides with the CharacterBody3D the player is controlling, it says it is not colliding…yet “.is_colliding()” still returns true?

	if $LOSchecker.is_colliding():
		var playerobj = $LOSchecker.get_collider()
		print(str($LOSchecker.get_collider_shape()))

In the code above (run on “_process(delta)():”) the raycast should only print to console when it is colliding, yet the collider shape that is printed to console is “0”, which means that it’s not colliding…but for that to be true the code shouldn’t even be running in the first place?

Although it looks wrong at a glance, this is actually correct (albeit slightly confusing) behavior.

get_collider_shape is returning the index of the collision shape that is being hit, which is 0 since it’s the CharacterBody3D’s first child collision shape. It only looks incorrect since 0 is also returned when nothing is being hit.

If you try printing playerobj, you should see the CharacterBody3D logged, as expected.