Added despawning when out of bounds
This commit is contained in:
@@ -9,16 +9,19 @@ namespace Fruitomation
|
||||
[Header("References")]
|
||||
[SerializeField] private Transform FruitSpawnParent;
|
||||
[SerializeField] private GameObject FruitPrefab;
|
||||
[SerializeField] private Canvas GameCanvas;
|
||||
|
||||
[UsedImplicitly, InspectorCallable("Spawn Fruit")]
|
||||
private void SpawnFruit()
|
||||
{
|
||||
GameObject go = Instantiate(FruitPrefab, FruitSpawnParent);
|
||||
|
||||
Rigidbody2D rb = go.GetComponent<Rigidbody2D>();
|
||||
Debug.Assert(rb != null, "Could not find Rigidbody2D component on FruitSpawner.");
|
||||
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
|
||||
Debug.Assert(behaviour != null, "Could not find FruitBehaviour");
|
||||
|
||||
rb.velocity = Random.insideUnitCircle * 2.5f;
|
||||
behaviour.InitFruitBehaviour
|
||||
(
|
||||
GameCanvas
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user