Godot Version
4.5.1 stable
Question
(Keep in mind that I’m not great at coding, suggest anything you can think of, no matter how obvious it seems)
Changing this node’s rotation changes it to a number far above where it’s supposed to be. The change is consistent, but I can’t figure out the pattern. The rotation is being done by the autoload script below (I only included the important:
var cartridges := ["red", "orange", "yellow", "green", "blue", "purple"]
...
enum cartridgeRotation {
red = 0,
orange = -60,
yellow = -120,
green = -180,
blue = -240,
purple = -300
}
func _physics_process(_delta: float) -> void:
if Input.is_action_just_pressed("Color Left"):
player_color_update(true)
Player.shoot()
if Input.is_action_just_pressed("Color Right"):
player_color_update(false)
func player_color_update(isLeft) -> void:
if isLeft:
cartridges.append(cartridges[0])
cartridges.remove_at(0)
#OLD: Cartridge.rotation -= 60
Cartridge.rotation = float(cartridgeRotation[cartridges[0]])
else:
cartridges.insert(0, cartridges.back())
cartridges.remove_at(6)
#OLD: Cartridge.rotation += 60
Cartridge.rotation = float(cartridgeRotation[cartridges[0]])
print(Cartridge)
print(Cartridge.rotation)
print(Cartridge.global_rotation)
print(cartridgeRotation[cartridges[0]])
Values in the enum and their resulting rotation and global rotation:
expected rotation | resulting rotation (according to value) | resulting rotation (according to remote scene) | resulting global rotation
0 | 0 | 0 | 0
-60 | -60.0 | -3437.7 | 2.83185315132141
-120 | -120.0 | -6875.5 | -0.61947917938232
-180 | -180.0 | -103113.2 | 2.21237397193909
-240 | -240.0 | -13751.0 | -1.23895835876465
-300 | -300.0 | -17188.7 | 1.59289479255676