photonView.RPC is wrong?
Options
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class Player : MonoBehaviourPun {
PhotonView view;
[SerializeField] private Transform grabPoint;
[SerializeField] private Transform holdPoint;
[SerializeField] private float radious;
private GameObject grabbedObject;
private int layerIndex;
void Start()
{
layerIndex = LayerMask.NameToLayer("Pickable");
view = GetComponent<PhotonView>();
}
void Update()
{
if (!view.IsMine)
{
return;
}
if (Input.GetKeyDown(KeyCode.E))
{
RaycastHit2D hitInfo = Physics2D.Raycast(holdPoint.position, transform.right, radious);
if (hitInfo.collider != null && hitInfo.collider.gameObject.layer == layerIndex)
{
if ((Input.GetKeyDown(KeyCode.E)) && grabbedObject == null)
{
grabbedObject = hitInfo.collider.gameObject;
photonView.RPC("PickUp", RpcTarget.AllBuffered);
}
}
}
}
[PunRPC]
void PickUp()
{
grabbedObject.GetComponent<Rigidbody2D>().isKinematic = true;
grabbedObject.transform.position = grabPoint.position;
grabbedObject.transform.SetParent(transform);
}
}
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.
0