james7132 / DanmakU

An open source Danmaku development kit for Unity3D.
https://danmaku.jamessliu.com/
MIT License
238 stars 50 forks source link

Probably wrong circle fireable logic. #32

Closed hdmmY closed 6 years ago

hdmmY commented 6 years ago

At DanmakU\DamakU Plugin\Runtime\Fireables\Shapes\Circle.cs

Method : Fire

float radius = Radius.GetValue ();
int count = Mathf.RoundToInt (Count.GetValue ());
var rotation = state.Rotation.GetValue ();
for (int i = 0; i < count; i++)
{
    var angle = rotation + i * (Mathf.PI * 2 / count);
    state.Position = state.Position + (radius * RotationUtiliity.ToUnitVector (angle));
    state.Rotation = rotation;
    Subfire (state);
}

I think the right implemention is

float radius = Radius.GetValue ();
int count = Mathf.RoundToInt (Count.GetValue ());
var rotation = state.Rotation.GetValue ();
var origin = state.Position;
for (int i = 0; i < count; i++)
{
    var angle = rotation + i * (Mathf.PI * 2 / count);
    state.Position = origin + (radius * RotationUtiliity.ToUnitVector (angle));
    state.Rotation = rotation;
    Subfire (state);
}

Since the state.Position will be change during the "for" loop.