This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
Jessist/addons/godot-action/GDAction/Animating/MoveBy/GDActionNodeMoveBy.gd
2022-06-18 13:05:48 +02:00

34 lines
665 B
GDScript

class_name GDActionNodeMoveBy extends GDActionNodeInterval
var velocity: Vector2 = Vector2.ZERO
func get_class() -> String:
return "GDActionNodeMoveBy"
func _init(action, key, node).(action, key, node):
pass
func _update(value: float, eased_value: float, delta: float):
match node_type:
NodeType.NODE_2D:
node.position += self.velocity * delta
NodeType.CONTROL:
node.rect_position += self.velocity * delta
func move_by(vector, duration: float, delay = 0.0, speed = 1.0):
if duration <= 0:
finished()
return
self.velocity = vector / duration
self.duration = duration
self.delay = delay
self.speed = speed
_reset_value()
_run()