Hello Everyone,
I was just trying to program a moving platform for my game. This is my code:
extends KinematicBody2D
var speed = 1
var up = true
func _process(delta):
var velocity = Vector2()
if up == true:
velocity.x = speed
$Timer.start()
if up == false:
velocity.x = -speed
$Timer.start()
velocity = move_and_slide(velocity, Vector2.UP)
func _on_Timer_timeout():
$Timer.start()
if up == true:
up = false
if up == false:
up = true
But instead of moving up and down the platform just teleports itself the whole time between two points.
Does soembody know how to fix this?