how can i make so that the player can’t see other player until they got into my vision range??
One way might be to disable the renderer of the remote player object when it is beyond the range that you want it to be visible.
I’ve never tried this, but I’m wondering if you could pull this off by using two cameras. Set the first camera with a far clipping plane set to the distance you want other players to appear, and the second camera with the near clipping plane starting at that same distance and going out further. Assign the players to their own layer, and use culling mask on the second camera to not display the players. You’d avoid having to recalculate range to all players in update, or however you’d do it, and avoid enabling/disabling renderers.
I don’t know if you’d get any graphic artifacts at the transition between the two cameras though.
PerLayerCulling script (from asset store) is what you want. Note that this isn’t “hack” proof concept.
Hey I had forgotten I had done this in a different game. No asset from the store needed, just need to set Camera.layerCullDistances. Completely forgot.
With asset you can get extra functionality, like adequate display of layers, but yeah, you’re right, it’s layerCullDistances that does the trick.
ProximityChecker component.