mirror of
https://github.com/Steffo99/looping-for-loops.git
synced 2024-11-24 09:04:21 +00:00
25 lines
655 B
GDScript
25 lines
655 B
GDScript
extends StaticBody2D
|
|
class_name ConveyorBelt
|
|
|
|
|
|
# Speed (and direction) of the conveyor belt
|
|
export(float) var cb_speed: float = 100 setget set_cb_speed, get_cb_speed
|
|
export(bool) var randomize_gear_starting_position: bool = false
|
|
|
|
signal cb_speed_changed(old, new)
|
|
|
|
func _ready():
|
|
set_cb_speed(cb_speed)
|
|
|
|
func set_cb_speed(value):
|
|
var old = cb_speed
|
|
cb_speed = value
|
|
emit_signal("cb_speed_changed", old, value)
|
|
|
|
func get_cb_speed():
|
|
return cb_speed
|
|
|
|
func get_relative_cb_speed(other_pos: Vector2):
|
|
var relative_position = other_pos - position
|
|
var speed_sign = sign(relative_position.dot(Vector2.UP.rotated(rotation)))
|
|
return speed_sign * cb_speed
|