What's wrong with my script ?
Hello bros.
This script is intended to produce amount of (food) objects for the players over the network. What should happen is that when a player eats one food, another food object gets created in another random place. Somehow it doesn't do that.
Here's the script.
public class FoodManager : Photon.MonoBehaviour {
 [SerializeField] GameObject smallCirclePrefab;
 [SerializeField] float widthOfBoard = 100;
 [SerializeField] float heightOfBoard = 100;
 [SerializeField] int amtOfSmallCircle = 100;
 [SerializeField] int sizeOfCircle = 5;
 // Use this for initialization
 void Start()
 {
    if(PhotonNetwork.isMasterClient)
    produceSmallCircle(amtOfSmallCircle);
 }
 // Update is called once per frame
 void Update()
 {
 }
 void produceSmallCircle(int n)
 {
     Vector2 position;
     GameObject circle;
     float positionX, positionY;
     int ratioOfSize = 5;
     for (int i = 0; i < n; i++)
     {
         positionX = Random.Range(-widthOfBoard / 2, widthOfBoard / 2);
         positionY = Random.Range(-heightOfBoard / 2, heightOfBoard / 2);
         position = new Vector3(positionX, positionY,0);
         circle = PhotonNetwork.InstantiateSceneObject(smallCirclePrefab.name, position, transform.rotation, 0,null) as GameObject;
         circle.transform.localScale = new Vector3((float)sizeOfCircle / ratioOfSize, (float)sizeOfCircle / ratioOfSize, (float)sizeOfCircle / ratioOfSize);
     }
 }
}
and here's the other script
using UnityEngine; using System.Collections;
public class FoodCollision : Photon.MonoBehaviour {
 public static float amtOfIncreaseSpeed = 1f;
 public static float amtOfIncreaseHealth = 1f;
 public static float ratioOfSpeed = 150.0f;
 public static float increaseSize = 0.001f;
 PhotonView photonView;
 BoxCollider2D boxCollider;
 SpriteRenderer sp;
 void Awake()
 {
     photonView = PhotonView.Get(this);
     boxCollider = GetComponent<BoxCollider2D>();
     sp = GetComponent<SpriteRenderer>();
 }
 // Use this for initialization
 void Start()
 {
 }
 // Update is called once per frame
 void Update()
 {
 }
 public void DestroyGO()
 {
     
     photonView.ownerId = PhotonNetwork.player.ID;
     boxCollider.enabled = false;
     sp.enabled = false;
     photonView.RPC("DestroyRPC", PhotonTargets.MasterClient);
    
 }
 [PunRPC]
 void DestroyRPC()
 {
     PhotonNetwork.Destroy(gameObject);
 }
}
And what part of that script is means to be detecting when the player has eaten the food and creating a new one?
it was in another script, sorry about that, i edited the post.
Questions like "What's wrong with my script" clearly belongs to the help room and not the default space as this is a pure debugging question.
I moved the question to the help room.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                