1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-11-21 23:54:23 +00:00
looping-for-loops/Scripts/ConveyorBelt.gd

12 lines
334 B
GDScript

extends StaticBody2D
class_name ConveyorBelt
# Speed (and direction) of the conveyor belt
export(float) var conveyor_speed = 0
func get_conveyor_speed(other_pos: Vector2):
var relative_position = other_pos - position
var speed_sign = sign(relative_position.dot(Vector2.UP.rotated(rotation)))
return speed_sign * conveyor_speed