princesse/detection_sol: ajout d'un deuxième ray cast
Un par pied, permet d'avoir un meilleur feeling pour rebondir au bord d'une plateforme.
This commit is contained in:
@@ -13,6 +13,7 @@ var gravity: int = ProjectSettings.get("physics/2d/default_gravity")
|
||||
@onready var wall_detect_right3 := $wall_detect_right3 as RayCast2D
|
||||
|
||||
@onready var ground_far_detect := $ground_far_detect as RayCast2D
|
||||
@onready var ground_far_detect2 := $ground_far_detect2 as RayCast2D
|
||||
@onready var animation := $AnimatedSprite2D as AnimatedSprite2D
|
||||
@onready var camera := $Camera2D as Camera2D
|
||||
@onready var death_animation := $"Death player" as AnimationPlayer
|
||||
@@ -80,6 +81,7 @@ var jumping : bool = false # Princesse est-elle en train de sauter ?
|
||||
var need_jump : bool = false # Le joueur veut-il sauter et peut il ?
|
||||
var jumping_step : int = -1 # Où en est la princesse dans son tableau d'accel
|
||||
var jump_key_counter : int = 0 # Où en est-on du refil ?
|
||||
var collide_ground_far_detect = false # est-ce que les collisioneurs du sol sont en contact avec ?
|
||||
|
||||
# variables d'état relatives au kick mural
|
||||
var kicking : bool = false
|
||||
@@ -384,7 +386,7 @@ func read_input() -> void:
|
||||
# Le joueur veut-il sauter ou kicker ?
|
||||
if Input.is_action_just_pressed("jump" + action_suffix):
|
||||
# Peut-il sauter ?
|
||||
if ground_far_detect.is_colliding() or (is_on_floor() or get_coyote(coyote_ground)):
|
||||
if collide_ground_far_detect or (is_on_floor() or get_coyote(coyote_ground)):
|
||||
need_jump=true
|
||||
else:
|
||||
need_jump=false
|
||||
@@ -505,6 +507,7 @@ func read_input() -> void:
|
||||
dash_step = DASH_SPEED_TABLE.size()-1
|
||||
|
||||
func compute_state() -> void:
|
||||
collide_ground_far_detect = ground_far_detect.is_colliding() or ground_far_detect2.is_colliding()
|
||||
# Met à jour une partie de l'état de la princesse
|
||||
# gestion du coyote time sur le contact au sol
|
||||
coyote_ground.append(is_on_floor())
|
||||
@@ -518,12 +521,12 @@ func compute_state() -> void:
|
||||
coyote_grab.remove_at(0)
|
||||
|
||||
# gestion de l'état de la pression au mur
|
||||
pressing_wall_left = (not is_on_floor() and not ground_far_detect.is_colliding()) and (
|
||||
pressing_wall_left = (not is_on_floor() and not collide_ground_far_detect) and (
|
||||
wall_detect_left.is_colliding() or
|
||||
wall_detect_left2.is_colliding() or
|
||||
wall_detect_left3.is_colliding()
|
||||
)
|
||||
pressing_wall_right = (not is_on_floor() and not ground_far_detect.is_colliding()) and (
|
||||
pressing_wall_right = (not is_on_floor() and not collide_ground_far_detect) and (
|
||||
wall_detect_right.is_colliding() or
|
||||
wall_detect_right2.is_colliding() or
|
||||
wall_detect_right3.is_colliding()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=37 format=3 uid="uid://dv0mokf4eogm7"]
|
||||
[gd_scene load_steps=43 format=3 uid="uid://dv0mokf4eogm7"]
|
||||
|
||||
[ext_resource type="Script" path="res://princesse.gd" id="1_dkp7s"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr7fyh2rufsyj" path="res://sprite/princess_falling_direction.png" id="2_hholp"]
|
||||
@@ -308,11 +308,17 @@ drag_horizontal_enabled = true
|
||||
drag_vertical_enabled = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 3)
|
||||
position = Vector2(0, 5)
|
||||
shape = SubResource("CapsuleShape2D_6r7th")
|
||||
|
||||
[node name="ground_far_detect" type="RayCast2D" parent="."]
|
||||
target_position = Vector2(0, 38)
|
||||
position = Vector2(4, 0)
|
||||
target_position = Vector2(0, 42)
|
||||
collision_mask = 16
|
||||
|
||||
[node name="ground_far_detect2" type="RayCast2D" parent="."]
|
||||
position = Vector2(-4, 0)
|
||||
target_position = Vector2(0, 42)
|
||||
collision_mask = 16
|
||||
|
||||
[node name="Death player" type="AnimationPlayer" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user