How to display things differently to different players

Options

Currently i'm working on a vr multiplayer project by using fusion.

In this project I want a player cannot see his own avatar head (because it could block views), and other players could see his head.

I wonder how to implement this function. I appreciate any replies.

Answers

  • Vallekralle
    Options

    Hi LBN,

    It depends on the structure from your player and how you instantiate them in a room. Most of the time people do this with a game manager, which instantiates and destroys players in a game.

    Solution:

    Every new player who joins the room in the game scene looks at their own PhotonView (which you need to communicate and send different data, like position and rotation) and checks if they are the owner of this object. If the condition returns true destroy the head. At the end will every other player have a head except the owner of the player, like you wanted it to be.

    The possible code could look like this:

    _______________________________________________________________________

    using Photon.Pun;


    PhotonView PV;

    [SerializeField] private GameObject playerHead;


    private void Awake(){

    PV= GetComponent<PhotonView>();

    }

    private void Start(){

    DestroyHeadFromOwner();

    }

    public void DestroyHeadFromOwner(){

    (if PhotonView.isMine) {

    Destroy(playerHead);

    }

    }

    _______________________________________________________________________


    Don't forget to put the head object in the playerHead field where the script is.

    I hope I could help you,

    Vallekralle

  • Ninety
    Options

    Vallekralle, OP is using Fusion, not PUN, so this unfortunately won't work.

    Object.InputAuthority can be used to poll whether an object "belongs" to the local client.