How to make Raycast ignore dead players?

Hi,

So in my multiplayer game, if a player dies, their mesh and capsule collider is turned off until they respawn.

If a player kills another player but keeps shooting where the killed player stood, the raycast still hits the dead player even though there is no active capsule collider. I think it’s because of the rigidbody, but how can I either temporarily turn off the rigidbody (if that’s the issue) or make it so that my raycast temporarily can’t hit the dead player?

Hi,

How about putting the players in another layer when they are dead?
And use a layer mask to only hit the one you want with the ray.

1 Like

I like that. I think that would work. Thanks :slight_smile: