added pipe rifle animation

This commit is contained in:
2026-02-10 02:48:14 +11:00
parent 137a979c5c
commit d8101979b9
113 changed files with 1025 additions and 415 deletions

41
PCs/spring.gd Normal file
View File

@@ -0,0 +1,41 @@
class_name Spring
extends Node3D
@export var hero: Hero
@export var hud: HUD
@export var hud_affect: float
@export var affect: Node3D
@export var AccelerationScale: float = 200.0
@export var MaxAcceleration: float = 0.3
@export var Rebound: float = 2.0
@export var Damping: float = 14.0
var previousVelocity: Vector3;
var AccumulatedDifferential: Vector3;
var AccumulatedDeflection: Vector3;
func _process(delta: float) -> void:
var current_velocity: Vector3 = hero.velocity
var acceleration: Vector3 = previousVelocity - current_velocity
acceleration /= AccelerationScale;
if (acceleration.length() > MaxAcceleration):
acceleration = acceleration.normalized() * MaxAcceleration;
AccumulatedDifferential += acceleration;
AccumulatedDeflection += AccumulatedDifferential;
AccumulatedDifferential -= AccumulatedDeflection * Rebound * delta;
AccumulatedDeflection -= AccumulatedDeflection * Damping * delta;
previousVelocity = current_velocity;
position.y = AccumulatedDeflection.y
if affect:
affect.position.y = AccumulatedDeflection.y
affect.position.x = AccumulatedDeflection.z
if hud:
hud.offset = Vector2(AccumulatedDeflection.x, AccumulatedDeflection.y) * hud_affect