JumpPad.gd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. tool
  2. extends Spatial
  3. class_name JumpPad
  4. var swarmnode
  5. export var color = Color8(40,180,200)
  6. export var number = 3
  7. export var left = true
  8. export var sc = 0.07
  9. export var dist = 1
  10. var will_do_it=false # conflict resolution when player touches 2 simultaneously.
  11. var anitime = 1
  12. var pl
  13. onready var vec = Vector3(1,0,0).rotated(Vector3(0,1,0),get_parent().rotation.y)
  14. func _ready():
  15. swarmnode = Spatial.new()
  16. swarmnode.rotation_degrees = Vector3(-90, -90, 0)
  17. if !left:
  18. swarmnode.rotate_y(PI)
  19. add_child(swarmnode)
  20. for i in range(3):
  21. var a = Arrow.new(color)
  22. a.freq = 1
  23. a.translation = Vector3(i*dist - float(number)/2.0, 0, 0)
  24. a.rotation_degrees = Vector3(0, 0, -90)
  25. a.scale = Vector3(sc,sc,sc)
  26. swarmnode.add_child(a)
  27. func deccel():
  28. print("deccel")
  29. accelerate(pl, "nop", pl.flyspeed, Vector3(0,0,0))
  30. func accelerate(body, nextfunc, startval, endval):
  31. print("acc")
  32. var tw1 = SDTween.new(self,nextfunc)
  33. tw1.interpolate_property(body,"flyspeed", startval,endval,anitime,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT)
  34. add_child(tw1)
  35. tw1.start()
  36. func nop():
  37. print("noping")
  38. pl.flycrazy=false
  39. pl.find_node("NagPlace").nag()
  40. find_parent("MAIN").tried_to_escape = true
  41. func take_responsibility():
  42. will_do_it = true
  43. var t = SDTimer.new(self,"drop_responsibility")
  44. t.wait_time = 1
  45. add_child(t)
  46. t.start()
  47. func drop_responsibility():
  48. will_do_it = false