Enemy Gravity

This commit is contained in:
Marco 2025-06-29 18:09:13 +02:00
commit d1517f864a
9 changed files with 65 additions and 9 deletions

View file

@ -11,6 +11,7 @@ public partial class Alert : EnemyStateBase3D
[Export] public EnemyStorage3D Storage { get; private set; }
[Export] public PlayerDetection3D PlayerDetection { get; private set; }
[Export] public NavigationProvider3D NavigationModule { get; private set; }
[Export] public GravityProvider GravityProvider { get; private set; }
[Export] public bool DebugEnabled { get; set; } = false;
private bool _isPlayerInRange = false;
@ -79,6 +80,12 @@ public partial class Alert : EnemyStateBase3D
NavigationModule.Move(Storage.EnemyData.MovementSpeed);
// Calculate gravity
MainObject.Velocity = new Vector3(MainObject.Velocity.X, GravityProvider.CalculateGravityVelocity(MainObject.Velocity.Y, delta), MainObject.Velocity.Z);
MainObject.MoveAndSlide();
//Storage.FacingDirection = MainObject.Velocity.SnapToCardinal().Normalized();
Storage.FacingDirection = MainObject.Velocity.ToVector2().Normalized();
Storage.AimingDirection = Storage.FacingDirection;