rename _push_outwards to _push_radial

This commit is contained in:
Teatov 2025-08-03 00:13:57 +10:00
parent 9cf81ffe62
commit 7966e2073c
2 changed files with 21 additions and 24 deletions

View File

@ -342,29 +342,27 @@ func _animate_position() -> Vector3:
func _shake(force: float) -> void:
_pos_sod.set_y(
(
position
+ (
Vector3(
randf_range(-force, force),
randf_range(-force, force),
randf_range(-force, force)
)
* _keyboard.key_size
_pos_sod.y = (
_pos_sod.y
+ (
Vector3(
randf_range(-force, force),
randf_range(-force, force),
randf_range(-force, force)
)
* _keyboard.key_size
)
)
func _push(force: Vector3) -> void:
_pos_sod.set_y(position + force * _keyboard.key_size)
_pos_sod.y = (_pos_sod.y + force * _keyboard.key_size)
func _push_outwards(force: float) -> void:
_pos_sod.set_y(
Vector3(position.x * (force + 1), position.y, position.z * (force + 1))
)
func _push_radial(force: float) -> void:
_pos_sod.y = (Vector3(
_pos_sod.y.x * (force + 1), _pos_sod.y.y, _pos_sod.y.z * (force + 1)
))
func _animate_light(delta: float) -> void:
@ -411,9 +409,10 @@ func _on_keyboard_keys_requested(filter_func: Callable) -> void:
func _on_keyboard_is_configuring_changed(value: bool) -> void:
if value:
_push_outwards(0.2)
_push_radial(0.2)
else:
_shake(0.2)
_push_radial(-0.05)
func _on_keyboard_player_key_changed(game_key: GameKey) -> void:

View File

@ -2,6 +2,8 @@
# https://www.youtube.com/watch?v=KPoeNZZ6H4s
class_name SecondOrderDynamics
var y: Vector3
var _k1: float
var _k2: float
var _k3: float
@ -11,7 +13,6 @@ var _z: float
var _d: float
var _xp: Vector3
var _y: Vector3
var _yd: Vector3
@ -29,7 +30,7 @@ func _init(fzr: Vector3, x0: Vector3) -> void:
_k3 = r * z / _w
_xp = x0
_y = x0
y = x0
_yd = Vector3.ZERO
@ -46,10 +47,7 @@ func process(t: float, x: Vector3, xd: Vector3 = Vector3.INF) -> Vector3:
var beta := t1 * t1
var t2 := t / (1 + beta - alpha)
k2_stable = t * t2
_y = _y + t * _yd
_yd = _yd + t * (x + _k3 * xd - _y - _k1 * _yd) / k2_stable
return _y
y = y + t * _yd
_yd = _yd + t * (x + _k3 * xd - y - _k1 * _yd) / k2_stable
return y
func set_y(y: Vector3) -> void:
_y = y