Refactor NPC behavior and teleportation logic; enhance tile material properties
This commit is contained in:
@@ -17,6 +17,12 @@ namespace Infrastructure.Unity
|
||||
|
||||
private Vector3 _currentDir;
|
||||
private float _timer;
|
||||
private Func<float> _timeDilationProvider;
|
||||
|
||||
public void Initialize(Func<float> timeDilationProvider)
|
||||
{
|
||||
_timeDilationProvider = timeDilationProvider;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -35,9 +41,11 @@ namespace Infrastructure.Unity
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (IsGrounded()) rb.MovePosition(rb.position + _currentDir * (moveSpeed * Time.fixedDeltaTime));
|
||||
var dilation = _timeDilationProvider?.Invoke() ?? 1f;
|
||||
|
||||
if (Physics.Raycast(transform.position, Vector3.down, out var hit, 1.5f, tileLayer))
|
||||
if (IsGrounded()) rb.MovePosition(rb.position + _currentDir * (moveSpeed * dilation * Time.fixedDeltaTime));
|
||||
|
||||
if (Physics.Raycast(transform.position, Vector3.down, out var hit, 2.0f, tileLayer))
|
||||
{
|
||||
if (hit.collider.TryGetComponent<TileViewAdapter>(out var tile))
|
||||
{
|
||||
@@ -48,7 +56,7 @@ namespace Infrastructure.Unity
|
||||
|
||||
private bool IsGrounded()
|
||||
{
|
||||
return Physics.Raycast(transform.position, Vector3.down, out var hit, 1.15f, tileLayer);
|
||||
return Physics.Raycast(transform.position, Vector3.down, out var hit, 2.0f, tileLayer);
|
||||
}
|
||||
|
||||
private void PickNewDirection()
|
||||
|
||||
Reference in New Issue
Block a user