Added fruit spawner
This commit is contained in:
24
Assets/Scripts/FruitSpawner.cs
Normal file
24
Assets/Scripts/FruitSpawner.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation
|
||||
{
|
||||
public class FruitSpawner : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Transform FruitSpawnParent;
|
||||
[SerializeField] private GameObject FruitPrefab;
|
||||
|
||||
[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.");
|
||||
|
||||
rb.velocity = Random.insideUnitCircle * 2.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user