Files
sanspie 5eb1832907
ci-platforms / darwin amd64 smoke (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 15m28s
ci / release (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 7m47s
Complete Stage 12 for v0.12.0
2026-11-05 11:46:53 +03:00

30 lines
539 B
Plaintext

package platform
script MovingPlatform {
@export(gizmo="vector", tip="Offset of the far end from the start position")
var Travel Vec2 = Vec2{4, 0}
@export(min=0.1, tip="Seconds for one leg")
var Duration float = 2
var start Vec2
var t float
var dir float = 1
func Ready() {
start = node.Position()
}
func FixedUpdate(dt float) {
t += dir * dt / Duration
if t >= 1 {
t = 1
dir = -1
} else if t <= 0 {
t = 0
dir = 1
}
node.Get<Body2D>().MoveTo(Vec2{start.X + Travel.X*t, start.Y + Travel.Y*t}, 0)
}
}