360度に飛ぶ弾のグラフィック向きを合わせたい

現在、Vampire Survivorsのようなトップビューで、
プレイヤーキャラクターに、以下のような攻撃をさせたいと考えています。

・「オートアタック」として、プレイヤーは何もしなくても、自動で弾が一定間隔で射出される
・オートアタックによる弾は
┗指定範囲内に敵が存在 する 場合、一番近くの敵の方向に向かって飛ぶ
┗指定範囲内に敵が存在 しない 場合、360度ランダムな方向に飛ぶ

という挙動で考えています。

現状、「衝撃波」のようなグラフィックを弾に設定していますが、
そのグラフィックの向きを、飛ぶ方向に合わせたいと思っています。

考えている実装方法としましては、

プレイヤーキャラクター
┗オートアタック地点(プレイヤーキャラのConnectorに配置したオブジェクト)

↑この「オートアタック地点(透明状態)」が弾を射出するものとし、

・「オートアタック地点」オブジェクトが一定間隔で弾を射出する
・「オートアタック地点」が、変数Aに乱数0~359を代入し、
射出された弾の変数「visible_direction(表示方向(度))」がそれをさらに取りに行く

という感じで実装できるかな?と思ったのですがどうもうまくいきません。

「弾に設定したグラフィックを、visible_directionによって8方向以外の向きにできるのかどうか」
すらもそもそもわかっていない状況です。

本件についてどなたかおわかりの方、ご助言をいただければ幸いです。
よろしくお願いいたします。
Video

Are you looking for a solution that allows for 360° free rotation, rather than just 8 directions?

「いいね!」 1

>Are you looking for a solution that allows for 360° free rotation, rather than just 8 directions?

はい。その通りです。
敵はあらゆる方向からプレイヤーに向かってくるようにしたいので、
プレイヤーが発する弾は同様にあらゆる向きにグラフィックが変化するようにしたいです。

Yes, that’s right.
Enemies come at the player from all directions, so Bullet’s graphics need to be oriented in 360 degrees as well.

From my personal perspective, currently when only use Visual Script doesn’t seem to offer any particularly good methods. However, I have a suggestion:

  1. Fix the bullet’s orientation to the right side.
  2. Add a child node to the bullet using Godot’s node, then write a GDScript script to rotate the GameObject every frame, aligning it with the current velocity direction of the GameObject.

I got it.
wait some moment, I will post a complete solution here later.

「いいね!」 1

I made a plugin for it.

  1. prepare your bullet game object
  2. this bullet game object could has no VisualScript, or has VS but all animation direction is pointing to RIGHT
  3. read following post and use the plugin, done.
    [Dive Into AGMaker] Plugin Release - Rotate GameObject to Point in the Direction of Movement Speed
「いいね!」 1

手順通りに実装したところ、希望の挙動を実現できました!
ご返信いただきありがとうございました! :slightly_smiling_face:

I followed the steps and was able to achieve the behavior I wanted!

Thank you for your reply!
Video_2

「いいね!」 1