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

13 lines
334 B
GDScript3
Raw Normal View History

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