How can I spin a roulette wheel in a clockwise direction using a tween?
I've successfully managed to rotate counter-clockwise to the exact segment, but changing the direction to go clockwise is still a problem.
extends Control const DEGREES := 360.0 @onready var wheel := $Front as TextureRect enum Directions {CCLOCKWISE=-1, CLOCKWISE=1} @export var direction := Directions.CLOCKWISE @export var segment_count := 8 @export var spin_time := 2.0 @export var spin_count := 1 var spinning := false func spin(to_segment: int) -> void: if spinning: return spinning = true print(to_segment) randomize() var d := DEGREES / segment_count var r := d / 2 var t := (to_segment-1) * d - r t += fposmod(wheel.rotation_degrees, DEGREES) #t += randf_range(0, d) # add slight offset var target := wheel.rotation_degrees - (spin_count * DEGREES) - t var tween := create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT) await tween.tween_property(wheel, "rotation_degrees", target, spin_time).finished spinning = false func _input(event: InputEvent) -> void: if event is InputEventMouseButton: if event.pressed: spin(randi() % segment_count + 1) # pick random segment 