I am having problems with photon a=is anyone able to help?

Hey guys, i am having problems with this error
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FoodSpawn : Photon.MonoBehaviour 
{
	//public GameObject _foodPrefab ;
	public GameObject[] _foodPrefabArray ;

	public float minX;
	public float maxX;
	public float minY;
	public float maxY;

	public Vector2 Min ;
	public Vector2 Max ;


	private Vector3 myFoodPos ;

	//	public Rigidbody2D foodClone ;

	void Start() 
	{
		InvokeRepeating ("MyFoodSpawn", 5f, 0.5f);
	}

	void MyFoodSpawn() 
	{

		myFoodPos = new Vector3 ( Random.Range(Min.x , Max.x )  , Random.Range(Min.y , Max.y) , 0 )  ;
		int randomNumber = Random.Range (1, 10000);
		photonView.RPC("SpawnForEverybody", PhotonTargets.AllBuffered, myFoodPos, randomNumber);


		//   var foodClone = Instantiate ( _foodPrefab, myFoodPos  , transform.rotation ) as Rigidbody2D ;

	}
	[PunRPC]
	void SpawnForEverybody(Vector3 _myFoodPos,string _name)
	{
		var i = Random.Range ( 0 ,  _foodPrefabArray.Length);
		var randomRandomClone =Instantiate (_foodPrefabArray [i], _myFoodPos, transform.rotation) as GameObject;
		randomRandomClone.transform.name = _name;
	}
}
and basically it isn't spawning any kind of food if you need anymore code i will be able to provide it :).

Answers

  • calling RPC you need to pass a array of objects
    like that:
    photonView.RPC("SpawnForEverybody", PhotonTargets.AllBuffered, new object[]{myFoodPos, randomNumber});
Sign In or Register to comment.