If a raycast hits a gameobject, how do i check who shot that raycast

I’m making a mulitplayer fps game, and I want to know how to check who shot a raycast at a player, when that player dies, so I can make some UI saying that this person killed this person. If a raycast hits a gameobject, how would I check who shot it?

I think the best way is to send the info from the shooter object to the object that gets hit. Using something like RaycastHit.transform.gameObject so you can get access to the hit player.

Hello.

As qarallax say, the best way is to have a public variable in the receptor called somethign like “ShooterThatHit”.

When the soother shoots the raycast, if hits, sets the ShooterThatHit variable from the receptor as itself.

Bye!