mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
Navigation for Actors
This commit is contained in:
parent
9d302e48e6
commit
b78692f150
4 changed files with 11 additions and 8 deletions
|
|
@ -53,7 +53,7 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
FacingDirection = Vector2.Down;
|
||||
|
||||
_actorAi = parent.GetNode<ActorAi>("ActorAi");
|
||||
_navigationAgent = GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
|
||||
_navigationAgent = _parent.GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
|
||||
_alarmManager = this.GetAlarmManager();
|
||||
|
||||
if (_alarmManager != null)
|
||||
|
|
@ -85,6 +85,7 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
if (_playerDetection != null && _playerDetection.IsPlayerInSight(_parent.CollisionMask))
|
||||
{
|
||||
_actorAi.State = EnemyState.Alert;
|
||||
GD.Print("Switching to alert");
|
||||
}
|
||||
break;
|
||||
case EnemyState.Alert:
|
||||
|
|
@ -102,7 +103,7 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
_navigationAgent.SetTargetPosition(_lastPlayerPosition.Value);
|
||||
}
|
||||
|
||||
var currentAgentPosition = GlobalPosition;
|
||||
var currentAgentPosition = _parent.GlobalPosition;
|
||||
|
||||
var nextPathPosition = _navigationAgent.GetNextPathPosition();
|
||||
|
||||
|
|
@ -116,6 +117,7 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
if (IsPlayerInSight)
|
||||
{
|
||||
//Shoot();
|
||||
|
||||
}
|
||||
|
||||
// TODO: If player totally left the max range it should stop shooting and go back to idle
|
||||
|
|
@ -140,7 +142,9 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
if (IsPlayerInSight)
|
||||
{
|
||||
//Shoot();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -151,6 +155,9 @@ public partial class EnemyNavigationMovement : MovementHandler
|
|||
public void _on_navigation_agent_2d_velocity_computed(Vector2 safeVelocity)
|
||||
{
|
||||
_parent.Velocity = safeVelocity;
|
||||
if (_parent.Velocity.Length() > 0) {
|
||||
_parent.FacingDirection = _parent.Velocity.Normalized();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,10 +307,6 @@ public partial class Enemy : CharacterBody2D
|
|||
GD.Print("Assuming direct control");
|
||||
Ai = AiState.Controlled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum EnemyState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue