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

Third Party basic photon question

Discussion in 'Multiplayer' started by MathNerd, Apr 3, 2014.

  1. MathNerd

    MathNerd

    Joined:
    Feb 24, 2014
    Posts:
    8
    Hi all,

    I have an object w/ trigger collider. I want instantiated players to die when they touch the object. The object has a photonview on it and is part of the scene (not instantiated). It uses the following code to call EnterShip on all players.

    Code (csharp):
    1.  public void OnTriggerEnter(Collider other){
    2.         if (other.gameObject.GetComponent<morphIntoShip> () != null) {
    3.             other.GetComponent<PhotonView>().RPC("EnterShip",PhotonTargets.All);
    4.         }
    5.          }
    Players are instantiated and have the follwoing

    -----------------------------------------------------------------------------
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class morphIntoShip : Photon.MonoBehaviour {
    5.    
    6.     public void KillPlayer(){
    7.         if (PhotonNetwork.isMasterClient) {
    8.             Debug.Log ("I'm MacDaddy MasterClient and i'm gonna off ya!");
    9.             PhotonNetwork.Destroy(gameObject);
    10.         } else {
    11.             Debug.Log ("i'm just a pinhead client and can't destroy instantiated gameobject");
    12.         }
    13.     }
    14.  
    15.  
    16.     [RPC]
    17.     public void EnterShip(){
    18.         KillPlayer();
    19.     }
    20. }
    When the client player touches the ship i get:

    i'm just a pinhead client and can't destroy instantiated gameobject

    i'm just a pinhead client and can't destroy instantiated gameobject


    and both play objects are still present in game.

    When the MasterClient player touches the ship i get:

    i'm just a pinhead client and can't destroy instantiated gameobject

    Ev Destroy for viewID: 1001 sent by owner: True this client is owner: False


    and the original MasterClient player is gone and the client player remains.
    Please help me. Been trying to fix this for two days. If you help me fix this I'll let ya have my wife.
     
    Last edited: Apr 3, 2014
  2. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    168
    Try and instantiate the object. Somtimes non instantiated objects cause issues.
    If is still not working I will do a little example to help you get the issue fixed. I know how bad is to not be able to fix something.
     
    Last edited: Apr 5, 2014
  3. MathNerd

    MathNerd

    Joined:
    Feb 24, 2014
    Posts:
    8
    Thank you very much for the response. You were correct, problem solved when I changed to instantion during oncreateroom

    Have a great day.