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.
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:
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.
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?
I tried it out right away, but I had a few questions, so I wanted to share them with you.
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.
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?