сростил проекты
This commit is contained in:
1 parent
a4573f2d12
commit
dfd44aa129
684 files changed
+152796
-67
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obstacle
|
||||
{
|
||||
public class StaticObstacle : MonoBehaviour
|
||||
{
|
||||
public float despawnDistance = 20f;
|
||||
|
||||
private Transform _player;
|
||||
private GameObject _originalPrefab;
|
||||
|
||||
public void Init(Transform player, GameObject prefab)
|
||||
{
|
||||
_player = player;
|
||||
_originalPrefab = prefab;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_player != null && transform.position.z < _player.position.z - despawnDistance)
|
||||
{
|
||||
SimpleObjectPool.Instance.ReturnToPool(_originalPrefab, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user