Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Gerboroso |
Hi there fellow redditers and godot people.
I find myself in times of trouble. I was trying to program a general purpose spiral shooting function for my bullet hell game. The problem is that if I encrease the angular velocity, it takes longer for the function to end and it keeps shooting for a while longer thaat it is told in time. But the weird thing is that if a tell it to add all of the intervals into a variable and then give it to me it allways prints the correct time value (5 since I called the function with shoot_spiral_V03(5,PI/16,4*PI)
) but it clearly isn’t the time it is shooting as when I counted it reached times as long as 14 seconds. Here I leave the function. Help would be trully apreciated.
func shoot_spiral_V03(time, angle_step, angular_velocity):
var shot_interval = angle_step/float(angular_velocity)
var bullets = time/shot_interval
var time_t = 0
var angle = 0
print(OS.get_time())
for counter in range(0,bullets,1):
angle = counter * angle_step
emit_signal("shoot_signal", position, Vector2(1,1).rotated(angle), false)
yield(get_tree().create_timer(shot_interval, false), "timeout")
time_t += shot_interval
print(time_t)
print(OS.get_time())
Ty. Have a good day.