How to make an object visible only to one player not the other one

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to make an object visible only to one player not the other one

Saharsh
2021-10-28 11:14:59

How to make an object visible only to one player not the other one. photonView.IsMine is not working

Comments

[Deleted User]
2021-10-28 11:18:05

Hey, not really sure what you mean. You can turn the renderer off from an RPC if you want to make it invisible to someone. You can do it from the SerializedRead stream too. There are lots of ways to achieve what I think you're trying to say.

Saharsh
2021-10-28 12:02:15

@MeepPun See i want only want to show a UI panel player who got triggered with another object and not to the other players. Pls help

Saharsh
2021-10-28 12:03:14

I tried using if(photonView.IsMine) but for some reason it doesn't work

Saharsh
2021-10-28 12:13:04

The Code Is Here:

using UnityEngine;using TMPro;using Photon.Pun;using Photon.Realtime;p - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

At line 226 at "OnTriggerEnter" function, the if(view.IsMine) statement at line 234.

Saharsh
2021-10-28 12:19:23

I only want the player who got collided with another gameobject called shell which has a tag called "Shell". After it collided with the player, i only want to show him a UI Panel not to the other Players. Pls help

Murky
2021-11-11 20:53:24

You can try changing the location of your trigger method. Move it from the player to the Shell object.

So you will have the next code in the Shell object:

public void OnTriggerEnter(Collider other)    
{    
    if (gameObject == null)    
    {    
        return;    
    }    
    if (other.CompareTag("Player"))    
    {    
        Debug.Log("Player enter the shell");    
        Obj.SetActive(true);    
        Destroy(gameObject);    
    }    
}    

Saharsh
2021-11-16 08:03:16

@Murky thanks, i realized we can also do an RPC

Saharsh
2021-11-16 08:03:30

your one also works!

Back to top