Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

limiting player FPS vision range ?

Discussion in 'Multiplayer' started by jamesasrah, Oct 12, 2017.

  1. jamesasrah

    jamesasrah

    Joined:
    Sep 29, 2017
    Posts:
    8
    how can i make so that the player can't see other player until they got into my vision range??
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    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.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    PerLayerCulling script (from asset store) is what you want. Note that this isn't "hack" proof concept.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  6. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    With asset you can get extra functionality, like adequate display of layers, but yeah, you're right, it's layerCullDistances that does the trick.
     
  7. Deleted User

    Deleted User

    Guest

    ProximityChecker component.
     
    xVergilx likes this.