Grab and Throw not sync
I can normally grab and throw if it is not online but online i just don't understand how i can sync, i have put all photon transform view on all i want to grab and also i have tried to change ownership but just doesn't work via online.
this is the grabber object:
https://ibb.co/t3G81Lc
and this is the object i want to grab
https://ibb.co/vXtzzLx
this is the grabber object:
https://ibb.co/t3G81Lc
and this is the object i want to grab
https://ibb.co/vXtzzLx
public class Grab : MonoBehaviourPunCallbacks { public bool grabbed; RaycastHit2D hit; public float distance = 2f; public Transform holdpoint; public Transform grabDetect; public float throwforce; public LayerMask notgrabbed; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetButtonDown("LeftShift")) { if (!grabbed) { Physics2D.queriesStartInColliders = false; hit = Physics2D.Raycast(grabDetect.position, Vector2.right * transform.localScale, distance); if (hit.collider != null && hit.collider.tag == "Box") { grabbed = true; base.photonView.RequestOwnership(); } if (hit.collider != null && hit.collider.tag == "P1") { grabbed = true; base.photonView.RequestOwnership(); } if (hit.collider != null && hit.collider.tag == "P2") { grabbed = true; base.photonView.RequestOwnership(); } } else if (!Physics2D.OverlapPoint(holdpoint.position, notgrabbed)) { grabbed = false; if (hit.collider.gameObject.GetComponent<Rigidbody2D>() != null) { hit.collider.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(transform.localScale.x, 1) * throwforce; } } } if (grabbed) hit.collider.gameObject.transform.position = holdpoint.position; }
0