Files
2026-02-21 16:45:37 +08:00

41 lines
916 B
C#

using UnityEngine;
namespace UltimateWater.Samples
{
public class SardineBoidsController : MonoBehaviour
{
[SerializeField]
private int _XCount = 2;
[SerializeField]
private int _YCount = 3;
[SerializeField]
private int _ZCount = 4;
[SerializeField]
private GameObject _SardinePrefab;
[SerializeField]
private Transform _Target;
private void Start()
{
for (int i = 0; i < _ZCount; i++)
{
for (int j = 0; j < _YCount; j++)
{
for (int k = 0; k < _XCount; k++)
{
Vector3 position = base.transform.position + Vector3.right * k + Vector3.up * j + Vector3.forward * i;
GameObject gameObject = Object.Instantiate(_SardinePrefab, position, base.transform.rotation);
gameObject.transform.SetParent(base.transform);
SardineBoid component = gameObject.GetComponent<SardineBoid>();
component.Destination = _Target;
}
}
}
}
}
}