Im trying to make some kind of inventory system that allows the players to pickup and drop weapons. Im just starting out. Heres the script:
using UnityEngine;
using System.Collections;
public class GrenadeLauncher : Photon.MonoBehaviour {
public GameObject Player = null;
void Update () {
if (Player != null) {
Debug.DrawLine(transform.position, Player.transform.position);
transform.position = Player.transform.position;
transform.rotation = Player.transform.rotation;
collider.enabled = false;
if (Player.GetComponent<PhotonView>().isMine) {
if (Input.GetKeyDown("g")) {
photonView.RPC("Playernull",PhotonTargets.AllBuffered);
}
}
}
else {
collider.enabled = true;
}
}
void OnTriggerEnter (Collider col) {
if ( col.gameObject.tag == "Player") {
GameObject send = col.gameObject;
photonView.RPC("Playeris",PhotonTargets.AllBuffered,send);
}
}
[RPC]
public void Playernull()
{
Player = null;
}
[RPC]
public void Playeris(GameObject recive)
{
Player = recive;
}
}
the Error im getting when the RPC´s are called is
Exception: cannot serialize(): UnityEngine.CapsuleCollider
and the weapon is not picked up.
I can’t seem to understand whats wrong.
Help is much apreciated.