Raycast Player Targeting UdonGraph

Hi. I’ve been trying for a bit to figure out how to get a Ray to point out a specific player, and I’m not quite sure how. The only thing I’ve thought of that could work is getting the transform of the collider of the player, and comparing the distance to all of the players in the world and finding which one is lowest, but that seems sloppy. Is there perhaps another way?

1 Like

You could use an object pool has a collider following each player, and have the raycast collide with that instead.

CyanLaser made an excellent prefab for object pools! GitHub - CyanLaser/CyanPlayerObjectPool: A VRChat system that will assign a unique object to every player in the world.

1 Like

I’m going to mark this as a solution as I’m certain it’ll work based on what I’ve done to mess around with it, but my project is messed up and I can’t get UdonSharp to import properly, so I can’t personally test it without making a whole new project and I’m a bit lazy as of late lol. Thank you very much.

1 Like