TransferOwnership() public method

Transfers the ownership of this PhotonView (and GameObject) to another player.
The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.
public TransferOwnership ( PhotonPlayer, newOwner ) : void
newOwner PhotonPlayer,
return void
Example #1
0
    /// <summary>
    /// Migrate informations while using RPC Requests #TRY#
    /// </summary>
    private void MigrateInformations()
    {
        //MIGRATE ALL DATAS FOREACH ENEMY AND PROPS
        //Start informations with the id of the previous master
        string _info = $"{ hostingManagerPhotonView.owner.ID }@";

        for (int i = 0; i < allAreas.Count; i++)
        {
            TDS_FightingArea _area = allAreas[i];
            _area.ClearDeadEnemies();
            if (_area.DetectionState == SpawnPointState.Enable)
            {
                // SEPARATE WITH & AND ADD OTHER INFOMATIONS
                if (i >= 1)
                {
                    _info += '&';
                }
                _info += _area.GetFightingAreaInfos();
            }
        }
        //ADD PROPS INFORMATIONS + SEPARATE WITH @

        //SEND INFORMATIONS TO THE NEW MASTER
        TDS_RPCManager.Instance.RPCManagerPhotonView.RPC("ReceiveMigrationsInformations", PhotonTargets.MasterClient, _info);
        hostingManagerPhotonView.TransferOwnership(PhotonNetwork.masterClient);
    }
Example #2
0
 private void CheckLocalPlayer()
 {
     // Checks for New Data
     TeamNumOld     = TeamNum;
     TeamNum        = (int)PhotonNetwork.LocalPlayer.CustomProperties["Team"];
     IsReadyOld     = IsReady;
     IsReady        = (bool)PhotonNetwork.LocalPlayer.CustomProperties["ReadyToPlay"];
     DisplayNameOld = DisplayName;
     DisplayName    = (string)PhotonNetwork.LocalPlayer.CustomProperties["DisplayName"];
     if (TeamNum != TeamNumOld)
     {
         ChangedTeam = true;
         PV.TransferOwnership(PhotonNetwork.LocalPlayer.ActorNumber);
     }
     else if (IsReady != IsReadyOld)
     {
         ChangedReady = true;
         PV.TransferOwnership(PhotonNetwork.LocalPlayer.ActorNumber);
     }
     else if (DisplayName != DisplayNameOld)
     {
         ChangedDisplayName = true;
         PV.TransferOwnership(PhotonNetwork.LocalPlayer.ActorNumber);
     }
 }
Example #3
0
 private void OnTriggerEnter(Collider other)
 {
     if ((other.gameObject.layer & playerLayer) != 0)
     {
         if (PlayerNetwork.local.playerState.Status != PlayerState.PlayerStatus.GHOST)
         {
             int a = OnCollect(other.gameObject);
             if (a > 0)
             {
                 int x = (int)(PlayerNetwork.local.gameObject.transform.position.x - 0.5) / 4;
                 int y = (int)(PlayerNetwork.local.gameObject.transform.position.z - 0.5) / 4;
                 print("Pris : " + x + " " + y);
                 int s = y * CreateRoomMenu.Xm + x;
                 print(s);
                 PlayerNetwork.local.PowerUpPris(s);
                 if (a == 1)
                 {
                     pv.TransferOwnership(PhotonNetwork.LocalPlayer);
                     PhotonNetwork.Destroy(gameObject);
                     pv.TransferOwnership(PhotonNetwork.MasterClient);
                 }
             }
         }
     }
 }
Example #4
0
 public void VechielAction(int Pvid)
 {
     if (!HavePeople)
     {
         Engine.Play();
         PlayerPv = PhotonView.Find(Pvid);
         Vpv.TransferOwnership(PlayerPv.ownerId);
         HeadPv.TransferOwnership(PlayerPv.ownerId);
         HavePeople = true;
         shot.SetPlayerPhotonView(PlayerPv);
         if (PlayerPv.isMine)
         {
             Al.enabled = true;
         }
     }
     else
     {
         if (PlayerPv.isMine)
         {
             Vpv.TransferOwnership(PhotonNetwork.masterClient.ID);
             HeadPv.TransferOwnership(PhotonNetwork.masterClient.ID);
             Al.enabled = false;
         }
         Engine.Stop();
         HavePeople = false;
         PlayerPv   = null;
     }
 }
Example #5
0
        // Handle Ownership Requests (Ex: Grabbable Ownership)
        public void OnOwnershipRequest(PhotonView targetView, Player requestingPlayer)
        {
            bool amOwner = targetView.AmOwner || (targetView.Owner == null && PhotonNetwork.IsMasterClient);

            NetworkedGrabbable netGrabbable = targetView.gameObject.GetComponent <NetworkedGrabbable>();

            if (netGrabbable != null)
            {
                // Authorize transfer of ownership if we're not holding it
                if (amOwner && !netGrabbable.BeingHeld)
                {
                    targetView.TransferOwnership(requestingPlayer.ActorNumber);
                    return;
                }
            }

            MemoryNetworkedGrabbable netGrabbableCM = targetView.gameObject.GetComponent <MemoryNetworkedGrabbable>();

            if (netGrabbableCM != null)
            {
                // Authorize transfer of ownership if we're not holding it
                if (amOwner && !netGrabbableCM.BeingHeld)
                {
                    targetView.TransferOwnership(requestingPlayer.ActorNumber);
                    return;
                }
            }
        }
Example #6
0
    private void OnTriggerStay(Collider other)
    {
        Rigidbody otherRb = other.attachedRigidbody;

        if (otherRb == null)
        {
            return;
        }

        PhotonView photonView = otherRb.GetComponent <PhotonView>();

        if (photonView != null)
        {
            if (!photonView.IsMine)
            {
                photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
            }
        }
        if (otherRb.transform.childCount > 0)
        {
            photonView = otherRb.transform.GetChild(0).GetComponent <PhotonView>();
            if (photonView != null)
            {
                if (!photonView.IsMine)
                {
                    photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
                }
            }
        }
        Grabbable gr = otherRb.GetComponent <Grabbable>();

        if (gr == null)
        {
            return;
        }

        float triggerValue = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, myHand);

        Debug.Log(this.name + ": " + triggerValue);

        if (triggerValue > 0.3f && grabbedObject == null)
        {
            attachPoint.position = otherRb.position;
            attachPoint.rotation = otherRb.rotation;
            if (gr.startGrab(this, attachPoint))
            {
                grabbedObject = gr;
            }
        }
        else if (triggerValue < 0.2f && grabbedObject != null)
        {
            if (gr.endGrab(this))
            {
                grabbedObject = null;
            }
        }
    }
Example #7
0
 // Use this for initialization
 void Start()
 {
     elevatorDoorComp = ElevatorDoor.GetComponent <ElevatorDoorController>();
     //objectsInside = new HashSet<GameObject>();
     view = GetComponent <PhotonView>();
     view.TransferOwnership(PhotonNetwork.masterClient);
     objectsInsideViewIDs = new HashSet <int>();
     viewTransform        = view.transform;
     view.TransferOwnership(PhotonNetwork.masterClient.ID);
 }
Example #8
0
    /// <summary>
    /// Instantiates a new ship into the game world for the given team on the given node
    /// </summary>
    /// <param name="node">the node to place the ship</param>
    /// <param name="team">the team the ship is assigned to</param>
    /// <returns>A reference to the newly created ship</returns>
    public Ship spawnShip(Node node, Team team)
    {
        GameObject parent = GameObject.Find("Ships");

        if (parent == null)
        {
            parent      = Instantiate(new GameObject());
            parent.name = "Ships";
        }
        GameObject shipPrefab = Resources.Load("Prefabs/Ship") as GameObject;

        GameObject spawn = Instantiate(shipPrefab, node.getRealPos(), Quaternion.identity);

        Ship ship = spawn.GetComponent <Ship>();

        PhotonView          pv  = spawn.AddComponent <PhotonView>();
        PhotonTransformView ptv = spawn.AddComponent <PhotonTransformView>();

        pv.ObservedComponents = new List <Component>();
        pv.ObservedComponents.Add(ptv);
        pv.OwnershipTransfer = OwnershipOption.Takeover;
        pv.Synchronization   = ViewSynchronization.Unreliable;
        //pv.ViewID = (int)(team.TeamFaction+1) * 100 + (ship.Id+1) * 10;

        if (PhotonNetwork.IsConnected)
        {
            if (PhotonNetwork.IsMasterClient)
            {
                if (!PhotonNetwork.AllocateSceneViewID(pv))
                {
                    Debug.LogError("Failed to allocated viewID for ship");
                }
            }
            else
            {
                pv.TransferOwnership(PhotonNetwork.MasterClient);
            }
        }

        //    Debug.Log((int)(team.TeamFaction + 1) * 100 + (ship.Id + 1) * 10);
        //Debug.Log(pv.ViewID);

        if (PhotonNetwork.IsConnected && !PhotonNetwork.IsMasterClient)
        {
            pv.TransferOwnership(PhotonNetwork.MasterClient);
            //spawn = PhotonNetwork.Instantiate("Prefabs/Ship",node.getRealPos(),Quaternion.identity);
        }

        spawn.transform.parent = parent.transform;

        ship.intialize(team, node);
        ship.name = team.TeamFaction.ToString() + " ship " + ship.Id;

        return(ship);
    }
 void TransferDriverPhotonViewOwnership()
 {
     // lookup the player from the gamestate tracker
     if (PhotonNetwork.IsMasterClient)
     {
         gamestateTracker = FindObjectOfType <GamestateTracker>();
         // gamestateTracker.ForceSynchronisePlayerList();
         Player p = PhotonNetwork.CurrentRoom.GetPlayer(driverId);
         //Debug.Log("Player p in driver transfer: " + p.ToString() + " name: " + p.NickName);
         //Debug.Log("driver in transfer: " + p.NickName);
         driverPhotonView.TransferOwnership(p);
     }
 }
Example #10
0
    public void PickUp(PickUpable item)
    {
        currentHeldItem = item;

        PhotonView view = item.GetComponent <PhotonView>();

        // transfer ownership to the player if they were not already the owner
        if (!view.IsMine)
        {
            view.TransferOwnership(PhotonNetwork.LocalPlayer);
        }
        else
        {
            // check if the item is a gun or a rock
            // we set ikActive to true to let the player look as if they are holding the item
            // we set the handObj to be an empty game object on the item which indicates where the player should appear to be holding the item
            if (item.tag == "Gun")
            {
                item.transform.GetChild(17).GetChild(0).gameObject.SetActive(true);
                GetComponent <IkBehaviour>().ikActive = true;
                GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(18);
            }
            else if (item.tag == "Rock")
            {
                GetComponent <IkBehaviour>().ikActive = true;
                GetComponent <IkBehaviour>().handObj  = item.transform.GetChild(0).transform.GetChild(2);
                // sets a fake rock to active so the player can see a rock on their screen to let them know they are holding a rock
                actualCamera.transform.GetChild(0).gameObject.SetActive(true);
            }

            photonView.RPC("PickUpRPC", RpcTarget.Others, item.transform.GetComponent <PhotonView>().ViewID);
            photonView.RPC("PickUpRPCLocal", PhotonNetwork.LocalPlayer, item.transform.GetComponent <PhotonView>().ViewID);
        }
    }
    void movePlayerByItem()
    {
        PhotonView playerHitItemPhotonView = playerHitItem.ItemObject.GetPhotonView();
        string     itemOwnerName           = Regex.Match(playerHitItemPhotonView.Owner.ToString(), @"([A-z])\w+").Value;

        if (itemOwnerName != PlayerScript.PlayerNickname)
        {
            playerHitItemPhotonView.TransferOwnership(PhotonNetwork.LocalPlayer);
        }

        object[] destroyedItemData = new object[] { playerHitItem };

        PhotonNetwork.RaiseEvent(RaiseEventCode.ITEM_USED_BY_PLAYER, destroyedItemData, RaiseEventOptions.Default, SendOptions.SendReliable);

        playerScript.PlayerMoveByItem(playerHitItem.Destination, playerHitItem.Type);

        if (StillMoveBecauseItem == false)
        {
            playerScript.PlayerWalkinItemPosition = 0;
            if (playerHitItem.Type == Card.CardType.Snake || playerHitItem.Type == Card.CardType.Snake2Head)
            {
                //SoundManager.PlaySoundEffect("SnakeDied");
            }
            else
            {
                //SoundManager.PlaySoundEffect("LadderDestroyed");
            }
            PhotonNetwork.Destroy(playerHitItem.ItemObject);
            cardManager.ItemOnBoard.Remove(playerHitItem);
            isReadyMovebyItem = false;
        }
    }
 public void NotInteractedOn()
 {
     if (photonView != null)
     {
         photonView.TransferOwnership(0); //transfer ownership back to scene
     }
 }
Example #13
0
 public void Trasfer(Player player)
 {
     if (!(_photon.Owner == player))
     {
         _photon.TransferOwnership(player);
     }
 }
Example #14
0
    void VacuumObject()
    {
        Collider[] hitObjects        = Physics.OverlapSphere(transform.position, radius);
        float      minDistanceToHand = float.MaxValue;

        for (int i = 0; i < hitObjects.Length; i++)
        {
            if (hitObjects[i].GetComponent <IVacuumable>() == null)
            {
                continue;
            }

            //filter out objects not in vacuum's view
            Vector3 normalizedDir = vacuumPoint.forward.normalized;
            Vector3 dirToObject   = (hitObjects[i].transform.position - vacuumPoint.position).normalized;
            if (Vector3.Dot(normalizedDir, dirToObject) < angle)
            {
                continue;
            }

            float distanceToHand = Vector3.SqrMagnitude(hitObjects[i].transform.position - transform.position);
            if (distanceToHand < minDistanceToHand)
            {
                minDistanceToHand = distanceToHand;
                closestObject     = hitObjects[i].gameObject;
            }
        }

        if (closestObject != null)
        {
            PhotonView closesObjectView = closestObject.GetComponent <PhotonView>();
            if (closesObjectView.Owner != PhotonNetwork.LocalPlayer)
            {
                closesObjectView.TransferOwnership(PhotonNetwork.LocalPlayer);
            }

            closestObject.GetComponent <IVacuumable>().GetVacuumed();
        }

        if (prevClosestObject != closestObject && prevClosestObject != null)
        {
            prevClosestObject.GetComponent <IVacuumable>().VacuumRelease();
        }

        prevClosestObject = closestObject;

        if (closestObject == null)
        {
            return;
        }

        float distanceToObject        = (closestObject.transform.position - vacuumPoint.position).magnitude;
        float distanceSpeedMultiplier = Mathf.Lerp(0.1f, 1, 1 - (distanceToObject / radius));

        closestObject.transform.position = Vector3.Lerp(closestObject.transform.position, vacuumPoint.position, Time.deltaTime * speed * distanceSpeedMultiplier);
        if ((closestObject.transform.position - vacuumPoint.position).magnitude < 0.05f)
        {
            LockEnergyBall();
        }
    }
Example #15
0
 private void OnGameStart()
 {
     if (((isPlayer1 && PhotonNetwork.IsMasterClient) || (!isPlayer1 && !PhotonNetwork.IsMasterClient)) && !photonView.IsMine)
     {
         photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
     }
 }
Example #16
0
 private void OnTriggerEnter(Collider other)
 {
     if (_network.IsMine)
     {
         if (!transform.parent)
         {
             if (other.gameObject.layer == Utils.PlayerLayer)
             {
                 PhotonView collidingView = other.GetComponent <PhotonView>();
                 if (!collidingView.IsMine)
                 {
                     _network.TransferOwnership(collidingView.Owner);
                 }
                 collidingView.RPC("RPC_OnPlayerGotFlag", RpcTarget.All, _network.ViewID);
             }
         }
         if (other.gameObject.layer == Utils.FlagZoneLayer)
         {
             InGameCommon.CurrentGame.GetComponent <PhotonView>().RPC(
                 "RPC_OnFlagCaptured", RpcTarget.AllBufferedViaServer,
                 other.GetComponent <FlagZone>().Team, _network.ViewID
                 );
             Destroy(this);
         }
     }
 }
Example #17
0
 private void setViewOwnership(PhotonView view)
 {
     if (view.ownerId != PhotonNetwork.player.ID)
     {
         view.TransferOwnership(PhotonNetwork.player.ID);
     }
 }
Example #18
0
    public virtual void SetupAbility()
    {
        driverPhotonView = transform.root.GetComponent <PhotonView>();
        // assign photon view to the driver
        abilityPhotonView = GetComponent <PhotonView>();
        abilityPhotonView.TransferOwnership(driverPhotonView.Owner);


        //Player gunnerPlayer = gunnerPhotonView.Owner;

        _networkPlayerVehicle = driverPhotonView.GetComponent <NetworkPlayerVehicle>();
        myVehicleManager      = driverPhotonView.GetComponent <VehicleHealthManager>();
        driverAbilityManager  = driverPhotonView.GetComponent <DriverAbilityManager>();

        if (_networkPlayerVehicle != null)
        {
            myNickName = _networkPlayerVehicle.GetDriverNickName();
            myPlayerId = _networkPlayerVehicle.GetDriverID();
            myTeamId   = _networkPlayerVehicle.teamId;
        }
        else
        {
            Debug.LogError("Ability does not belong to a valid vehicle!! Assigning owner to null");
        }

        uiCanvas      = FindObjectOfType <UiCanvasBehaviour>().GetComponent <Canvas>();
        targetOverlay = Instantiate(targetOverlayPrefab, uiCanvas.transform);
        targetOverlay.SetActive(false);
        lastTarget = transform;
        isSetup    = true;
        Invoke(nameof(GetCarList), 2f);
    }
Example #19
0
 private void TransferOwnership()
 {
     if (PhotonNetwork.IsMasterClient)
     {
         m_view.TransferOwnership(PhotonNetwork.MasterClient);
     }
 }
Example #20
0
        public void StartTurn()
        {
            cardWindow.gameObject.SetActive(false);
            CameraController.viewDiceRoll = true;
            if (players[currentPlayer] == PhotonNetwork.LocalPlayer)
            {
                // Transfer ownership to current player so we can control and sync movement of the dice
                dicePhotonView.TransferOwnership(PhotonNetwork.LocalPlayer);

                popUpWindow.SetActive(true);
                popUpWindow.SendMessage("DisplayText", "It's your turn! Press space to roll the dice", SendMessageOptions.RequireReceiver);

                StartCoroutine(WaitForDiceRoll(diceNum => {
                    EnableButton("endTurnButton");
                    Move(diceNum);
                    CameraFollow.isFollowing = true; // Move camera to target for current player
                    LandedOn(diceNum);
                }));
            }
            else
            {
                string text = "It's " + players[currentPlayer].NickName + "'s turn!";
                popUpWindow.SetActive(true);
                popUpWindow.SendMessage("DisplayText", text, SendMessageOptions.RequireReceiver);
            }
        }
        // Object spawning methods
        public int SetupLocalPlayer()
        {
            MPLogger.Log("Setting up local player");
            MPLogger.Log($"{HeroController.instance.col2d.GetType().ToString()}");

            GameObject local = new GameObject("NetworkPlayerSender");

            DontDestroyOnLoad(local);

            PhotonView    view   = local.AddComponent <PhotonView>();
            NetworkPlayer player = local.AddComponent <NetworkPlayer>();

            view.ownershipTransfer = OwnershipOption.Takeover;
            view.synchronization   = ViewSynchronization.UnreliableOnChange;
            view.viewID            = PhotonNetwork.AllocateViewID();
            view.TransferOwnership(PhotonNetwork.player);
            view.ObservedComponents = new List <Component>
            {
                player
            };

            RaiseEventOptions options = new RaiseEventOptions()
            {
                CachingOption = EventCaching.AddToRoomCache
            };

            PhotonNetwork.RaiseEvent(NetworkCallbacks.OnSetupLocalPlayer, view.viewID, true, options);

            localPlayer = player;

            needsToSetupPlayer = false;

            return(view.viewID);
        }
Example #22
0
    public void OnOwnershipRequest(object[] viewAndPlayer)
    {
        PhotonView   view             = viewAndPlayer[0] as PhotonView;
        PhotonPlayer requestingPlayer = viewAndPlayer[1] as PhotonPlayer;

        view.TransferOwnership(requestingPlayer.ID);
    }
 public void OnOwnershipRequest(PhotonView targetView, Player requestingPlayer)
 {
     if (targetView.gameObject.GetComponent <NetworkControllableObject>() != null)
     {
         targetView.TransferOwnership(requestingPlayer);
     }
 }
Example #24
0
 public void Assign(Player player)
 { // a simple method that gets called by the player list to assign players to the labels.
   // could probably be done better, but I had trouble instantiating UI through the network instantiate function,
   // and this was my workaround
     Debug.Log("Transfer Ownership");
     pv.TransferOwnership(player);
 }
Example #25
0
        public virtual void CheckForNullOwner()
        {
            // Only master client should check for empty owner
            if (!PhotonNetwork.IsMasterClient)
            {
                return;
            }

            // No longer requesting ownership since this view is mine
            if (requestingOwnerShip && view.AmOwner)
            {
                requestingOwnerShip = false;
            }

            // Currently waiting for ownership request
            if (requestingOwnerShip)
            {
                return;
            }

            // Master Client should Request Ownership if not yet set. This could be a scene object or if ownership was lost
            if (view.AmOwner == false && view.Owner == null)
            {
                requestingOwnerShip = true;
                view.TransferOwnership(PhotonNetwork.MasterClient);
            }
        }
Example #26
0
 void TransferControl(Player idPlayer)
 {
     if (PV.IsMine)
     {
         PV.TransferOwnership(idPlayer);
     }
 }
        /// <summary>
        /// Will create the scripts needed to sync the local players position, rotation and animation to others
        /// </summary>
        void AddEssentialComponentsToPlayer()
        {
            GameObject playerBody = Player.main.transform.Find("body").gameObject;
            // Because we can't use PhotonNetwork.Instantiate(), we need to allocate a view ID manually
            int id = PhotonNetwork.AllocateViewID();

            localPlayerView        = playerBody.AddComponent <PhotonView>();
            localPlayerView.viewID = id;
            localPlayerView.TransferOwnership(PhotonNetwork.player);
            localPlayerView.synchronization   = ViewSynchronization.UnreliableOnChange;
            localPlayerView.ownershipTransfer = OwnershipOption.Takeover;

            // We can sync this ID to other players using PhotonPlayer.CustomProperties
            Hashtable playerProps = new Hashtable();

            playerProps.Add("ObjectID", id);

            PhotonNetwork.player.SetCustomProperties(playerProps);

            // Using a custom class rather than PhotonTransformView and PhotonAnimatorView
            NetPlayerSync positionSync = playerBody.AddComponent <NetPlayerSync>();

            positionSync.animator = playerBody.transform.Find("player_view").GetComponent <Animator>();

            localPlayerView.ObservedComponents = new List <Component>();
            //localPlayerView.ObservedComponents.Add(transView);
            localPlayerView.ObservedComponents.Add(positionSync);
        }
Example #28
0
        private async void RemoteInstantiate(
            short jobId,
            short objNameStringId,
            Vector3 position,
            Quaternion rotation,
            object[] data,
            PhotonMessageInfo info)
        {
            // this logic must be executed on the master client
            if (PhotonNetwork.IsMasterClient)
            {
                string objName = await NetworkedStringManager.GetString(objNameStringId);

                GameObject result             = MasterSceneNetworkInstantiate(objName, position, rotation, data);
                PhotonView photonViewOnResult = result?.GetComponent <PhotonView>();
                int        resultPhotonViewId = 0;
                if (photonViewOnResult != null)
                {
                    resultPhotonViewId = photonViewOnResult.ViewID;
                    photonViewOnResult.TransferOwnership(info.Sender);
                }
                photonView.RPC("RemoteInstantiationFinished", RpcTarget.Others,
                               info.Sender.ActorNumber,
                               jobId,
                               resultPhotonViewId
                               );
            }
        }
Example #29
0
    // Update is called once per frame
    void Update()
    {
        if (!photonView.isMine && PhotonNetwork.connected)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.E) && triggerRange && !holdingDiamond)
        {
            photonView.RPC("GetDiamond", PhotonTargets.All, null);

            holdingDiamond = true;

            diamondView.TransferOwnership(PhotonNetwork.player);

            //photonView.RPC("playerLight", PhotonTargets.Others, true);
        }
        else if (Input.GetKeyDown(KeyCode.E) && holdingDiamond || Input.GetKeyDown(KeyCode.R) && holdingDiamond)
        {
            photonView.RPC("DropDiamond", PhotonTargets.All, null);

            if (Input.GetKeyDown(KeyCode.R)) //allows the player to throw the diamond
            {
                diamondRB.AddForce(transform.forward * 500);
            }

            holdingDiamond = false;

            //photonView.RPC("playerLight", PhotonTargets.Others, false);
        }
    }
Example #30
0
        void OnPhotonInstantiate(PhotonMessageInfo info)
        {
            GameJamGameManager gm = GameJamGameManager.instance;
                // e.g. store this gameobject as this player's charater in PhotonPlayer.TagObject
                PhotonView pv = GetComponent <PhotonView>();

            id = (int)pv.instantiationData[0];
            Debug.Log("ID: " + id);
            // gameObject.transform.SetParent(playersParent.transform);
            gm.players.Add(this);
            if (id == GameJamGameManager.LocalPlayerId)
            {
                gameObject.name = "Active Player";
                CameraFollow.instance.target = transform;
            }
            else
            {
                if (PhotonNetwork.player.IsMasterClient)
                {
                    pv.TransferOwnership(id);
                }
                gameObject.name = "Other Player";
            }

            initialColorAssignment();
        }