I want to align the graphic direction of bullets flying in 360 degrees.

Currently, in a top-down game like Vampire Survivors, I want to implement the following attack behavior for the player character:

  • As an “Auto Attack,” the player should automatically fire projectiles at regular intervals without any input.
  • Projectiles fired by the Auto Attack should:
    ┗ If enemies exist within a specified range, fly toward the nearest enemy.
    ┗ If no enemies exist within the specified range, fly in a random 360-degree direction.

Currently, I have set a graphic similar to a “shockwave” for the projectile, and I want to align the orientation of this graphic with the direction of flight.

My proposed implementation approach is as follows:

Player Character
┗ Auto Attack Point (an object placed at the player character’s Connector)

↑ This “Auto Attack Point” (transparent state) will be responsible for firing projectiles.

  • The “Auto Attack Point” object fires projectiles at regular intervals.
  • The “Auto Attack Point” assigns a random number between 0 and 359 to Variable A, and the fired projectile’s variable “visible_direction” (display direction in degrees) retrieves this value.

I thought this implementation might work, but I’m having trouble getting it to function correctly.

I’m not even sure if it’s possible to orient the graphic assigned to the projectile in directions other than the standard 8 directions based on “visible_direction.”

If anyone has knowledge on this matter, I would greatly appreciate your advice.
Thank you in advance.
Video

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

1 Like

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

Yes, that’s correct.
Since enemies approach the player from all directions, the graphics of the bullets fired by the player should also change orientation in all directions.

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 Like

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 Like

I implemented the steps as instructed and was able to achieve the desired behavior!
Thank you for your reply! :slightly_smiling_face:

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

Thank you for your reply!
Video_2

2 Likes

I’m sorry, but I’ve been using this script without permission. However, it seems that it doesn’t work with the newly added Area2DGameObject node. How can I make it work?

Hello, I’ll find a way to make it compatible, but it may take a while. I need to figure out how.

Thank you for your reply.
I appreciate your assistance.

[Dive Into AGMaker] Plugin Release - Rotate Specific Node2D to Point in the Direction of Movement
this may help

2 Likes

Thank you!

I tried it out right away, but I had a few questions, so I wanted to share them with you.

  1. When firing as a projectile, the initial direction is not reflected. Should I consider this the intended behavior? Since making it visible midway causes the image orientation to look incorrect, I’m planning to handle it by switching from a transparent image.

  2. The bullet behavior confirmed in this file isn’t being reflected. How can I fix this?

You can fire with Z and reload with X.
“Start” is the initial state where I set up the actions.
It might be a bit tricky since it’s a somewhat special type of bullet.

I’d like to confirm whether the behavior you want is this: when the shuttlecock is thrown, its orientation follows its trajectory like a real shuttlecock?

Yes, that’s correct.
I want the shuttle’s head to change orientation as it follows its flight path and falls due to gravity.