修改移动组件
This commit is contained in:
parent
0e84094564
commit
6d248bdb88
|
|
@ -1,3 +1,7 @@
|
|||
extends Node2D
|
||||
|
||||
var s := 1
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action("ui_down"):
|
||||
Engine.time_scale = .1
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://c3mievyfhx6ni" path="res://_props/coin/coin.tscn" id="11_1t0dx"]
|
||||
[ext_resource type="Script" uid="uid://cdvgq0xqdbagk" path="res://addons/reedscene/prop/ReedPropEffect.gd" id="12_fyfyw"]
|
||||
[ext_resource type="Script" uid="uid://jeybblac0kg2" path="res://addons/reedscene/prop/ReedTransition.gd" id="13_8hwae"]
|
||||
[ext_resource type="PackedScene" uid="uid://mi4omkkocmc0" path="res://_props/_prefabs/scene_static_camera.tscn" id="14_s6kod"]
|
||||
[ext_resource type="PackedScene" uid="uid://mi4omkkocmc0" path="res://_props/_prefabs/camera/scene_static_camera.tscn" id="14_s6kod"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s6kod"]
|
||||
script = ExtResource("6_fyfyw")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=36 format=4 uid="uid://c6and5mqr3wv1"]
|
||||
[gd_scene load_steps=37 format=4 uid="uid://c6and5mqr3wv1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="1_of2em"]
|
||||
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="2_61x7c"]
|
||||
|
|
@ -15,8 +15,9 @@
|
|||
[ext_resource type="PackedScene" uid="uid://c3mievyfhx6ni" path="res://_props/coin/coin.tscn" id="11_61x7c"]
|
||||
[ext_resource type="Script" uid="uid://cdvgq0xqdbagk" path="res://addons/reedscene/prop/ReedPropEffect.gd" id="12_jhhb1"]
|
||||
[ext_resource type="Script" uid="uid://jeybblac0kg2" path="res://addons/reedscene/prop/ReedTransition.gd" id="13_5navl"]
|
||||
[ext_resource type="PackedScene" uid="uid://mi4omkkocmc0" path="res://_props/_prefabs/scene_static_camera.tscn" id="14_5navl"]
|
||||
[ext_resource type="PackedScene" uid="uid://bonrls3iuhdqb" path="res://_props/_prefabs/player_trigger_volumn.tscn" id="17_tr4o2"]
|
||||
[ext_resource type="PackedScene" uid="uid://mi4omkkocmc0" path="res://_props/_prefabs/camera/scene_static_camera.tscn" id="14_5navl"]
|
||||
[ext_resource type="Resource" uid="uid://bm0iyvgqfrqoj" path="res://_props/_prefabs/camera/change_room_tween.tres" id="15_meuxg"]
|
||||
[ext_resource type="PackedScene" uid="uid://bonrls3iuhdqb" path="res://_props/_prefabs/player/player_trigger_volumn.tscn" id="17_tr4o2"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5navl"]
|
||||
script = ExtResource("6_d8y7x")
|
||||
|
|
@ -182,8 +183,9 @@ effects = Array[ExtResource("12_jhhb1")]([SubResource("Resource_25twt")])
|
|||
metadata/_custom_type_script = "uid://jeybblac0kg2"
|
||||
|
||||
[node name="SceneStaticCamera" parent="Props" instance=ExtResource("14_5navl")]
|
||||
process_mode = 3
|
||||
position = Vector2(981, 183)
|
||||
draw_limits = true
|
||||
tween_resource = ExtResource("15_meuxg")
|
||||
|
||||
[node name="[Prop_0001]" type="Node" parent="Props/SceneStaticCamera"]
|
||||
script = ExtResource("7_5navl")
|
||||
|
|
|
|||
|
|
@ -160,18 +160,19 @@ dash_speed = 400.0
|
|||
end_dash_speed = 190.0
|
||||
climb_hop_velocity_x = 180.0
|
||||
climb_hop_velocity_y = 334.0
|
||||
jump_force = 296.0
|
||||
jump_force = 460.0
|
||||
jump_hold_maxium_time = 0.125
|
||||
jump_horizontal_Boost = 265.0
|
||||
jump_horizontal_Boost_last_time = 0.3
|
||||
light_gravity_threshold = 135.0
|
||||
light_gravity_mult = 0.6
|
||||
wall_jump_base_force_x = 260.0
|
||||
wall_jump_base_force_y = 220.0
|
||||
fall_maxium_speed = 430.0
|
||||
air_control_mult = 0.85
|
||||
run_accel = 1100.0
|
||||
run_accel = 1300.0
|
||||
run_reduce = 2400.0
|
||||
move_speed_max = 192.0
|
||||
move_speed_max = 202.0
|
||||
|
||||
[node name="WallDetector" parent="LocomotionComponent" instance=ExtResource("20_air0b")]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
|
|
@ -50,9 +50,15 @@ func _ready() -> void:
|
|||
func _draw() -> void:
|
||||
draw_string(ThemeDB.fallback_font,Vector2.ZERO,str(get_wall_normal()))
|
||||
|
||||
var x: float = clampf(abs(velocity.x),1,1000) * .2 * sign(velocity.x)
|
||||
var y: float = clampf(abs(velocity.y),1,1000) * .2 * sign(velocity.y)
|
||||
|
||||
draw_line(Vector2.ZERO,Vector2(x, 0),Color.RED,4)
|
||||
draw_line(Vector2.ZERO,Vector2(0, y),Color.GREEN,4)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
print(self.is_on_floor())
|
||||
queue_redraw()
|
||||
print(self.is_on_floor())
|
||||
|
||||
|
||||
func set_move_input(dir: Vector2) -> void:
|
||||
|
|
@ -65,57 +71,6 @@ func get_move_input() -> Vector2:
|
|||
func get_is_on_floor() -> bool:
|
||||
return self.is_on_floor() or ground_companion.has_overlapping_areas() or ground_companion.has_overlapping_bodies()
|
||||
|
||||
#func _physics_process(delta: float) -> void:
|
||||
#
|
||||
###用於更新輸入的朝向
|
||||
#m_input_intent_direction = Input.get_vector(
|
||||
#"move_left",
|
||||
#"move_right",
|
||||
#"move_up",
|
||||
#"move_down"
|
||||
#)
|
||||
#
|
||||
#spawn_hook_comp.set_ray_direction(m_input_intent_direction)
|
||||
|
||||
#func _unhandled_input(event: InputEvent) -> void:
|
||||
#if event.is_echo():
|
||||
#return
|
||||
#
|
||||
##jump input
|
||||
#if event.is_action_pressed(&"jump"):
|
||||
#m_jump_press = true
|
||||
#_handle_jump_press()
|
||||
#
|
||||
#if event.is_action_released(&"jump"):
|
||||
#m_jump_press = false
|
||||
#_handle_jump_release()
|
||||
#
|
||||
##dash input
|
||||
#if event.is_action_pressed(&"dash"):
|
||||
#m_dash_press = true
|
||||
#_handle_dash_press()
|
||||
#
|
||||
#if event.is_action_released(&"dash"):
|
||||
#m_dash_press = false
|
||||
#
|
||||
##climb input
|
||||
#if event.is_action_pressed(&"climb"):
|
||||
#m_climb_press = true
|
||||
#_handle_climb_press()
|
||||
#
|
||||
#if event.is_action_released(&"climb"):
|
||||
#m_climb_press = false
|
||||
#_handle_climb_release()
|
||||
#
|
||||
##grap hook input
|
||||
#if event.is_action_pressed(&"grap_hook"):
|
||||
#m_grap_hook_press = true
|
||||
#_handle_grap_hook_press()
|
||||
#
|
||||
#if event.is_action_released(&"grap_hook"):
|
||||
#m_grap_hook_press = false
|
||||
#_handle_grap_hook_release()
|
||||
|
||||
#region 输入处理
|
||||
'''对于单次的输入触发动作,我们发送一个格式为
|
||||
want_to_...的事件给hsm,用来尝试触发
|
||||
|
|
@ -154,38 +109,6 @@ func release_grap_hook() -> void:
|
|||
hsm.dispatch(&"completed_grap_hook")
|
||||
#endregion
|
||||
|
||||
##处理 jump 单次输入
|
||||
#func _handle_jump_press() -> void:
|
||||
#if not m_jump_press:
|
||||
#return
|
||||
#
|
||||
#hsm.dispatch(&"trigger_jump")
|
||||
#
|
||||
#func _handle_jump_release() -> void:
|
||||
#hsm.dispatch(&"completed_jump")
|
||||
#
|
||||
###处理 Dash 单次输入
|
||||
#func _handle_dash_press() -> void:
|
||||
#if not m_dash_press:
|
||||
#return
|
||||
#hsm.dispatch(&"trigger_dash")
|
||||
#
|
||||
###处理 climb 输入
|
||||
#func _handle_climb_press() -> void:
|
||||
#if not m_climb_press:
|
||||
#return
|
||||
#hsm.dispatch(&"trigger_climb")
|
||||
#
|
||||
#func _handle_climb_release() -> void:
|
||||
#hsm.dispatch(&"completed_climb")
|
||||
#
|
||||
###处理 Grap Hook 输入
|
||||
#func _handle_grap_hook_press() -> void:
|
||||
#hsm.dispatch(&"trigger_grap_hook")
|
||||
#
|
||||
#func _handle_grap_hook_release() -> void:
|
||||
#hsm.dispatch(&"completed_grap_hook")
|
||||
|
||||
##玩家方向改变时更新
|
||||
func _handle_direction_changed(value: Direction):
|
||||
match value:
|
||||
|
|
|
|||
|
|
@ -10,12 +10,20 @@ extends LimboState
|
|||
var _pull_timer := 0.0
|
||||
var _anchor
|
||||
|
||||
var _tween: Tween
|
||||
|
||||
|
||||
func _setup() -> void:
|
||||
self.add_event_handler(&"trigger_jump",_handle_trigger_jump)
|
||||
|
||||
func _enter() -> void:
|
||||
var tween := get_tree().create_tween()
|
||||
tween.set_ignore_time_scale(true)
|
||||
|
||||
tween.tween_property(Engine, "time_scale", .15, .04)
|
||||
tween.tween_interval(.12)
|
||||
tween.tween_property(Engine, "time_scale", 1.0, .06)
|
||||
|
||||
if root.grap_hook_state._jump_grace_timer > 0:
|
||||
_hook_to_jump()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends LimboState
|
||||
|
||||
func _enter() -> void:
|
||||
return
|
||||
agent.locomotion_comp.stop_movement(0.0) #用0唤起制动加速度
|
||||
|
||||
func _update(delta: float) -> void:
|
||||
if agent.get_move_input().x != 0.0:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func _handle_move_input() -> void:
|
|||
var move_direction = agent.get_move_input().x as float
|
||||
if move_direction == 0.0:
|
||||
get_root().dispatch(self.EVENT_FINISHED)
|
||||
agent.locomotion_comp.add_movement_input(0.0) #用0唤起制动加速度
|
||||
agent.locomotion_comp.stop_movement(0.0) #用0唤起制动加速度
|
||||
return
|
||||
agent.locomotion_comp.add_movement_input(move_direction)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="PhantomCameraTween" load_steps=2 format=3 uid="uid://bm0iyvgqfrqoj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://8umksf8e80fw" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="1_j0gyv"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_j0gyv")
|
||||
duration = 0.6
|
||||
transition = 7
|
||||
metadata/_custom_type_script = "uid://8umksf8e80fw"
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="1_p2s6f"]
|
||||
[ext_resource type="Script" uid="uid://8umksf8e80fw" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="2_77rrp"]
|
||||
[ext_resource type="Script" uid="uid://ce7d2tpunfaxe" path="res://_props/_prefabs/camera_tool.gd" id="3_77rrp"]
|
||||
[ext_resource type="Script" uid="uid://ce7d2tpunfaxe" path="res://_props/_prefabs/camera/camera_tool.gd" id="3_77rrp"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_gofl0"]
|
||||
script = ExtResource("2_77rrp")
|
||||
|
|
@ -10,6 +10,7 @@ script = ExtResource("2_77rrp")
|
|||
[node name="SceneStaticCamera" type="Node2D"]
|
||||
script = ExtResource("1_p2s6f")
|
||||
tween_resource = SubResource("Resource_gofl0")
|
||||
draw_limits = true
|
||||
metadata/_custom_type_script = "uid://bhexx6mj1xv3q"
|
||||
|
||||
[node name="Tool" type="Node" parent="." node_paths=PackedStringArray("binded_camera")]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://d20u8tfktepxg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b7o5456qrwgbf" path="res://_props/_prefabs/collection_prefab.gd" id="1_8ns1b"]
|
||||
[ext_resource type="Script" uid="uid://b7o5456qrwgbf" path="res://_props/_prefabs/collection/collection_prefab.gd" id="1_8ns1b"]
|
||||
|
||||
[node name="CollectionPrefab" type="Area2D"]
|
||||
collision_layer = 16
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://5ia817pm76x1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://byntg0bbp8nar" path="res://_props/_prefabs/door.gd" id="1_gt1uq"]
|
||||
[ext_resource type="Script" uid="uid://byntg0bbp8nar" path="res://_props/_prefabs/door/door.gd" id="1_gt1uq"]
|
||||
[ext_resource type="Texture2D" uid="uid://c673bap4b12fx" path="res://icon.svg" id="2_f05xd"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g1m3x"]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[gd_scene format=3 uid="uid://csdxpv8gefpec"]
|
||||
|
||||
[node name="MovablePlateform" type="AnimatableBody2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bonrls3iuhdqb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c25ea2nypjah7" path="res://_props/_prefabs/player_trigger_volumn.gd" id="1_qrafk"]
|
||||
[ext_resource type="Script" uid="uid://c25ea2nypjah7" path="res://_props/_prefabs/player/player_trigger_volumn.gd" id="1_qrafk"]
|
||||
|
||||
[node name="PlayerTriggerVolumn" type="Area2D"]
|
||||
editor_description = "此类在检测到玩家时会发出signal,可以与其他的需要检测玩家的scene组合使用。
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://brxjxhoq2g2bb"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://csdxpv8gefpec" path="res://_props/_prefabs/movable_plateform.tscn" id="1_4q2e0"]
|
||||
[ext_resource type="Texture2D" uid="uid://c673bap4b12fx" path="res://icon.svg" id="2_687ql"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_687ql"]
|
||||
size = Vector2(126, 52)
|
||||
|
||||
[node name="AnimationMovePlateform" type="Node2D"]
|
||||
|
||||
[node name="MovablePlateform" parent="." instance=ExtResource("1_4q2e0")]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="MovablePlateform"]
|
||||
scale = Vector2(1, 0.421875)
|
||||
texture = ExtResource("2_687ql")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="MovablePlateform"]
|
||||
shape = SubResource("RectangleShape2D_687ql")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c3mievyfhx6ni"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d20u8tfktepxg" path="res://_props/_prefabs/collection_prefab.tscn" id="1_r0qyb"]
|
||||
[ext_resource type="PackedScene" uid="uid://d20u8tfktepxg" path="res://_props/_prefabs/collection/collection_prefab.tscn" id="1_r0qyb"]
|
||||
[ext_resource type="Texture2D" uid="uid://c673bap4b12fx" path="res://icon.svg" id="2_igeyo"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_r0qyb"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b5nx4dntm0gyn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://5ia817pm76x1" path="res://_props/_prefabs/door.tscn" id="1_3ghu3"]
|
||||
[ext_resource type="PackedScene" uid="uid://5ia817pm76x1" path="res://_props/_prefabs/door/door.tscn" id="1_3ghu3"]
|
||||
[ext_resource type="Script" uid="uid://cup8c7j4e6xpf" path="res://_props/door_manager/event_trigger_door.gd" id="1_iprsb"]
|
||||
|
||||
[node name="EventTriggerDoor" type="Node2D"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://knrcnoedxvm6"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bonrls3iuhdqb" path="res://_props/_prefabs/player_trigger_volumn.tscn" id="1_mvp6g"]
|
||||
[ext_resource type="PackedScene" uid="uid://bonrls3iuhdqb" path="res://_props/_prefabs/player/player_trigger_volumn.tscn" id="1_mvp6g"]
|
||||
[ext_resource type="PackedScene" uid="uid://cmjwk4gr1nfns" path="res://_props/_prefabs/rock.tscn" id="1_nh18e"]
|
||||
[ext_resource type="Script" uid="uid://b8yl6l3tlam86" path="res://_props/trigger_fall_rock/trigger_fall_rock.gd" id="1_vv0hj"]
|
||||
[ext_resource type="Texture2D" uid="uid://c673bap4b12fx" path="res://icon.svg" id="2_xilvp"]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ func _ready() -> void:
|
|||
r.body_entered.connect(_handle_body_enter_room)
|
||||
r.init_room_entrance(self)
|
||||
|
||||
self.get_process_delta_time()
|
||||
|
||||
func _handle_body_enter_room(body: Node2D) -> void:
|
||||
if RoomSystem.current_room_id == self._room_id:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class_name JumpLocomotionComponent extends LocomotionComponent
|
|||
@export var jump_hold_maxium_time : float = .18
|
||||
##跳跃时对移动输入的补正
|
||||
@export var jump_horizontal_Boost : float = 80
|
||||
##跳跃对移动输入的水平补正可以持续的时间
|
||||
@export var jump_horizontal_Boost_last_time : float = .08
|
||||
##Jump时是否还需要受到重力影响
|
||||
@export var jump_effected_by_gravity : bool = true
|
||||
##半重力触发阈值,当速度小于这个数值时,会将角色的重力减半
|
||||
|
|
@ -33,6 +35,7 @@ class_name JumpLocomotionComponent extends LocomotionComponent
|
|||
var _jump_timer : float
|
||||
var _is_jumping : bool = false
|
||||
var _is_wall_jumping: bool = false
|
||||
var _h_boost_timer: float
|
||||
|
||||
|
||||
##跳跃
|
||||
|
|
@ -40,13 +43,10 @@ func jump() -> bool:
|
|||
if _is_jumping : return false
|
||||
|
||||
##如果是同方向的,则
|
||||
if sign(characterbody.velocity.x) * sign(_movement_input) > 0:
|
||||
#给与一个跳跃的补正速度
|
||||
characterbody.velocity.x += _movement_input * jump_horizontal_Boost * .7
|
||||
else:
|
||||
characterbody.velocity.x = _movement_input * jump_horizontal_Boost # 跳跃的水平补正速度
|
||||
characterbody.velocity.x = _movement_input * jump_horizontal_Boost
|
||||
|
||||
_jump_timer = jump_hold_maxium_time
|
||||
_h_boost_timer = jump_horizontal_Boost_last_time
|
||||
_is_jumping = true
|
||||
characterbody.velocity.y = _get_jump_force()
|
||||
|
||||
|
|
@ -54,6 +54,14 @@ func jump() -> bool:
|
|||
|
||||
##停止跳跃,实际的功能是重置跳跃相关的标识符
|
||||
func stop_jump() -> void:
|
||||
|
||||
# 如果还在上升,直接砍掉上升速度
|
||||
if characterbody.velocity.y < 0 and _jump_timer > 0:
|
||||
characterbody.velocity.y *= 0.6
|
||||
|
||||
_jump_timer = 0
|
||||
_h_boost_timer = 0
|
||||
|
||||
_is_jumping = false
|
||||
_is_wall_jumping = false
|
||||
|
||||
|
|
@ -68,13 +76,19 @@ func wall_jump() -> void:
|
|||
_is_wall_jumping = true
|
||||
|
||||
func _update_gravity(delta: float) -> void:
|
||||
if _jump_timer >= 0:
|
||||
if _is_jumping:
|
||||
characterbody.velocity.y = _get_jump_force()
|
||||
#if _jump_timer >= 0:
|
||||
#if _is_jumping:
|
||||
#characterbody.velocity.y = _get_jump_force()
|
||||
#_jump_timer -= delta
|
||||
#
|
||||
##如果不希望jump时受到重力影响,可以关闭此开关
|
||||
#if not jump_effected_by_gravity: return
|
||||
if _jump_timer > 0 and _is_jumping:
|
||||
_jump_timer -= delta
|
||||
|
||||
#如果不希望jump时受到重力影响,可以关闭此开关
|
||||
if not jump_effected_by_gravity: return
|
||||
if _h_boost_timer > 0 and _is_jumping:
|
||||
_h_boost_timer -= delta
|
||||
characterbody.velocity.x = _movement_input * jump_horizontal_Boost
|
||||
|
||||
super._update_gravity(delta)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class_name LocomotionComponent extends ComponentBase
|
|||
##空中控制乘量,在空中移动时修改
|
||||
@export var air_control_mult : float = .65
|
||||
#基础的乘量,对所有Character相同
|
||||
const GRAVITY_BASIC_MULT_FACTOR : float = 2.1
|
||||
const GRAVITY_BASIC_MULT_FACTOR : float = 1.8
|
||||
#下坠速度和最大下坠速度的阈值,超过了这个阈值会开启下坠速度修正,主要取决于设备的刷新率固写死。
|
||||
const FALL_SPEED_EXCEED_TOLERANCE_THRESHOLD = 40
|
||||
|
||||
|
|
@ -107,8 +107,15 @@ func _update_movement(delta : float) -> void:
|
|||
var input_dir = sign(_movement_input) as float
|
||||
var current_dir = sign(characterbody.velocity.x) as float
|
||||
var accel: float
|
||||
if abs(characterbody.velocity.x) > move_speed_max and input_dir * current_dir <= 0 and input_dir != 0:
|
||||
accel = run_reduce #如果移动方向和当前的速度方向不同向,且不是起步,那么apply 减速的加速度。
|
||||
if abs(characterbody.velocity.x) > move_speed_max or \
|
||||
input_dir * current_dir < 0 or \
|
||||
(input_dir == 0 and abs(characterbody.velocity.x) > 0):
|
||||
#如果:
|
||||
# 1. 速度超过极限速度
|
||||
# 2. 移动方向和输入方向相反
|
||||
# 3. 输入为0,但仍然有速度。(放开输入,等待停止)
|
||||
#那么apply 减速的加速度。
|
||||
accel = run_reduce
|
||||
else:
|
||||
accel = run_accel #其他case都是加速的加速度
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
extends Node
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cjidiw2iaotbg
|
||||
Loading…
Reference in New Issue