CharTween.gd 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. extends Tween
  2. # Drive moves for liners
  3. const MINIMAL_DURATION = 0.01
  4. export var default_duration = 0.1
  5. export var drift_duration = 0.2
  6. export var boost_bonus = 0.02
  7. var current_duration = default_duration
  8. var current_bonus = 0.0
  9. func move_char(character, target):
  10. move_char_during(character, target, get_computed_duration())
  11. func move_char_during(c, target, duration):
  12. interpolate_property(c, "position", c.get_position(), target, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT_IN)
  13. func rotate_char(character, from, to):
  14. rotate_char_during(character, from, to, get_computed_duration())
  15. func rotate_char_during(c, from, to, duration):
  16. interpolate_property(c, "rotation_degrees", from, to, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT)
  17. func set_boost(value:int):
  18. current_bonus = boost_bonus * value
  19. func get_computed_duration():
  20. var duration = current_duration - current_bonus
  21. if duration < MINIMAL_DURATION :
  22. return MINIMAL_DURATION
  23. return duration
  24. func _on_Player_drift_started():
  25. current_duration = drift_duration
  26. func _on_Player_drift_ended():
  27. current_duration = default_duration