Get raycast to pass through object/ignore first hit?

Godot Version

4.4

Question

`Hi,
I’m trying to create a hitscan weapon that can be fired from inside a vehicle.
I got everything done, the weapon works fine, it uses a raycast node to register hits,
you can get in the car with the gun, BUT when you fire the gun inside the car the bullet
immediately hits the car and stops.
I want to make it so that the bullet ignores the first hit (which is always the cars collision shape) and travels outside the car, but apparently you can’t do that with raycasting.
Or can you?
Is there a way for a hitscan/raycast weapon to ignore the first hit and keep moving past it?

Any help would be appreciated, thank you!

Are you able to add the entered vehicle as a collision exception using add_exception?

1 Like

I tried doing that, I actually even tried putting the car in its own group and then exclude the group, but I couldn’t get it to work I don’t fully understand why :\

It actually doesn’t really matter now, I ended up using a different solution: whenever the player is in the car there’s a vertical offset so the ray is cast a bit above the center of the screeen, so it passes over the car and doesn’t hit it even when the camera angle is changed.
Thanks for replying!