Skip to content

Instantly share code, notes, and snippets.

View WolfgangSenff's full-sized avatar

Kyle Szklenski WolfgangSenff

View GitHub Profile
@WolfgangSenff
WolfgangSenff / SimpleMove.gd
Last active December 24, 2019 00:58
Touch-move in 3D for Godot 3.0
extends Spatial
signal tapped(card)
signal released(card)
var is_tapped = false setget set_is_tapped
var should_process_touch = true
func set_is_tapped(value):
is_tapped = value
@WolfgangSenff
WolfgangSenff / GetDirections.gd
Created March 29, 2019 12:35
Get the direction you're moving in, in Godot
func get_direction(pos : Vector2) -> String:
var B := pos # next position
var A := global_position # current position
var direction := B - A
direction = direction.normalized()
var angle = direction.angle()
var cos_angle = rad2deg(cos(angle))
var sin_angle = rad2deg(sin(angle))
@WolfgangSenff
WolfgangSenff / ForZon.gd
Created April 20, 2019 02:47
Move in 3D space in Godot using translation
extends Spatial
var speed = 100
func _physics_process(delta):
if Input.is_action_pressed("ui_space"):
translation += speed * (Vector3.RIGHT.rotated(Vector3(0, 1, 0), rotation.y)) * delta
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
@WolfgangSenff
WolfgangSenff / ForStephanie.gd
Created September 13, 2019 19:55
How to play looping animations in Godot _process or _physics_process
func _physics_process(delta):
if Input.is_key_pressed(KEY_A):
rotate_y(0.1)
if $AnimPlayer.current_animation != "Walk-loop":
$AnimPlayer.play("Walk-loop")
elif ...

Keybase proof

I hereby claim:

  • I am wolfgangsenff on github.
  • I am wolfgangsenff (https://keybase.io/wolfgangsenff) on keybase.
  • I have a public key ASAvwW-SmM6W-1E_SbwlAuHp0-FzFBjg3vBVmxZeKYOo1wo

To claim this, I am signing this object:

extends Resource
class_name FolderListResource
export (String) onready var FolderPath setget set_folder_path
export (String) var ResourceCategory
var all_resources = []
func set_folder_path(value):
FolderPath = value
@WolfgangSenff
WolfgangSenff / PinchAndDragCamera2D.gd
Created January 10, 2021 12:50
A camera script in GDScript that makes for clean pinch-to-zoom and pan-to-drag functionality.
extends Camera2D
export (NodePath) var target
var target_return_enabled = true
var target_return_rate = 0.02
var min_zoom = 0.5
var max_zoom = 2
var zoom_sensitivity = 10
var zoom_speed = 0.05
@WolfgangSenff
WolfgangSenff / Node2D.gd
Created August 17, 2021 14:54
File open broken
extends Node2D
func _ready() -> void:
var file = File.new()
var file_location = "user://cache_temp/icon.png"
if not file.file_exists(file_location):
var result = file.open(file_location, File.WRITE_READ)
var buffer = preload("res://icon.png").get_data().get_data()
file.store_buffer(buffer)
file.close()
@WolfgangSenff
WolfgangSenff / Butterfly.gd
Created November 17, 2021 06:33
For Jacob
extends Area2D
const FlightMagnitude = 20.0
const FlightFrequency = 5.0
const FlightSpeed = 8.0
var _current_flight_angle := 0.0
var _flying_left := 1
func _physics_process(delta : float) -> void:
@WolfgangSenff
WolfgangSenff / gist:168cb0cbd486c8c9cd507f232165b976
Last active July 5, 2024 09:44
Godot 4.0 Migration/Upgrade guide
## For a beginner-friendly version of the following (more advanced users likely will get better use of the below,
## if you're just starting out...), see this new gist:
## https://gist.github.com/WolfgangSenff/0a9c1d800db42a9a9441b2d0288ed0fd
This document represents the beginning of an upgrade or migration document for GDScript 2.0 and Godot 4.0. I'm focusing on 2D
at the moment as I'm upgrading a 2D game, but will hopefully have more to add for 3D afterward.
## If you want more content like this, please help fund my cat's medical bills at https://ko-fi.com/kyleszklenski - thank you very much! On to the migration guide.