Godot Version
4.3 stable Windows 11
Question
I have this node that is supposed to spawn hammer objects in a circle with amount defined by a “howmany” variable:
var howmany = amount_r
var dir = get_angle_to(get_global_mouse_position())
for i in howmany :
var hammer = hammer_scene.instantiate()
hammer.angle = dir+(TAU*i)/howmany
print("hamer angle should be:", dir+(TAU*i)/howmany)
add_child(hammer)
For the hammer object itself, I have an animation player to make it swing in an arc, and code to set its angle:
func _ready():
print("hammer angle is:", angle)
$AnimationPlayer.get_animation("new_animation").track_set_key_value(0,0,deg_to_rad(0) + angle)
print($AnimationPlayer.get_animation("new_animation").track_get_key_value(0,0))
$AnimationPlayer.get_animation("new_animation").track_set_key_value(0,1,deg_to_rad(120) + angle)
$AnimationPlayer.get_animation("new_animation").track_set_key_value(0,2,deg_to_rad(110) + angle)
As far as I can tell, this code should create a full circle of evenly spread hammers. In all my print functions, everything is as it should be, the angles are always correct and different for every hammer object. However, in game, they are all spawning with the exact same rotation perfectly on top of each other - or maybe it’s only spawning one, it’s hard to tell.
I’ve been looking at this for a while now and I really don’t see the problem, especially with the print functions returning everything right. What could be the issue? Any help is appreciated.