Files
fgj-26/Scripts/Misc/Floating.gd
T

16 lines
347 B
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extends Node2D
@export var float_height := 2.0
@export var float_speed := 1.25
var start_y := 0.0
var time := 0.0
var phase := 0.0
func _ready():
start_y = position.y
phase = randf() * TAU # Random value between 0
func _process(delta):
time += delta * float_speed
position.y = start_y + sin(time + phase) * float_height