virtualx-engine/demos/2d/platformer/moving_platform.gd

21 lines
340 B
GDScript3
Raw Normal View History

2014-02-10 02:10:30 +01:00
extends Node2D
# Member variables
2014-02-10 02:10:30 +01:00
export var motion = Vector2()
export var cycle = 1.0
var accum = 0.0
2014-02-10 02:10:30 +01:00
func _fixed_process(delta):
accum += delta*(1.0/cycle)*PI*2.0
accum = fmod(accum, PI*2.0)
2014-02-10 02:10:30 +01:00
var d = sin(accum)
var xf = Matrix32()
xf[2]= motion*d
2014-02-10 02:10:30 +01:00
get_node("platform").set_transform(xf)
2014-02-10 02:10:30 +01:00
func _ready():
set_fixed_process(true)