ashish2244's picture
Initial commit (part 2)
8df9a4f verified
Raw
History Blame Contribute Delete
467 Bytes
using UnityEngine;
public class FoodLogic : MonoBehaviour
{
public bool respawn;
public FoodCollectorArea myArea;
public void OnEaten()
{
if (respawn)
{
transform.position = new Vector3(Random.Range(-myArea.range, myArea.range),
3f,
Random.Range(-myArea.range, myArea.range)) + myArea.transform.position;
}
else
{
Destroy(gameObject);
}
}
}