From 103b3bf74a8e85ef01ce4eb086533d281bff1f0f Mon Sep 17 00:00:00 2001 From: Spencer Killen Date: Sun, 11 Dec 2022 18:07:05 -0700 Subject: [PATCH] Fix FOV and sink block --- godot/player/HighSpeedFOV.gd | 10 +++++++--- godot/player/OnFootPhysics.gd | 4 ++-- godot/player/PlatformMechanics.gd | 2 +- godot/tests/falling/test_falling.tscn | 6 +++++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/godot/player/HighSpeedFOV.gd b/godot/player/HighSpeedFOV.gd index d422b26..0f5ca53 100644 --- a/godot/player/HighSpeedFOV.gd +++ b/godot/player/HighSpeedFOV.gd @@ -2,9 +2,13 @@ extends Node onready var OnFootPhysics = get_node("../../../../../OnFootPhysics") onready var Floor = get_node("../../../../../OnFootPhysics/Floor") +var has_played = false func _process(_delta): - if OnFootPhysics.velocity.y >= 0.0 or Floor.is_on_floor: - $FOVAnimation.play("RESET") + if OnFootPhysics.is_falling_terminally: + if has_played: + $FOVAnimation.play("fov") + has_played = true return - $FOVAnimation.play("fov") + has_played = false + $FOVAnimation.play("RESET") diff --git a/godot/player/OnFootPhysics.gd b/godot/player/OnFootPhysics.gd index fecbc18..3610c59 100644 --- a/godot/player/OnFootPhysics.gd +++ b/godot/player/OnFootPhysics.gd @@ -66,7 +66,7 @@ func process_velocity(delta: float): target_velocity_xz *= sprint_factor else: target_velocity_xz *= walk_factor - target_velocity = util.vec2_xz_to_vec3(target_velocity_xz, target_velocity.y) + target_velocity = util.vec2_xz_to_vec3(target_velocity_xz, target_velocity.y) * velocity_factor var velocity_xz = util.vec3_xz(velocity) @@ -88,8 +88,8 @@ func process_velocity(delta: float): var velocity_y = util.clamped_lerp(velocity.y, target_velocity.y, y_weight, 0.25) + velocity = util.vec2_xz_to_vec3(velocity_xz, velocity_y) - velocity = util.vec2_xz_to_vec3(velocity_xz, velocity_y) * velocity_factor func process_falling(): if not $Floor.is_on_floor: diff --git a/godot/player/PlatformMechanics.gd b/godot/player/PlatformMechanics.gd index d9243f5..2d7e4ba 100644 --- a/godot/player/PlatformMechanics.gd +++ b/godot/player/PlatformMechanics.gd @@ -2,7 +2,7 @@ extends Node onready var global_event_bus = get_node("/root/GlobalEventBus") var sink_counter = 0 -export var SINK_BLOCK_SLOWDOWN_AMOUNT = Vector3(0.7, 0.1, 0.7) +export var SINK_BLOCK_SLOWDOWN_AMOUNT = Vector3(0.7, 0.01, 0.7) func _ready(): global_event_bus.connect("player_entered_meat_sink", self, "on_player_enter_meat_sink") diff --git a/godot/tests/falling/test_falling.tscn b/godot/tests/falling/test_falling.tscn index 0ffa5a3..6fd8107 100644 --- a/godot/tests/falling/test_falling.tscn +++ b/godot/tests/falling/test_falling.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://player/player.tscn" type="PackedScene" id=1] +[ext_resource path="res://effects/SinkBlock.tscn" type="PackedScene" id=2] [sub_resource type="CubeMesh" id=1] @@ -38,3 +39,6 @@ shape = SubResource( 2 ) [node name="Player" parent="." instance=ExtResource( 1 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.271765, 0 ) + +[node name="SinkBlock" parent="." instance=ExtResource( 2 )] +transform = Transform( 1, 0, 0, 0, 0.264811, 0, 0, 0, 1, 2.72806, -22.0505, 0 )