Make Doc dash away instead of predetermined angle

master
John Montagu, the 4th Earl of Sandvich 2024-10-11 19:00:19 -07:00
parent feec74fa65
commit c0424444b9
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 4 additions and 1 deletions

View File

@ -47,7 +47,10 @@ public partial class DashDefensive : AttackState
{
GD.Print("changing direction");
var direction = projectile.Direction;
DashTo(direction.Rotated(Mathf.Pi / 2));
var dirToChar = projectile.GlobalPosition
.DirectionTo(NPC.GlobalPosition);
var lateralDirection = Mathf.Sign(direction.Cross(dirToChar));
DashTo(direction.Rotated(lateralDirection * Mathf.Pi / 2));
}
}
}