Raycast not colliding with anything

Godot Version

Godot 4.4.1

Question

Suddenly, the raycast3D for my pistol stop working, making it no longer do damage, well sometimes it does, but rarely, I was using a plugin call DeepRaycast3D, the code for my shotgun and automatic rifle were similar to the pistol, but in the pistol it didn’t work, so I decide to use Godot built in raycast, and that also didn’t work, I tried to do a lot of things, like changing the code in the function that handles the damage to the enemy, move the code from the function to where the fire is handled itself, etc. But nothing works, then, I decided to use a print outside the if statement, and This is what most of the time prints:

<Object#null>

I don’t know what else to do.

Here is the code that handles the detection and damage.

if %raycast_1.is_colliding():
	print("damage_1")
	var use_RAYCAST = raycast3D.get_collider()
	if use_RAYCAST.is_in_group("enemies"):
		BOSS_1.damage_FUNC(pistol_RESOURCE.damage_AMOUNT)

Why are you testing if %raycast_1 is colliding but then getting the collider from raycast3D?

1 Like

I don’t know, but I change it and nothing, until I got close to the boss, and it started to work, and then I realized it was the length of the ray cast, I increase it and now it works. I feel embarrassed for posting this now that I realized that it was the length of the raycast.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.