Big fix patch for enemy behaviors
This commit is contained in:
@@ -23,20 +23,25 @@ public partial class PatrolBehavior : Node3D, IBehavior
|
||||
private NavigationAgent3D _navigationAgent;
|
||||
|
||||
private int _recursiveCounter = 0;
|
||||
private Vector3 _homePosition;
|
||||
|
||||
public Vector3 HomePosition { get; set; }
|
||||
public Vector3 HomePosition
|
||||
{
|
||||
get => _homePosition;
|
||||
set
|
||||
{
|
||||
_homePosition = value;
|
||||
_navigationAgent.TargetPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Signal] public delegate void OnVelocityComputedEventHandler(Vector3 safeVelocity);
|
||||
|
||||
public PatrolBehavior()
|
||||
public void OnReady()
|
||||
{
|
||||
_patrolTimer = new Timer() { WaitTime = _patrolTime };
|
||||
_patrolTimer.Timeout += PatrolTimer_Timeout;
|
||||
AddChild(_patrolTimer);
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
SetPhysicsProcess(false);
|
||||
}
|
||||
|
||||
@@ -44,10 +49,12 @@ public partial class PatrolBehavior : Node3D, IBehavior
|
||||
{
|
||||
_navigationAgent = navigationAgent;
|
||||
_navigationAgent.WaypointReached += NavigationAgent_WaypointReached;
|
||||
_navigationAgent.TargetPosition = HomePosition;
|
||||
}
|
||||
|
||||
private async void NavigationAgent_WaypointReached(Dictionary details) => await ToSignal(GetTree().CreateTimer(_thinkTime), "timeout");
|
||||
private async void NavigationAgent_WaypointReached(Dictionary details)
|
||||
{
|
||||
await ToSignal(GetTree().CreateTimer(_thinkTime), "timeout");
|
||||
}
|
||||
|
||||
public void StartPatrol()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user