photonView.RPC is wrong?

Options
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Photon.Pun;
  5. public class Player : MonoBehaviourPun {
  6. PhotonView view;
  7. [SerializeField] private Transform grabPoint;
  8. [SerializeField] private Transform holdPoint;
  9. [SerializeField] private float radious;
  10. private GameObject grabbedObject;
  11. private int layerIndex;
  12. void Start()
  13. {
  14. layerIndex = LayerMask.NameToLayer("Pickable");
  15. view = GetComponent<PhotonView>();
  16. }
  17. void Update()
  18. {
  19. if (!view.IsMine)
  20. {
  21. return;
  22. }
  23. if (Input.GetKeyDown(KeyCode.E))
  24. {
  25. RaycastHit2D hitInfo = Physics2D.Raycast(holdPoint.position, transform.right, radious);
  26. if (hitInfo.collider != null && hitInfo.collider.gameObject.layer == layerIndex)
  27. {
  28. if ((Input.GetKeyDown(KeyCode.E)) && grabbedObject == null)
  29. {
  30. grabbedObject = hitInfo.collider.gameObject;
  31. photonView.RPC("PickUp", RpcTarget.AllBuffered);
  32. }
  33. }
  34. }
  35. }
  36. [PunRPC]
  37. void PickUp()
  38. {
  39. grabbedObject.GetComponent<Rigidbody2D>().isKinematic = true;
  40. grabbedObject.transform.position = grabPoint.position;
  41. grabbedObject.transform.SetParent(transform);
  42. }
  43. }


HI!,

"grabbedObject" work perfect in game until player "grab it". Then it start to bug a lot and its not synchronized. Any idea? i gues my photonView.RPC is wrong.