21 行
467 B
21 行
467 B
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);
|
|
}
|
|
}
|
|
}
|