diff --git a/Assets/DanmakU/Runtime/Core/Danmaku.cs b/Assets/DanmakU/Runtime/Core/Danmaku.cs
index add2662b..d215f170 100644
--- a/Assets/DanmakU/Runtime/Core/Danmaku.cs
+++ b/Assets/DanmakU/Runtime/Core/Danmaku.cs
@@ -65,6 +65,11 @@ public float Rotation {
[MethodImpl(MethodImplOptions.AggressiveInlining)] set { Pool.Rotations[Id] = value; }
}
+ ///
+ /// Gets the direction the Danmaku is facing. Guarenteed to be a unit vector.
+ ///
+ public Vector2 Direction => GetDirection(Pool.Rotations[Id]);
+
///
/// Gets or sets the speed of the Danmaku.
///
@@ -154,6 +159,15 @@ public void ApplyState(DanmakuState state) {
Color = state.Color;
}
+ ///
+ /// Convert a Danmaku rotation into a unit vector.
+ ///
+ /// the rotation of the Danmaku.
+ /// the unit vector representing the way the bullet is facing.
+ public static Vector2 GetDirection(float rotation) {
+ return new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation));
+ }
+
public static bool operator ==(Danmaku lhs, Danmaku rhs) {
return lhs.Id == rhs.Id && lhs.Pool == rhs.Pool;
}