爬墙手感迭代,跳跃手感迭代
This commit is contained in:
parent
2322e41a99
commit
027ea95584
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=13 format=3 uid="uid://3vc8ojbiyy5w"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://3vc8ojbiyy5w"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://crgac4manhoud" path="res://_game/game.gd" id="1_yksyv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_x2i0j"]
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
[ext_resource type="PackedScene" uid="uid://7424nctotch0" path="res://_scene/level1/l1_s6.tscn" id="9_m1t3p"]
|
||||
[ext_resource type="PackedScene" uid="uid://dr8a26hfqkh12" path="res://_scene/level1/l1_s7.tscn" id="10_5s0xe"]
|
||||
[ext_resource type="PackedScene" uid="uid://2d457ndb7toe" path="res://_scene/level1/l1_s8.tscn" id="11_ktxjv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcoq4q3brnkw6" path="res://_scene/level1/l1_s9.tscn" id="12_enubi"]
|
||||
|
||||
[node name="Game" type="Node2D" groups=["PLAYER_RESPAWN"]]
|
||||
script = ExtResource("1_yksyv")
|
||||
|
|
@ -35,5 +34,3 @@ script = ExtResource("1_yksyv")
|
|||
[node name="L1_S7" parent="." instance=ExtResource("10_5s0xe")]
|
||||
|
||||
[node name="L1_S8" parent="." groups=["GRAPABLE"] instance=ExtResource("11_ktxjv")]
|
||||
|
||||
[node name="L1_S9" parent="." instance=ExtResource("12_enubi")]
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ size = Vector2(10, 25)
|
|||
|
||||
[node name="Avatar" type="CharacterBody2D" groups=["PLAYER"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 36
|
||||
collision_mask = 4
|
||||
floor_snap_length = 4.0
|
||||
platform_floor_layers = 4
|
||||
platform_wall_layers = 4
|
||||
|
|
@ -65,6 +65,7 @@ shape = SubResource("CircleShape2D_1a1t3")
|
|||
debug_color = Color(0, 0.63529414, 0.40784314, 0.41960785)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
shape = SubResource("RectangleShape2D_qnulu")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
|
|
|
|||
|
|
@ -9,10 +9,16 @@ class_name Player extends CharacterBody2D
|
|||
@onready var foot_pos_marker: Marker2D = %FootPosMarker
|
||||
@onready var ground_companion: Area2D = %GroundCompanion
|
||||
|
||||
@onready var collision_shape_2d: CollisionShape2D = %CollisionShape2D
|
||||
|
||||
|
||||
enum Direction{LEFT,RIGHT}
|
||||
var direction: Direction = Direction.RIGHT: set = _player_direction_changed
|
||||
|
||||
var wall_snap_offset: float :
|
||||
get():
|
||||
return collision_shape_2d.shape.get_rect().size.x/2
|
||||
|
||||
var m_jump_press: bool = false
|
||||
var m_dash_press: bool = false
|
||||
var m_climb_press: bool = false
|
||||
|
|
|
|||
|
|
@ -13,10 +13,25 @@ func _enter() -> void:
|
|||
if agent.is_on_wall():##如果已经在Wall上,则什么都不做
|
||||
return
|
||||
|
||||
##这里是给予玩家一个补偿的上墙力,因为我们存在一个小区间运行玩家可以不贴着墙壁,所以我们给予一个很大的力让玩家的位置修正到墙壁
|
||||
var compensaton_velocity = Player.get_direction_vector(agent.direction) * 1000
|
||||
agent.velocity = compensaton_velocity
|
||||
agent.move_and_slide()
|
||||
snap_to_wall()
|
||||
|
||||
func snap_to_wall(max_snap_dist := 6.0) -> bool:
|
||||
var wall_dir : float = sign(agent.wall_detector.wall_direction.x)
|
||||
|
||||
var from : Vector2 = agent.global_position
|
||||
var to : Vector2 = from + Vector2(wall_dir * max_snap_dist, 0)
|
||||
|
||||
var query := PhysicsRayQueryParameters2D.create(from, to)
|
||||
query.exclude = [agent]
|
||||
query.collision_mask = agent.collision_mask
|
||||
|
||||
var result = agent.get_world_2d().direct_space_state.intersect_ray(query)
|
||||
if result:
|
||||
var target_x = result.position.x - wall_dir * agent.wall_snap_offset
|
||||
agent.global_position.x = target_x
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _handler_climb_state_finished() -> bool:
|
||||
if agent.is_on_floor():
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -158,7 +158,7 @@ func _get_gravity_scale() -> float:
|
|||
##重写最大下落速度
|
||||
func _get_max_fall_speed() -> float:
|
||||
var wall_normal_x = characterbody.get_wall_normal().x
|
||||
if -1 * sign(_movement_input) == wall_normal_x and characterbody.is_on_wall():
|
||||
if -1 * sign(_movement_input) == wall_normal_x and characterbody.is_on_wall() and characterbody.velocity.y > 0:
|
||||
return wall_slide_fall_maxium_speed
|
||||
else:
|
||||
return fall_maxium_speed
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ var down_ray_on_wall: bool = false:
|
|||
down_ray_on_wall = value
|
||||
down_ray_state_changed.emit(value)
|
||||
|
||||
var wall_direction : Vector2:
|
||||
get():
|
||||
return Vector2(-1,0) if flip_h else Vector2(1,0)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
|
|
|||
Loading…
Reference in New Issue