Added despawning when out of bounds

This commit is contained in:
2026-03-30 11:21:34 +01:00
parent c2455dba60
commit 921f4531b8
6 changed files with 102 additions and 8 deletions

View File

@@ -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
);
}
}
}