RPC has no method

Options
hello ,
I try to spawn enemy on master client, and use RPC for share the view of the spawned enemy,
and i got an erro from this line :
enemy.GetComponent<PhotonView>().RPC("Generate", PhotonTargets.AllBuffered, 9);

PhotonView with ID 8 has no method "Generate" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: Int32

I put the spawn enemy in the network controller like that :

using System.Collections; using System.Collections.Generic; using UnityEngine; public class NetworkController : MonoBehaviour { private string _gameversion="0.1"; public GameObject player; public GameObject Food; public float Speed; GameObject id; // Use this for initialization void Start () { PhotonNetwork.ConnectUsingSettings(_gameversion); } // Update is called once per frame void Update () { //Debug.Log("Status: " + PhotonNetwork.connectionStateDetailed.ToString()); } void OnJoinedLobby() { PhotonNetwork.JoinRandomRoom(); } void OnPhotonRandomJoinFailed() { Debug.Log("Can't join random room! "); PhotonNetwork.CreateRoom(null); } void OnJoinedRoom() { Debug.Log("on viens juste de rejoindre une room"); PhotonNetwork.Instantiate("Prefabs/"+player.name, player.transform.position, Quaternion.identity, 0); if (PhotonNetwork.isMasterClient) { InvokeRepeating("Generate", 0, Speed); Debug.Log("un spawn a était crée"); } } [PunRPC] void Generate() { int x = Random.Range(0, Camera.main.pixelWidth); int y = Random.Range(0, Camera.main.pixelHeight); Vector3 Target = Camera.main.ScreenToWorldPoint(new Vector3(x, y, 0)); Target.z = 0; //Instantiate(Food, Target, Quaternion.identity); GameObject enemy = (GameObject)PhotonNetwork.InstantiateSceneObject("Prefabs/" + Food.name, Target, Quaternion.identity, 0, null); PhotonView view = enemy.GetComponent<PhotonView>(); enemy.GetComponent<PhotonView>().RPC("Generate", PhotonTargets.AllBuffered, (int)view.viewID); } }


thank u in advance for any help


This discussion has been closed.