Search Unity

Third Party PUN photonView problem

Discussion in 'Multiplayer' started by miha4406jp, Aug 27, 2021.

  1. miha4406jp

    miha4406jp

    Joined:
    Apr 8, 2021
    Posts:
    9
    Hello. So, I have:
    1) Login scene, there I enter my Nickname and chose between Blue and Yellow capsule;
    2) Indestructible object Statics to keep my choice;
    3) Game scene with Blue and Yellow capsule game object (not prefabs) with scripts like this attached:
    Code (CSharp):
    1. public class MouseMove1 : MonoBehaviour
    2. {
    3.     bool bControlable;
    4.  
    5.     RaycastHit hit;
    6.     Vector3 clPos;
    7.     Vector3 newDir;
    8.  
    9.     public float rotSpeed = 2f;
    10.     public float mSpeed = 1f;
    11.  
    12.  
    13.     void Start()
    14.     {
    15.         bControlable = false;
    16.  
    17.         if (GameObject.FindGameObjectWithTag("Statics").GetComponent<Statics>().obj1owner == PhotonNetwork.NickName)
    18.         {
    19.             bControlable = true;
    20.         }      
    21.     }
    22.  
    23.    
    24.     void Update()
    25.     {
    26.         if (!bControlable)
    27.         {
    28.             return;
    29.         }
    30.  
    31.         Debug.DrawRay(transform.position, transform.forward*10, Color.green, 0.2f);
    32.  
    33.         Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
    34.  
    35.         if (Input.GetMouseButtonDown(0)) {
    36.            
    37.             if(Physics.Raycast(mRay, out hit))
    38.             {
    39.                 clPos = hit.point;              
    40.             }          
    41.         }
    42.         mMove();
    43.     }
    44.  
    45.  
    46.     void mMove()
    47.     {  
    48.         newDir = Vector3.RotateTowards(transform.forward, clPos, rotSpeed * Time.deltaTime, 0.0f);
    49.         transform.rotation = Quaternion.LookRotation(newDir);
    50.  
    51.         transform.position = Vector3.MoveTowards(transform.position, clPos+Vector3.up, mSpeed*Time.deltaTime);
    52.     }
    53. }
    54.  
    So, basically, I'm using PhotonNetwork.NickName to define, who controls which object.
    Of course, i've attached PhotonView and PhotonTransformView on this capsules.
    Problem is: guest player sees all changes on scene, but host can't see guest player movements.
    What's the problem?
     
  2. miha4406jp

    miha4406jp

    Joined:
    Apr 8, 2021
    Posts:
    9
    Nwm. Idk how to close this question. Just close it please.