init
This commit is contained in:
commit
f389e4e807
186 changed files with 10853 additions and 0 deletions
17
spring2d.gd
Normal file
17
spring2d.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends Node2D
|
||||
|
||||
@export var max_offset := Vector2.ONE
|
||||
|
||||
var _last_global_position: Vector2
|
||||
var _local_offset: Vector2
|
||||
|
||||
func _ready() -> void:
|
||||
_last_global_position = global_position
|
||||
_local_offset = position
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var parent_position: Vector2 = get_parent().global_position
|
||||
var target_position := parent_position + _local_offset
|
||||
var new_position: Vector2 = lerp(_last_global_position, target_position, 0.4)
|
||||
global_position = target_position + (new_position - target_position).clamp(-max_offset, max_offset)
|
||||
_last_global_position = global_position
|
||||
Loading…
Add table
Add a link
Reference in a new issue