mirror of
https://github.com/Dadechin/Unity-WebSocket.git
synced 2025-07-04 04:14:34 +00:00
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using FishNet.Object;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace FishNet.Demo.HashGrid
|
|
{
|
|
|
|
public class GridSpawner : NetworkBehaviour
|
|
{
|
|
[SerializeField]
|
|
private NetworkObject _staticPrefab;
|
|
[SerializeField]
|
|
private NetworkObject _movingPrefab;
|
|
[SerializeField]
|
|
private int _movingCount = 100;
|
|
[SerializeField]
|
|
private byte _spacing = 2;
|
|
|
|
private float _range => MoveRandomly.Range;
|
|
|
|
public override void OnStartServer()
|
|
{
|
|
|
|
|
|
for (int x = (int)(_range * -1); x < _range; x+= _spacing)
|
|
{
|
|
for (int y = (int)(_range * -1); y < _range; y++)
|
|
{
|
|
NetworkObject n = Instantiate(_staticPrefab, new(x, y, transform.position.z), Quaternion.identity);
|
|
base.Spawn(n);
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < _movingCount; i++)
|
|
{
|
|
NetworkObject n = Instantiate(_movingPrefab, transform.position, transform.rotation);
|
|
base.Spawn(n);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} |