Created
March 5, 2025 18:28
-
-
Save lamarmarshall/d1a3f330909d4762fd97cf77277da957 to your computer and use it in GitHub Desktop.
godot, bob, rotate, up and down, back and fourth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Area2D | |
var rotate_speed : float = 3.0 | |
var bob_height: float = 5.0 | |
var bob_speed: float = 5.0 | |
@onready var start_position: Vector2 = global_position | |
@onready var sprite = $Sprite2D | |
func _physics_process(delta: float) -> void: | |
var time = Time.get_unix_time_from_system() | |
#rotate | |
sprite.scale.x = sin(time * rotate_speed) | |
#bob up and down | |
var y_pos = ((1+sin(time * bob_speed)) / 2) * bob_height | |
global_position.y = start_position.y - y_pos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment