Bullet spawners in editor and bullets come out at the spanwer position

This commit is contained in:
Marco 2025-07-09 15:05:50 +02:00
commit b64e096661
16 changed files with 288 additions and 169 deletions

View file

@ -188,7 +188,7 @@ public partial class ShootingPattern3D : AttackPattern
// Rotate with parent rotation
if (pattern.UseParentRotationOffset)
{
direction = direction.Rotated(-ScriptHost.ParentObject.GlobalRotation.Y + Mathf.DegToRad(90));
direction = direction.Rotated(-spawner.GlobalRotation.Y + Mathf.DegToRad(90));
}
// TODO: Fix player aiming for 3D
@ -196,21 +196,21 @@ public partial class ShootingPattern3D : AttackPattern
{
if (pattern._predictPlayer && GameController.Instance.PlayerVelocity.HasValue)
{
var predictedDirection = MathFunctions.PredictInterceptPosition(ScriptHost.ParentObject.GlobalPosition.ToVector2(),
var predictedDirection = MathFunctions.PredictInterceptPosition(spawner.GlobalPosition.ToVector2(),
GameController.Instance.PlayerPosition.Value.ToVector2(), GameController.Instance.PlayerVelocity.Value.ToVector2(),
pattern.BulletResource.BulletSpeed);
if (predictedDirection.HasValue)
{
direction = (predictedDirection.Value - ScriptHost.ParentObject.GlobalPosition.ToVector2()).Normalized();
direction = (predictedDirection.Value - spawner.GlobalPosition.ToVector2()).Normalized();
}
}
else
{
direction = (GameController.Instance.PlayerPosition.Value.ToVector2() - ScriptHost.ParentObject.GlobalPosition.ToVector2()).Normalized();
direction = (GameController.Instance.PlayerPosition.Value.ToVector2() - spawner.GlobalPosition.ToVector2()).Normalized();
}
}
var spawnPosition = ScriptHost.ParentObject.GlobalPosition + pattern.EmitterOffset;
var spawnPosition = spawner.GlobalPosition + pattern.EmitterOffset;
var bullet = pattern.MakeBullet(spawnPosition.ToVector2(), pattern.bulletCount,
pattern.spread, angleOffset);