mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 16:15:54 +00:00
Gaussian Spread
This commit is contained in:
parent
f3a701d3f9
commit
2c72f36108
11 changed files with 84 additions and 11 deletions
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
|
||||
public partial class Weapon : Node2D
|
||||
{
|
||||
|
|
@ -123,6 +124,18 @@ public partial class Weapon : Node2D
|
|||
// Calculate angle offset for this bullet
|
||||
float spreadOffset = -halfSpread + (spreadStep * i);
|
||||
|
||||
// Add random spread
|
||||
if (WeaponData.RandomSpread > 0)
|
||||
{
|
||||
// Gaussian with mean = 0, stddev = WeaponData.RandomSpread
|
||||
spreadOffset += RandomStuff.GaussianClamped(
|
||||
mean: 0f,
|
||||
stdDev: WeaponData.RandomSpread, // tuning knob
|
||||
min: -halfSpread,
|
||||
max: halfSpread
|
||||
);
|
||||
}
|
||||
|
||||
// Rotate the ShootDirection by the spread angle
|
||||
Vector2 spreadDirection = ShootDirection.Rotated(Mathf.DegToRad(spreadOffset));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue