planet.gd 912 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. extends Spatial
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. export var apoapsis = 17000
  6. export var periapsis = 12000
  7. export var aoa = 42
  8. export var xtilt = 0
  9. export var ytilt = 0
  10. export var daylen = 6
  11. var orbital_period
  12. var planet
  13. var count
  14. # Called when the node enters the scene tree for the first time.
  15. func _ready():
  16. planet = get_child(0)
  17. self.rotate_y(aoa)
  18. self.rotate_x(xtilt)
  19. self.rotate_z(ytilt)
  20. planet.translation = Vector3(0,0,apoapsis)
  21. var a = (apoapsis + periapsis ) * 1000000.0 / 2
  22. orbital_period = 2*PI*sqrt(a*a*a/(132700000000000000000.0))
  23. print(orbital_period)
  24. count = 0
  25. pass # Replace with function body.
  26. # Called every frame. 'delta' is the elapsed time since the previous frame.
  27. #func _process(delta):
  28. # pass
  29. # warning-ignore:unused_argument
  30. func _physics_process(delta):
  31. count += 1
  32. if(count % 60 == 0):
  33. self.rotate_y(2*PI/(orbital_period))
  34. pass