Godot Version
4.2.2 stable Windows 11
Question
I have this code that is meant to create a circle of yellow bullets:
func CreateShotA1(bullet_type : String, colour : int, pos : Vector2, speed : float, accel : float, target_speed : float, angle : float, angular_velocity : float, lifespan : float, dmg : float):
var objShot = ###blah blah blah
###insert all other arguments here
objShot.angle = angle
call_deferred("add_sibling", objShot)
for i in 6 :
CreateShotA1("ball_M", 2, global_position, 60, 0, 60, (2*PI)/(i+1), 0, 3, 5)
What’s important here is the (2*PI)/(i+1)
argument, which tells the bullet what direction to move.
From what my research tells me, Godot uses radians for angles, where one full circle is 2*PI. This code should start the angle at 0, and increment it by one sixth of a full circle for every loop. However, what comes out looks like this:
That’s half a circle, and they’re not even equal angles apart. I’ve tried messing with the math, changing it to PI/(i+1) and -PI+(2*PI)/(i+1), but the results were all similar.
This has also happened in other instances where I tried similar circle code, which leads me to believe the problem is with the math itself. Maybe I just don’t understand radians, but all I could find on the topic tells me this should be right.
What am I doing wrong? Any help is appreciated.