Help me find the function for wave and circular movement

Godot Version

Godot 4.2


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 ( 

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.

In your first ‘circular’ movement, are you expecting a spiral outwards with the bullet aligned to the spiral path?

For your ‘wave’ movement, assuming y is your forward direction you just need to affect the x position with sin(delta * frequency) * amplitude

1 Like

I think you got it,

if you don’t like the math you could offset the bullet sprite and collision shape transforms and just rotate the bullet parent. Then you just give a forward vector to the parent.

Same for the wave bullet you would just move it in the y offset of the bullet and collision shape by using @ijidau equation locally while applying a forward vector to parent.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.