Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created March 5, 2025 18:28
Show Gist options
  • Save lamarmarshall/d1a3f330909d4762fd97cf77277da957 to your computer and use it in GitHub Desktop.
Save lamarmarshall/d1a3f330909d4762fd97cf77277da957 to your computer and use it in GitHub Desktop.
godot, bob, rotate, up and down, back and fourth
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