myd
2025 年 6 月 14 日午前 8:02
1
現在、Vampire Survivorsのようなトップビューで、
プレイヤーキャラクターに、以下のような攻撃をさせたいと考えています。
・「オートアタック」として、プレイヤーは何もしなくても、自動で弾が一定間隔で射出される
・オートアタックによる弾は
┗指定範囲内に敵が存在 する 場合、一番近くの敵の方向に向かって飛ぶ
┗指定範囲内に敵が存在 しない 場合、360度ランダムな方向に飛ぶ
という挙動で考えています。
現状、「衝撃波」のようなグラフィックを弾に設定していますが、
そのグラフィックの向きを、飛ぶ方向に合わせたいと思っています。
考えている実装方法としましては、
プレイヤーキャラクター
┗オートアタック地点(プレイヤーキャラのConnectorに配置したオブジェクト)
↑この「オートアタック地点(透明状態)」が弾を射出するものとし、
・「オートアタック地点」オブジェクトが一定間隔で弾を射出する
・「オートアタック地点」が、変数Aに乱数0~359を代入し、
射出された弾の変数「visible_direction(表示方向(度))」がそれをさらに取りに行く
という感じで実装できるかな?と思ったのですがどうもうまくいきません。
「弾に設定したグラフィックを、visible_directionによって8方向以外の向きにできるのかどうか」
すらもそもそもわかっていない状況です。
本件についてどなたかおわかりの方、ご助言をいただければ幸いです。
よろしくお願いいたします。
Justus
2025 年 6 月 14 日午前 9:01
2
Are you looking for a solution that allows for 360° free rotation, rather than just 8 directions?
「いいね!」 1
myd
2025 年 6 月 14 日午前 9:41
3
>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.
Justus
2025 年 6 月 14 日午前 9:57
4
From my personal perspective, currently when only use Visual Script doesn’t seem to offer any particularly good methods. However, I have a suggestion:
Fix the bullet’s orientation to the right side.
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.
Justus
2025 年 6 月 14 日午前 10:17
5
I got it.
wait some moment, I will post a complete solution here later.
「いいね!」 1
myd
2025 年 6 月 14 日午後 12:28
7
手順通りに実装したところ、希望の挙動を実現できました!
ご返信いただきありがとうございました!
I followed the steps and was able to achieve the behavior I wanted!
Thank you for your reply!
「いいね!」 1