25 lines
733 B
C#
25 lines
733 B
C#
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;
|
|
}
|
|
}
|
|
}
|