#17 Rockfall 무한 루프 버그 수정
+ Rockfall 코루틴 방식 -> Update 방식으로 변경 (간헐적으로 무한 루프에 걸리는 버그 테스트 더 필요)
This commit is contained in:
parent
e57dae33c0
commit
65282463e5
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using BlueWater.Audios;
|
using BlueWater.Audios;
|
||||||
using BlueWater.Interfaces;
|
using BlueWater.Interfaces;
|
||||||
@ -45,38 +46,54 @@ namespace BlueWater
|
|||||||
private ParticleSystem _groundCrashParticle;
|
private ParticleSystem _groundCrashParticle;
|
||||||
|
|
||||||
private Collider[] _hitColliders = new Collider[4];
|
private Collider[] _hitColliders = new Collider[4];
|
||||||
|
private RaycastHit _raycastHit;
|
||||||
|
private float _startDistance = float.PositiveInfinity;
|
||||||
private bool _isGrounded;
|
private bool _isGrounded;
|
||||||
private bool _isAttacked;
|
private bool _isAttacked;
|
||||||
|
|
||||||
// Hashes
|
// Hashes
|
||||||
private static readonly int _fillHash = Shader.PropertyToID("_Fill");
|
private static readonly int _fillHash = Shader.PropertyToID("_Fill");
|
||||||
|
|
||||||
private IEnumerator Start()
|
private void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
Debug.DrawRay(transform.position, Vector3.down * _checkDistance, _isGrounded ? Color.blue : Color.red);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
{
|
{
|
||||||
_sphereCollider.enabled = false;
|
_sphereCollider.enabled = false;
|
||||||
SpawnLocation = MapManager.Instance.SandMoleMapController.ParticleInstantiateLocation;
|
SpawnLocation = MapManager.Instance.SandMoleMapController.ParticleInstantiateLocation;
|
||||||
|
|
||||||
|
if (!Physics.Raycast(transform.position, Vector3.down, out _raycastHit, 10f, _groundLayer))
|
||||||
|
{
|
||||||
|
Debug.LogError("땅을 감지하지 못하는 버그");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BasicSetting();
|
BasicSetting();
|
||||||
ShowIndicator();
|
ShowIndicator();
|
||||||
|
_startDistance = _raycastHit.distance;
|
||||||
var startDistance = float.PositiveInfinity;
|
|
||||||
while (!_isGrounded)
|
|
||||||
{
|
|
||||||
if (!Physics.Raycast(transform.position, Vector3.down, out var hit, 10f, _groundLayer)) continue;
|
|
||||||
|
|
||||||
if (float.IsPositiveInfinity(startDistance))
|
|
||||||
{
|
|
||||||
startDistance = hit.distance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (!Physics.Raycast(transform.position, Vector3.down, out _raycastHit, 10f, _groundLayer))
|
||||||
|
{
|
||||||
|
Debug.LogError("땅을 감지하지 못하는 버그");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_isGrounded = _raycastHit.distance <= _checkDistance;
|
||||||
|
|
||||||
|
if (!_isGrounded)
|
||||||
|
{
|
||||||
if (_isUsingIndicator && _indicator)
|
if (_isUsingIndicator && _indicator)
|
||||||
{
|
{
|
||||||
var fillValue = Mathf.Lerp(1f, 0f, hit.distance / startDistance);
|
var fillValue = Mathf.Lerp(1f, 0f, _raycastHit.distance / _startDistance);
|
||||||
_indicator.material.SetFloat(_fillHash, fillValue);
|
_indicator.material.SetFloat(_fillHash, fillValue);
|
||||||
}
|
}
|
||||||
_isGrounded = hit.distance <= _checkDistance;
|
|
||||||
yield return null;
|
|
||||||
}
|
}
|
||||||
|
else if (_isGrounded && !_isAttacked)
|
||||||
|
{
|
||||||
_indicator.material.SetFloat(_fillHash, 1f);
|
_indicator.material.SetFloat(_fillHash, 1f);
|
||||||
HideIndicator();
|
HideIndicator();
|
||||||
|
|
||||||
@ -105,6 +122,10 @@ namespace BlueWater
|
|||||||
if (iDamageable == null || !iDamageable.CanDamage()) continue;
|
if (iDamageable == null || !iDamageable.CanDamage()) continue;
|
||||||
|
|
||||||
iDamageable.TakeDamage(_attackDamage);
|
iDamageable.TakeDamage(_attackDamage);
|
||||||
|
Die();
|
||||||
|
}
|
||||||
|
|
||||||
|
_isAttacked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user