OutboundPad.gd 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. extends JumpPad
  2. onready var pair = $"../JumpPadIn"
  3. func escape():
  4. if find_parent("MAIN").dna_scanned:
  5. get_tree().change_scene("res://END7.tscn")
  6. else:
  7. get_tree().change_scene("res://END1.tscn")
  8. func _on_Area_body_entered(body):
  9. #print(body.name+" entered JUMPZONE")
  10. if body.name=="Player":
  11. if !pair.will_do_it:
  12. take_responsibility()
  13. body.flycrazy = true
  14. pl = body
  15. var action = "uturn" if not find_parent("MAIN").warp_enabled else "escape"
  16. accelerate(pl,action,Vector3(0,0,0), vec*body.maxflyspeed)
  17. if body.name == "human":
  18. var host = body.get_parent().get_parent()
  19. if host.has_method("warp"):
  20. host.warp(vec)
  21. func uturn():
  22. print("uturning")
  23. var topair = pair.global_transform.origin - global_transform.origin
  24. #print("topair",topair)
  25. var playerpos = pl.global_transform.origin - global_transform.origin
  26. #print("playerpos",playerpos)
  27. var playerpos_correction = topair.dot(playerpos)/topair.length_squared() #it is a ratio value
  28. #print("correction",playerpos_correction)
  29. var topair2= pair.translation - translation
  30. pl.translation += topair2.rotated(Vector3(0,1,0),get_parent().rotation.y)*(1-playerpos_correction)
  31. accelerate(pl, "deccel", pl.flyspeed, -pl.flyspeed)