Godot Version
Godot 4.2
Question
While this is a Godot question, it’s more of a math question.
I’m trying to implement the following bullet behaviours of some of my favourite bullet hell games:
Circular bullets and Wavey bullets.
For the first type of bullet, it should rotate around a pivot point (center) with a linear speed (circularspeed) while moving away from the center (speed). We should also take in consideration from which position around the circle (direction) this object starts at: ex it may start at π /4 rad (direction = Vector2(1,1).normalized()
).
I don’t really have a good answer for this… I’m not the best in trigonometry, and the best solution I could find was to calculate new X and Y positions through:
#r is the radius, or distance of the bullet from the center.
r += speed * delta
position = new Vector (
center.x+r⋅cos(direction.angle+(circularspeed/r)⋅delta),
center.y+r⋅sin(direction.angle+(circularspeed/r)⋅delta)
)
direction = new Vector(position.x-center.x, position.y-center.y).normalized()
But I’m not totally sure I’m applying this formula correctly or if there’s an easier way to go about doing it.
As for wave movement, I’m not very sure how to do it… Starting from a bullet that moves in a direction(direction) at a certain speed(speed), it also needs to move in a sinuisoid pattern in said direction (the segment the bullet traces needs to be penpendicular to its direction) at a certain frquency and speed.
I’ve got no idea how to implement this.