I have this code to send info:
using UnityEngine;
using System.Collections;
public class SendAttackInfo : MonoBehaviour {
public int damage = 100;
// Use this for initialization
void Start () {
}
void Update () {
bool RMB = Input.GetMouseButtonDown (1);
if (RMB) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
//&& hit.transform.tag == "Player" && hit.collider.name != this.gameObject.name
if (Physics.Raycast(ray, out hit)){
//float dist = Vector3.Distance(hit.transform.position, this.transform.position);
//if(dist <= 2.0f) {
PhotonView pv = PhotonView.Get(this);
if (pv.isMine) {
hit.collider.gameObject.GetComponent<PhotonView>().RPC("ApplyDamage", PhotonTargets.All);
}
}
//}
}
}
}
And this to recieve:
[PunRPC]
void ApplyDamage(){
curHealth -= 50;
Debug.Log("hit player " + curHealth);
}
When I try them I get this error:
PhotonView with ID 1002 has no method “ApplyDamage” marked with the PunRPC or @PunRPC(JS) property! Args:
Please help!