moving_platform.gd 299 B

12345678910111213141516
  1. extends Node2D
  2. # Member variables
  3. export var motion = Vector2()
  4. export var cycle = 1.0
  5. var accum = 0.0
  6. func _physics_process(delta):
  7. accum += delta * (1.0 / cycle) * PI * 2.0
  8. accum = fmod(accum, PI * 2.0)
  9. var d = sin(accum)
  10. var xf = Transform2D()
  11. xf[2]= motion * d
  12. $platform.transform = xf