Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6737668391 | |||
| ca77579168 | |||
| c6559d593a | |||
| e32dac9e6e | |||
| 30b4d1a2eb |
@@ -133,6 +133,21 @@ material = ExtResource("3_vvhq3")
|
||||
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -9.5)
|
||||
text = "10m"
|
||||
|
||||
[node name="Label3D6" type="Label3D" parent="Greybox/RunningTrack"]
|
||||
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 27.5, 0.1, 1)
|
||||
text = "10deg
|
||||
"
|
||||
|
||||
[node name="Label3D7" type="Label3D" parent="Greybox/RunningTrack"]
|
||||
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 30.5, 0.1, 1)
|
||||
text = "20deg
|
||||
"
|
||||
|
||||
[node name="Label3D8" type="Label3D" parent="Greybox/RunningTrack"]
|
||||
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 33.5, 0.1, 1)
|
||||
text = "30deg
|
||||
"
|
||||
|
||||
[node name="Label3D2" type="Label3D" parent="Greybox/RunningTrack"]
|
||||
transform = Transform3D(5, 0, 0, 0, -2.18557e-07, 5, 0, -5, -2.18557e-07, 1, 0.1, -19.5)
|
||||
text = "20m"
|
||||
@@ -367,6 +382,60 @@ use_collision = true
|
||||
size = Vector3(7.5, 20, 10)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D41" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.75, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(12.5, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D47" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9848078, 0.17364816, 0, -0.17364816, 0.9848078, 22.75, 0.03095889, -30.695885)
|
||||
use_collision = true
|
||||
size = Vector3(12.5, 10, 58)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D48" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9396926, 0.34202012, 0, -0.34202012, 0.9396926, 30.5, 1.5878377, -16.713436)
|
||||
use_collision = true
|
||||
size = Vector3(3, 6.5, 31.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D49" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.86602545, 0.5, 0, -0.5, 0.86602545, 33.5, 2.5053406, -10.524445)
|
||||
use_collision = true
|
||||
size = Vector3(3, 5.5, 20.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D42" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.5, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(3, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D43" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 33.5, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(3, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D44" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 36.5, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(3, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D45" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 39.5, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(3, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D46" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 42.5, 5, -1.5)
|
||||
use_collision = true
|
||||
size = Vector3(3, 10, 3)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D34" type="CSGBox3D" parent="Greybox/JumpHeights"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -24.5, 10, -15)
|
||||
use_collision = true
|
||||
@@ -437,6 +506,162 @@ use_collision = true
|
||||
size = Vector3(5, 3, 2)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D38" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 21.5, 2.25, 22.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D39" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 21.25, 0.5, 22.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D40" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 28.5, 2.25, 22.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D41" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 28.25, 0.25, 22.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 2.5, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D42" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 35.5, 2.25, 22.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D43" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 35.25, -0.5, 22.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D44" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 42.5, 2.25, 22.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D45" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 42.25, -1, 22.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D46" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 21.5, 2.25, 31.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D47" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 21.25, 0.5, 31.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D48" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 28.5, 2.25, 31.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D49" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 28.25, 0.25, 31.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 2.5, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D50" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 35.5, 2.25, 31.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D51" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 35.25, -0.5, 31.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D52" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 42.5, 2.25, 31.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D53" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-2.6226834e-08, 0, -1, 0, 1, 0, 0.6, 0, -4.371139e-08, 42.25, -1, 31.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D54" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 21.5, 2.25, 39.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D55" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 21.25, 0.5, 39.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D56" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 28.5, 2.25, 39.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D57" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 28.25, 0.25, 39.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 2.5, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D58" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 35.5, 2.25, 39.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D59" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 35.25, -0.5, 39.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D60" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 42.5, 2.25, 39.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 5, 5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D61" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(-7.86805e-09, 0, -1, 0, 1, 0, 0.18, 0, -4.371139e-08, 42.25, -1, 39.5)
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(5, 3, 1.5)
|
||||
material = ExtResource("3_vvhq3")
|
||||
|
||||
[node name="CSGBox3D32" type="CSGBox3D" parent="Greybox/Passageways"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 2.25, -26.5)
|
||||
use_collision = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=49 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
[gd_scene load_steps=50 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||
[ext_resource type="PackedScene" uid="uid://cf3rrgr1imvv4" path="res://scenes/path/path.tscn" id="2_6lejt"]
|
||||
@@ -11,7 +11,6 @@
|
||||
[ext_resource type="Resource" uid="uid://brswsknpgwal2" path="res://systems/inputs/base_mode/move_front.tres" id="7_m8gvy"]
|
||||
[ext_resource type="Resource" uid="uid://s1l0n1iitc6m" path="res://systems/inputs/base_mode/move_back.tres" id="8_jb43f"]
|
||||
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="8_lhb11"]
|
||||
[ext_resource type="Script" uid="uid://dd1yrt7eiiyf4" path="res://player_controller/Scripts/CapsuleCollider.cs" id="8_lmtjd"]
|
||||
[ext_resource type="Resource" uid="uid://c3e0ivgaxrsyb" path="res://systems/inputs/base_mode/aim_down.tres" id="8_obsfv"]
|
||||
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="8_qu4wy"]
|
||||
[ext_resource type="Resource" uid="uid://bebstkm608wxx" path="res://systems/inputs/base_mode/aim_pressed.tres" id="9_nob5r"]
|
||||
@@ -47,6 +46,9 @@
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
|
||||
height = 1.7
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_6lejt"]
|
||||
radius = 0.45
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nodcl"]
|
||||
transparency = 1
|
||||
albedo_color = Color(0, 0.627451, 0.6313726, 0.49019608)
|
||||
@@ -59,7 +61,10 @@ height = 1.0
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_6lejt"]
|
||||
radius = 1.0
|
||||
height = 3.0
|
||||
height = 3.5
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_nob5r"]
|
||||
radius = 0.4
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
|
||||
blend_mode = 1
|
||||
@@ -89,9 +94,16 @@ SimpleDashTime = 0.2
|
||||
AimedDashTime = 0.2
|
||||
PostDashSpeed = 30.0
|
||||
SlamSpeed = 80.0
|
||||
AccelerationGroundSlide = 0.2
|
||||
FlatGroundSlideSpeedLossRate = 0.996
|
||||
GroundSlideJumpMultiplier = 0.1
|
||||
GroundSlideJumpSpeedFactor = 0.1
|
||||
GroundSlideDownSlopeAcceleration = 0.2
|
||||
GroundSlideDownSlopeMaxSpeed = 30.0
|
||||
AirGlideVSpeed = 4.0
|
||||
AccelerationAirGlide = 0.2
|
||||
AccelerationAirGlide = 0.4
|
||||
AirGlideVerticalAcceleration = 8.0
|
||||
AirGlideJumpMultiplier = 0.1
|
||||
AirGlideJumpSpeedFactor = 0.05
|
||||
WallHugGravityLesseningFactor = 15.0
|
||||
WallHugDownwardMaxSpeed = 4.0
|
||||
WallHugHorizontalDeceleration = 1.0
|
||||
@@ -129,17 +141,22 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||
visible = false
|
||||
mesh = SubResource("CapsuleMesh_xc2g5")
|
||||
|
||||
[node name="CapsuleCollider" type="CollisionShape3D" parent="."]
|
||||
[node name="StandingCollider" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||
shape = ExtResource("13_r7i3q")
|
||||
debug_color = Color(0, 0.6, 0.701961, 0.341176)
|
||||
script = ExtResource("8_lmtjd")
|
||||
CapsuleDefaultHeight = 1.7
|
||||
|
||||
[node name="SlideCollider" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.45, 0)
|
||||
shape = SubResource("SphereShape3D_6lejt")
|
||||
disabled = true
|
||||
debug_color = Color(0, 0.6, 0.701961, 0.341176)
|
||||
|
||||
[node name="HeadSystem" parent="." instance=ExtResource("11_rxwoh")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
|
||||
CameraInclineAcceleration = 20.0
|
||||
GroundedCameraIncline = 3.0
|
||||
SlidingJitterAmplitude = 0.2
|
||||
|
||||
[node name="MantleSystem" parent="HeadSystem" instance=ExtResource("8_qu4wy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
|
||||
@@ -242,7 +259,17 @@ mesh = SubResource("CylinderMesh_nodcl")
|
||||
|
||||
[node name="GroundDetector" type="ShapeCast3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_6lejt")
|
||||
target_position = Vector3(0, -0.5, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CeilingDetector" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_nob5r")
|
||||
target_position = Vector3(0, 0.4, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="DirectGroundDetector" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, -2, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="DashCooldown" type="Timer" parent="."]
|
||||
@@ -540,10 +567,10 @@ delay_in_seconds = "0.0"
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("SimpleJump")
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
[node name="OnDash" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
to = NodePath("../../Dashing/Dash")
|
||||
event = &"dash"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
@@ -561,6 +588,12 @@ to = NodePath("../../../Airborne/DoubleJumpEnabled")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -570,10 +603,22 @@ to = NodePath("../../../Airborne/Falling")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Dashing" type="Node" parent="StateChart/Root/Movement"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("Dash")
|
||||
|
||||
[node name="OnDashEndedGrounded" type="Node" parent="StateChart/Root/Movement/Dashing"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Grounded")
|
||||
event = &"grounded"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnDashEnded" type="Node" parent="StateChart/Root/Movement/Dashing"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Airborne/Reset")
|
||||
@@ -602,6 +647,12 @@ script = ExtResource("27_34snm")
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("GroundSlide")
|
||||
|
||||
[node name="OnDash" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Dashing/Dash")
|
||||
event = &"actually_no_dash"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
@@ -619,10 +670,43 @@ delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../AirGlide")
|
||||
to = NodePath("../../AirGlideDoubleJumpEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/SimpleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnCancel" type="Node" parent="StateChart/Root/Movement/Sliding/GroundSlide"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../SlideCanceled")
|
||||
event = &"slide_canceled"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="AirGlideDoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnSlideReleased" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/Reset")
|
||||
event = &"slide_released"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnGrounded" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../GroundSlide")
|
||||
event = &"grounded"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/DoubleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="AirGlide" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -638,6 +722,33 @@ to = NodePath("../../GroundSlide")
|
||||
event = &"grounded"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="SlideCanceled" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnAirborne" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnDash" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Dashing/Dash")
|
||||
event = &"dash"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/SimpleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlideReleased" type="Node" parent="StateChart/Root/Movement/Sliding/SlideCanceled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Grounded")
|
||||
event = &"slide_released"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Airborne" type="Node" parent="StateChart/Root/Movement"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("CoyoteEnabled")
|
||||
@@ -664,12 +775,6 @@ to = NodePath("../../Grounded")
|
||||
event = &"grounded"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlam" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Slamming")
|
||||
@@ -679,6 +784,12 @@ delay_in_seconds = "0.0"
|
||||
[node name="CoyoteEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/Airborne/CoyoteEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/SimpleJump")
|
||||
@@ -694,6 +805,12 @@ delay_in_seconds = "0.0"
|
||||
[node name="DoubleJumpEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Sliding/AirGlideDoubleJumpEnabled")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/DoubleJumpEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../OnWall/Hugging")
|
||||
@@ -709,6 +826,12 @@ delay_in_seconds = "0.0"
|
||||
[node name="Falling" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../OnWall/Hugging")
|
||||
|
||||
@@ -40,17 +40,13 @@ public partial class CapsuleCollider : CollisionShape3D
|
||||
return Mathf.IsEqualApprox(_shape.Height, CapsuleCrouchHeight);
|
||||
}
|
||||
|
||||
public void Crouch(float delta, float crouchTransitionSpeed)
|
||||
public void Crouch()
|
||||
{
|
||||
_shape.Height -= delta * crouchTransitionSpeed;
|
||||
|
||||
_shape.Height = Mathf.Clamp(_shape.Height, CapsuleCrouchHeight, CapsuleDefaultHeight);
|
||||
_shape.Height = CapsuleCrouchHeight;
|
||||
}
|
||||
|
||||
public void UndoCrouching(float delta, float crouchTransitionSpeed)
|
||||
public void Uncrouch()
|
||||
{
|
||||
_shape.Height += delta * crouchTransitionSpeed;
|
||||
|
||||
_shape.Height = Mathf.Clamp(_shape.Height, CapsuleCrouchHeight, CapsuleDefaultHeight);
|
||||
_shape.Height = CapsuleDefaultHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
public StairsSystem StairsSystem;
|
||||
public MantleSystem MantleSystem;
|
||||
public DashSystem DashSystem;
|
||||
public CapsuleCollider CapsuleCollider;
|
||||
public CollisionShape3D StandingCollider;
|
||||
public CollisionShape3D SlideCollider;
|
||||
public Node3D WeaponRoot;
|
||||
public WeaponSystem WeaponSystem;
|
||||
public WallHugSystem WallHugSystem;
|
||||
@@ -49,6 +50,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
public CylinderMesh DashIndicatorMeshCylinder;
|
||||
public RayCast3D WallRunSnapper;
|
||||
public ShapeCast3D GroundDetector;
|
||||
public ShapeCast3D CeilingDetector;
|
||||
public RayCast3D DirectGroundDetector;
|
||||
|
||||
// Inspector stuff
|
||||
[Export] public Marker3D TutorialWeaponTarget;
|
||||
@@ -142,14 +145,36 @@ public partial class PlayerController : CharacterBody3D
|
||||
public float AccelerationGroundSlide = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float DecelerationGroundSlide = 0.1f;
|
||||
[Export(PropertyHint.Range, "0.99,1,0.0001")]
|
||||
public float FlatGroundSlideSpeedLossRate = 0.9975f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float GroundSlideJumpMultiplier = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float GroundSlideJumpSpeedFactor;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float GroundSlideDownSlopeAcceleration = 0.1f;
|
||||
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
|
||||
public float GroundSlideDownSlopeMaxSpeed = 50f;
|
||||
[Export(PropertyHint.Range, "1,10,0.1,or_greater")]
|
||||
public float GroundSlideSlopeMagnetism = 2f;
|
||||
|
||||
|
||||
[ExportSubgroup("Air glide")]
|
||||
[ExportSubgroup("Air glide")]
|
||||
[Export]
|
||||
public bool AllowForVelocityRedirection = true;
|
||||
|
||||
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
||||
public float AirGlideVSpeed { get; set; } = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float AccelerationAirGlide = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float DecelerationAirGlide = 0.1f;
|
||||
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
||||
public float AirGlideVerticalAcceleration = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float AirGlideJumpMultiplier = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float AirGlideJumpSpeedFactor;
|
||||
|
||||
// Wall hug
|
||||
[ExportGroup("Wall hug")]
|
||||
@@ -252,6 +277,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _jumping;
|
||||
private StateChartState _simpleJump;
|
||||
private StateChartState _doubleJump;
|
||||
private StateChartState _mantling;
|
||||
@@ -260,6 +286,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _sliding;
|
||||
private StateChartState _groundSliding;
|
||||
private StateChartState _airGliding;
|
||||
private StateChartState _airGlidingDoubleJump;
|
||||
private StateChartState _slideCanceled;
|
||||
private StateChartState _slamming;
|
||||
private StateChartState _onWall;
|
||||
private StateChartState _onWallHugging;
|
||||
@@ -269,6 +297,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
private Transition _onJumpFromWall;
|
||||
private Transition _onJumpFromWallFalling;
|
||||
private Transition _onLeaveWallFromRun;
|
||||
|
||||
private Transition _onGroundSlideJump;
|
||||
private Transition _onAirGlideDoubleJump;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -301,12 +332,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
WeaponRoot = GetNode<Node3D>("WeaponRoot");
|
||||
WeaponSystem = GetNode<WeaponSystem>("WeaponRoot/WeaponSystem");
|
||||
MantleSystem = GetNode<MantleSystem>("HeadSystem/MantleSystem");
|
||||
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");
|
||||
StandingCollider = GetNode<CollisionShape3D>("StandingCollider");
|
||||
SlideCollider = GetNode<CollisionShape3D>("SlideCollider");
|
||||
DashSystem = GetNode<DashSystem>("DashSystem");
|
||||
StairsSystem = GetNode<StairsSystem>("StairsSystem");
|
||||
WallHugSystem = GetNode<WallHugSystem>("WallHugSystem");
|
||||
WallRunSnapper = GetNode<RayCast3D>("%WallRunSnapper");
|
||||
GroundDetector = GetNode<ShapeCast3D>("GroundDetector");
|
||||
CeilingDetector = GetNode<ShapeCast3D>("CeilingDetector");
|
||||
DirectGroundDetector = GetNode<RayCast3D>("DirectGroundDetector");
|
||||
RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D");
|
||||
RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D");
|
||||
_headCollisionDetectors = new RayCast3D[NUM_OF_HEAD_COLLISION_DETECTORS];
|
||||
@@ -316,7 +350,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
"HeadCollisionDetectors/HeadCollisionDetector" + i);
|
||||
}
|
||||
|
||||
var playerShape = CapsuleCollider.GetShape() as CapsuleShape3D;
|
||||
var playerShape = StandingCollider.GetShape() as CapsuleShape3D;
|
||||
_playerHeight = playerShape!.Height;
|
||||
_playerRadius = playerShape.Radius;
|
||||
|
||||
@@ -326,11 +360,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
_aiming = StateChartState.Of(GetNode("StateChart/Root/Aim/On"));
|
||||
_simpleDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/Dash"));
|
||||
_aimedDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/AimedDash"));
|
||||
_slamming = StateChartState.Of(GetNode("StateChart/Root/Movement/Slamming"));
|
||||
|
||||
_sliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding"));
|
||||
_slideCanceled = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/SlideCanceled"));
|
||||
_groundSliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide"));
|
||||
_airGliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlide"));
|
||||
_slamming = StateChartState.Of(GetNode("StateChart/Root/Movement/Slamming"));
|
||||
_airGlidingDoubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"));
|
||||
_onGroundSlideJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide/OnJump"));
|
||||
_onAirGlideDoubleJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled/OnJump"));
|
||||
|
||||
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||
_powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired"));
|
||||
@@ -341,6 +379,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
||||
// _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
_jumping = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump"));
|
||||
_simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump"));
|
||||
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump"));
|
||||
_mantling = StateChartState.Of(GetNode("StateChart/Root/Movement/Mantling"));
|
||||
@@ -421,8 +460,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
_sliding.StateEntered += SlideStarted;
|
||||
_sliding.StateExited += SlideEnded;
|
||||
_slideCanceled.StateEntered += OnSlideCanceled;
|
||||
_slideCanceled.StatePhysicsProcessing += HandleSlideCanceled;
|
||||
_groundSliding.StatePhysicsProcessing += HandleGroundSlide;
|
||||
_airGliding.StatePhysicsProcessing += HandleAirGlide;
|
||||
_airGlidingDoubleJump.StatePhysicsProcessing += HandleAirGlide;
|
||||
|
||||
_onGroundSlideJump.Taken += JumpFromGroundSlide;
|
||||
_onAirGlideDoubleJump.Taken += JumpFromAirGlide;
|
||||
|
||||
_slamming.StateEntered += SlamStarted;
|
||||
_slamming.StateExited += SlamEnded;
|
||||
@@ -557,9 +602,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
StairsSystem.UpStairsCheckParams upStairsCheckParams = new StairsSystem.UpStairsCheckParams
|
||||
{
|
||||
IsOnFloorCustom = isOnFloorCustom(),
|
||||
IsCapsuleHeightLessThanNormal = CapsuleCollider.IsCapsuleHeightLessThanNormal(),
|
||||
IsCapsuleHeightLessThanNormal = false,
|
||||
CurrentSpeedGreaterThanWalkSpeed = false,
|
||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||
IsCrouchingHeight = false,
|
||||
Delta = delta,
|
||||
FloorMaxAngle = FloorMaxAngle,
|
||||
GlobalPositionFromDriver = GlobalPosition,
|
||||
@@ -569,7 +614,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
};
|
||||
StairsSystem.UpStairsCheckResult upStairsCheckResult = StairsSystem.SnapUpStairsCheck(upStairsCheckParams);
|
||||
|
||||
if (upStairsCheckResult.UpdateRequired)
|
||||
if (upStairsCheckResult.UpdateRequired && !_jumping.Active)
|
||||
{
|
||||
upStairsCheckResult.Update(this);
|
||||
}
|
||||
@@ -580,10 +625,10 @@ public partial class PlayerController : CharacterBody3D
|
||||
StairsSystem.DownStairsCheckParams downStairsCheckParams = new StairsSystem.DownStairsCheckParams
|
||||
{
|
||||
IsOnFloor = IsOnFloor(),
|
||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||
IsCrouchingHeight = false,
|
||||
LastFrameWasOnFloor = _lastFrameWasOnFloor,
|
||||
CapsuleDefaultHeight = CapsuleCollider.GetDefaultHeight(),
|
||||
CurrentCapsuleHeight = CapsuleCollider.GetCurrentHeight(),
|
||||
CapsuleDefaultHeight = _playerHeight,
|
||||
CurrentCapsuleHeight = _playerHeight,
|
||||
FloorMaxAngle = FloorMaxAngle,
|
||||
VelocityY = Velocity.Y,
|
||||
GlobalTransformFromDriver = GlobalTransform,
|
||||
@@ -601,9 +646,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
StairsSystem.SlideCameraParams slideCameraParams = new StairsSystem.SlideCameraParams
|
||||
{
|
||||
IsCapsuleHeightLessThanNormal = CapsuleCollider.IsCapsuleHeightLessThanNormal(),
|
||||
IsCapsuleHeightLessThanNormal = false,
|
||||
CurrentSpeedGreaterThanWalkSpeed = false,
|
||||
BetweenCrouchingAndNormalHeight = CapsuleCollider.IsBetweenCrouchingAndNormalHeight(),
|
||||
BetweenCrouchingAndNormalHeight = false,
|
||||
Delta = delta
|
||||
};
|
||||
StairsSystem.SlideCameraSmoothBackToOrigin(slideCameraParams);
|
||||
@@ -748,7 +793,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
|
||||
var playerVelocity = GetGlobalMoveInput();
|
||||
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, wallHugContactPoint, lookSensitivity);
|
||||
HeadSystem.LookAround(delta, inputLookDir, playerVelocity, Velocity, wallHugContactPoint, lookSensitivity, isSliding: _groundSliding.Active);
|
||||
}
|
||||
public void RotateWeaponWithPlayer()
|
||||
{
|
||||
@@ -763,7 +808,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
Bobbing.CameraBobbingParams cameraBobbingParams = new Bobbing.CameraBobbingParams
|
||||
{
|
||||
Delta = delta,
|
||||
IsOnFloorCustom = isOnFloorCustom() || _onWallRunning.Active,
|
||||
IsOnFloorCustom = _grounded.Active || _onWallRunning.Active,
|
||||
Velocity = Velocity,
|
||||
SettingsMultiplier = _headBobbingMultiplier
|
||||
};
|
||||
@@ -771,7 +816,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
FieldOfView.FovParameters fovParams = new FieldOfView.FovParameters
|
||||
{
|
||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||
IsCrouchingHeight = false,
|
||||
Delta = delta,
|
||||
SprintSpeed = WalkSpeed,
|
||||
Velocity = Velocity,
|
||||
@@ -902,7 +947,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
if (!_canDash)
|
||||
{
|
||||
_playerState.SendEvent("dash_finished");
|
||||
var dashEvent = isOnFloorCustom() ? "grounded" : "dash_finished";
|
||||
_playerState.SendEvent(dashEvent);
|
||||
return;
|
||||
}
|
||||
_canDash = false;
|
||||
@@ -920,7 +966,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void SimpleDashFinished()
|
||||
{
|
||||
_playerState.SendEvent("dash_finished");
|
||||
var dashEvent = isOnFloorCustom() ? "grounded" : "dash_finished";
|
||||
_playerState.SendEvent(dashEvent);
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
@@ -1063,11 +1110,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
_playerState.SendEvent("jump");
|
||||
}
|
||||
|
||||
|
||||
private float _jumpStrengthMultiplier = 1.0f;
|
||||
public void OnJumpStarted(float verticalVelocity)
|
||||
{
|
||||
_framesSinceJumpAtApex = 0;
|
||||
SetVerticalVelocity(verticalVelocity);
|
||||
var angle = GetFloorAngle();
|
||||
var floorAngleFactor = angle > 1 ? 1 : 1 + angle;
|
||||
SetVerticalVelocity(verticalVelocity*_jumpStrengthMultiplier*floorAngleFactor);
|
||||
_jumpStrengthMultiplier = 1.0f;
|
||||
}
|
||||
public void OnSimpleJumpStarted()
|
||||
{
|
||||
@@ -1201,7 +1252,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
var positionDifference = GlobalPosition - _mantleStartPosition;
|
||||
var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z);
|
||||
// SimpleDashInDirection(directionHorizontal.Normalized());
|
||||
SetVelocity(directionHorizontal.Normalized() * WalkSpeed);
|
||||
SetVelocity(directionHorizontal.Normalized() * _velocityOnMantleStarted.Length());
|
||||
}
|
||||
|
||||
_customMantle = false;
|
||||
@@ -1211,55 +1262,194 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
// Slide management //
|
||||
///////////////////////////
|
||||
|
||||
private bool _isSlideInputDown = false;
|
||||
public void OnInputSlideStarted()
|
||||
{
|
||||
_playerState.SendEvent("slide");
|
||||
_isSlideInputDown = true;
|
||||
if (Velocity.Length() > WalkSpeed/2f)
|
||||
_playerState.SendEvent("slide");
|
||||
}
|
||||
public void OnInputSlideEnded()
|
||||
{
|
||||
_playerState.SendEvent("slide_released");
|
||||
_isSlideInputDown = false;
|
||||
if (_airGliding.Active || CanStandUpFromSlide())
|
||||
_playerState.SendEvent("slide_released");
|
||||
}
|
||||
|
||||
public record SlopeRecord(
|
||||
Vector3 Position,
|
||||
Vector3 Normal,
|
||||
Vector3 Direction,
|
||||
float AngleRadians
|
||||
);
|
||||
public Vector3 GetGroundPosition()
|
||||
{
|
||||
return DirectGroundDetector.GetCollisionPoint();
|
||||
}
|
||||
public Vector3 GetGroundNormal()
|
||||
{
|
||||
return DirectGroundDetector.GetCollisionNormal();
|
||||
}
|
||||
public SlopeRecord GetSlope()
|
||||
{
|
||||
var position = GetGroundPosition();
|
||||
var normal = GetGroundNormal();
|
||||
var angle = normal.AngleTo(Vector3.Up);
|
||||
var vectorInPlane = normal.Cross(Vector3.Up).Normalized();
|
||||
var direction = normal.Cross(vectorInPlane).Normalized();
|
||||
return new SlopeRecord(position, normal, direction, angle);
|
||||
}
|
||||
|
||||
public void SetupSlideCollision()
|
||||
{
|
||||
StandingCollider.Disabled = true;
|
||||
SlideCollider.Disabled = false;
|
||||
CeilingDetector.Enabled = true;
|
||||
}
|
||||
|
||||
public void SetupStandingCollision()
|
||||
{
|
||||
StandingCollider.Disabled = false;
|
||||
SlideCollider.Disabled = true;
|
||||
CeilingDetector.Enabled = false;
|
||||
}
|
||||
public void SlideStarted()
|
||||
{
|
||||
_targetSpeed = Velocity.Length();
|
||||
SetupSlideCollision();
|
||||
}
|
||||
|
||||
public bool CanStandUpFromSlide()
|
||||
{
|
||||
return !CeilingDetector.IsColliding();
|
||||
}
|
||||
|
||||
public bool CanCancelSlide()
|
||||
{
|
||||
return DirectGroundDetector.IsColliding()
|
||||
&& Velocity.Length() < WalkSpeed / 2f
|
||||
&& CanStandUpFromSlide();
|
||||
}
|
||||
public void SlideOnGround(float delta)
|
||||
{
|
||||
// Store current velocity
|
||||
var currentVelocity = Velocity.Length();
|
||||
// We prevent automatically losing speed when sliding under something
|
||||
var speedLossRate = CanStandUpFromSlide() ? FlatGroundSlideSpeedLossRate : 1.0f;
|
||||
// We force a minimum of speed when sliding under something
|
||||
var minimumVelocity = CanStandUpFromSlide() ? 0f : WalkSpeed;
|
||||
var finalSpeed = Mathf.Max(currentVelocity * speedLossRate, minimumVelocity);
|
||||
|
||||
// Going down a slope?
|
||||
var (position, _, slopeDirection, slopeAngleRadians) = GetSlope();
|
||||
|
||||
// Change velocity based on Input
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationGroundSlide, DecelerationGroundSlide);
|
||||
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z);
|
||||
var newVelocityDirection = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z).Normalized();
|
||||
var newVelocityHDirection = new Vector3(horizontalVelocity.X, 0, horizontalVelocity.Z).Normalized();
|
||||
// var redirectedVelocity = newVelocityDirection.Slide(normal);
|
||||
|
||||
var redirectedVelocity = newVelocityDirection;
|
||||
if (slopeAngleRadians > Mathf.Epsilon)
|
||||
{
|
||||
var slopeHDirection = new Vector3(slopeDirection.X, 0, slopeDirection.Z);
|
||||
redirectedVelocity = newVelocityDirection.Lerp(slopeHDirection, delta * GroundSlideSlopeMagnetism);
|
||||
|
||||
var angleBetweenVelocityAndSlope = newVelocityHDirection.AngleTo(slopeHDirection);
|
||||
var velocitySlopeAlignment = Mathf.Cos(angleBetweenVelocityAndSlope);
|
||||
var slopeSpeedFactor = Mathf.Remap(velocitySlopeAlignment, -1, 1, 0.98, 1.02);
|
||||
var speedFactorFromDownSlope = Velocity.Length() > GroundSlideDownSlopeMaxSpeed ? 1f : slopeSpeedFactor;
|
||||
finalSpeed *= (float) speedFactorFromDownSlope;
|
||||
|
||||
// var redirectedVVelocity = slopeDirection.Y * velocitySlopeAlignment;
|
||||
// redirectedVelocity = new Vector3(redirectedVelocity.X, redirectedVVelocity, redirectedVelocity.Z);
|
||||
|
||||
// Moving upslope and not enough speed
|
||||
if (velocitySlopeAlignment < 0 && CanCancelSlide())
|
||||
_playerState.SendEvent("slide_canceled");
|
||||
}
|
||||
else if (CanCancelSlide())
|
||||
{
|
||||
// Moving on flat ground and not enough speed
|
||||
_playerState.SendEvent("slide_canceled");
|
||||
}
|
||||
|
||||
// Preserve velocity when changing direction
|
||||
var finalVelocity = redirectedVelocity.Normalized() * finalSpeed;
|
||||
Velocity = finalVelocity;
|
||||
if (DirectGroundDetector.IsColliding())
|
||||
{
|
||||
GlobalPosition = new Vector3(GlobalPosition.X, position.Y, GlobalPosition.Z);
|
||||
}
|
||||
}
|
||||
public void OnSlideCanceled()
|
||||
{
|
||||
SetupStandingCollision();
|
||||
_targetSpeed = WalkSpeed;
|
||||
}
|
||||
public void HandleSlideCanceled(float delta)
|
||||
{
|
||||
HandleGrounded(delta);
|
||||
}
|
||||
public void HandleGroundSlide(float delta)
|
||||
{
|
||||
SlideOnGround(delta);
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (!isOnFloorCustom())
|
||||
_playerState.SendEvent("start_falling");
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
if (!isOnFloorCustom() && !DirectGroundDetector.IsColliding()) _playerState.SendEvent("start_falling");
|
||||
if (CanStandUpFromSlide() && !_isSlideInputDown) _playerState.SendEvent("slide_released");
|
||||
}
|
||||
|
||||
public void GlideInAir(float delta)
|
||||
{
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
|
||||
|
||||
float verticalSpeed;
|
||||
if (Velocity.Y < -AirGlideVSpeed) verticalSpeed = -AirGlideVSpeed;
|
||||
else if (Velocity.Y > 0) verticalSpeed = ComputeVerticalSpeedGravity(delta);
|
||||
else verticalSpeed = Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta);
|
||||
|
||||
Velocity = new Vector3(horizontalVelocity.X, verticalSpeed, horizontalVelocity.Z);
|
||||
if (AllowForVelocityRedirection)
|
||||
{
|
||||
// Preserve overall velocity
|
||||
// Allows for tragic reorientation of the velocity vector after a fall
|
||||
// Allows for bunny-hoping-like movement
|
||||
var currentVelocity = Velocity.Length();
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
|
||||
var verticalSpeed = Velocity.Y > 0 ? ComputeVerticalSpeedGravity(delta) : Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta*AirGlideVerticalAcceleration);
|
||||
var newVelocity = new Vector3(horizontalVelocity.X, verticalSpeed, horizontalVelocity.Z);
|
||||
Velocity = newVelocity.Normalized() * currentVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Preserve horizontal velocity only
|
||||
// Allows for mor stable descent when gliding because you don't zoom away after a long fall
|
||||
// Removes bunny-hoping-like movement by simply holding slide and jump jump jump
|
||||
var currentHVelocity = new Vector2(Velocity.X, Velocity.Z).Length();
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
|
||||
var newHVelocity = horizontalVelocity.Normalized() * currentHVelocity;
|
||||
var verticalSpeed = Velocity.Y > 0 ? ComputeVerticalSpeedGravity(delta) : Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta*AirGlideVerticalAcceleration);
|
||||
var newVelocity = new Vector3(newHVelocity.X, verticalSpeed, newHVelocity.Z);
|
||||
Velocity = newVelocity;
|
||||
}
|
||||
}
|
||||
public void HandleAirGlide(float delta)
|
||||
{
|
||||
GlideInAir(delta);
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
public void SlideEnded()
|
||||
{
|
||||
SetupStandingCollision();
|
||||
_targetSpeed = WalkSpeed;
|
||||
}
|
||||
|
||||
public void JumpFromGroundSlide()
|
||||
{
|
||||
_jumpStrengthMultiplier = GroundSlideJumpMultiplier + Velocity.Length()*GroundSlideJumpSpeedFactor;
|
||||
}
|
||||
|
||||
public void JumpFromAirGlide()
|
||||
{
|
||||
_jumpStrengthMultiplier = AirGlideJumpMultiplier + Velocity.Length()*AirGlideJumpSpeedFactor;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Slam Management ///////
|
||||
@@ -1427,7 +1617,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
public void AimedDashTweenEnded()
|
||||
{
|
||||
_playerState.SendEvent("dash_finished");
|
||||
var dashEvent = isOnFloorCustom() ? "grounded" : "dash_finished";
|
||||
_playerState.SendEvent(dashEvent);
|
||||
}
|
||||
public void OnAimedDashFinished()
|
||||
{
|
||||
@@ -1521,14 +1712,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
CameraModifications((float) delta);
|
||||
MoveSlideAndHandleStairs((float) delta);
|
||||
MantleSystem.ProcessMantle(_grounded.Active);
|
||||
|
||||
if (WeaponSystem.InHandState.Active)
|
||||
RotateWeaponWithPlayer();
|
||||
|
||||
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
|
||||
{
|
||||
DashIndicatorMesh.Visible = false;
|
||||
}
|
||||
|
||||
if (!WeaponSystem.InHandState.Active && TutorialDone)
|
||||
{
|
||||
DashIndicatorMesh.Visible = true;
|
||||
@@ -1537,6 +1727,4 @@ public partial class PlayerController : CharacterBody3D
|
||||
DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,12 +22,26 @@ public partial class HeadSystem : Node3D
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float GroundedCameraIncline { get; set; } = 5f;
|
||||
|
||||
[Export(PropertyHint.Range, "0,2,0.1,or_greater")]
|
||||
public float SlidingCameraHeightOffset { get; set; } = 1.0f;
|
||||
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float SlidingJitterFrequency { get; set; } = 0.01f;
|
||||
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float SlidingJitterAmplitude { get; set; } = 0.1f;
|
||||
|
||||
private FastNoiseLite _slidingNoise = new FastNoiseLite();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Input.SetMouseMode(Input.MouseModeEnum.Captured);
|
||||
_camera = GetNode<Camera3D>("CameraSmooth/Camera3D");
|
||||
_cameraAnchor = GetNode<Marker3D>("CameraAnchor");
|
||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
|
||||
_slidingNoise.NoiseType = FastNoiseLite.NoiseTypeEnum.Perlin;
|
||||
_slidingNoise.SetFrequency(SlidingJitterFrequency);
|
||||
}
|
||||
|
||||
public void OnMantle()
|
||||
@@ -35,7 +49,7 @@ public partial class HeadSystem : Node3D
|
||||
_animationPlayer.Play("mantle");
|
||||
}
|
||||
|
||||
public void LookAround(double delta, Vector2 lookDir, Vector3 playerVelocity, Vector3? wallContactPoint = null, float sensitivitMultiplier = 1f)
|
||||
public void LookAround(double delta, Vector2 lookDir, Vector3 playerInput, Vector3 playerVelocity, Vector3? wallContactPoint = null, float sensitivitMultiplier = 1f, bool isSliding = false)
|
||||
{
|
||||
// Horizontal movement of head
|
||||
float angleForHorizontalRotation = lookDir.X * LookSensitivity * sensitivitMultiplier;
|
||||
@@ -46,8 +60,9 @@ public partial class HeadSystem : Node3D
|
||||
currentCameraRotation.X += Convert.ToSingle(lookDir.Y * LookSensitivity * sensitivitMultiplier);
|
||||
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
|
||||
|
||||
// Camera incline on Wall and more
|
||||
var isWallRunning = wallContactPoint.HasValue && wallContactPoint.Value.Length() > Mathf.Epsilon;
|
||||
var cameraIncline = 0f;
|
||||
float cameraIncline;
|
||||
if (isWallRunning)
|
||||
{
|
||||
var directionToWall = (wallContactPoint.Value - GlobalPosition).Normalized();
|
||||
@@ -56,11 +71,23 @@ public partial class HeadSystem : Node3D
|
||||
}
|
||||
else
|
||||
{
|
||||
var cameraInclineFactor = ComputeCameraInclineFactor(playerVelocity);
|
||||
var cameraInclineFactor = ComputeCameraInclineFactor(playerInput);
|
||||
cameraIncline = Mathf.DegToRad(GroundedCameraIncline * cameraInclineFactor * -1.0f);
|
||||
}
|
||||
currentCameraRotation.Z = (float) Mathf.Lerp(currentCameraRotation.Z, cameraIncline, delta * CameraInclineAcceleration);
|
||||
_cameraAnchor.Rotation = currentCameraRotation;
|
||||
|
||||
if (isSliding)
|
||||
{
|
||||
_cameraAnchor.Position = Vector3.Down*SlidingCameraHeightOffset;
|
||||
float noise1D = _slidingNoise.GetNoise1D(Time.GetTicksMsec());
|
||||
float noiseAmplitude = SlidingJitterAmplitude*Mathf.Clamp(playerVelocity.Length(), 0f, 1f);
|
||||
_cameraAnchor.Position += Vector3.Up*noise1D*noiseAmplitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cameraAnchor.Position = Vector3.Zero;
|
||||
}
|
||||
|
||||
_camera.GlobalTransform = _cameraAnchor.GetGlobalTransformInterpolated();
|
||||
}
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
using Godot;
|
||||
using Movementtests.player_controller.Scripts;
|
||||
using RustyOptions;
|
||||
|
||||
namespace Movementtests.systems;
|
||||
|
||||
public partial class MoveSystem : Node3D
|
||||
{
|
||||
public enum JumpTypes
|
||||
{
|
||||
SimpleJump,
|
||||
DoubleJump,
|
||||
JumpFromDash,
|
||||
JumpFromWall
|
||||
}
|
||||
|
||||
public record MoveSystemParameters(
|
||||
CharacterBody3D Parent,
|
||||
Gravity Gravity,
|
||||
MantleSystem MantleSystem,
|
||||
TweenQueueSystem TweenQueueSystem,
|
||||
HeadSystem HeadSystem,
|
||||
CapsuleCollider CapsuleCollider);
|
||||
|
||||
public record MoveAroundParameters(
|
||||
double Delta,
|
||||
Vector3 MovementDirection,
|
||||
bool IsOnFloor,
|
||||
bool IsDead,
|
||||
bool IsHeadTouchingCeiling,
|
||||
bool isHanging,
|
||||
bool isWallHugging
|
||||
);
|
||||
|
||||
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
||||
public float WalkSpeed { get; set; } = 5.0f;
|
||||
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
||||
public float SprintSpeed { get; set; } = 7.2f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float CrouchSpeed { get; set; } = 2.5f;
|
||||
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
|
||||
|
||||
public float _currentSpeed;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float AccelerationSpeedFactorFloor = 5.0f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float DecelerationSpeedFactorFloor = 5.0f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float DecelerationSpeedFactorAir = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float ApexHoldTime = 0.0f;
|
||||
private float _timeLeftAtApex = 0.0f;
|
||||
private bool _wasGoingUpLastFrame = false;
|
||||
|
||||
public float CrouchTransitionSpeed { get; set; } = 20.0f;
|
||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||
public float WallHugGravityReducingFactor { get; set; } = 0.1f;
|
||||
|
||||
|
||||
private Gravity _gravity;
|
||||
private CharacterBody3D _parent;
|
||||
private MantleSystem _mantleSystem;
|
||||
private TweenQueueSystem _tweenQueueSystem;
|
||||
private CapsuleCollider _capsuleCollider;
|
||||
private HeadSystem _headSystem;
|
||||
public void Init(MoveSystemParameters parameters)
|
||||
{
|
||||
_parent = parameters.Parent;
|
||||
_gravity = parameters.Gravity;
|
||||
_mantleSystem = parameters.MantleSystem;
|
||||
_tweenQueueSystem = parameters.TweenQueueSystem;
|
||||
_capsuleCollider = parameters.CapsuleCollider;
|
||||
_headSystem = parameters.HeadSystem;
|
||||
|
||||
_currentSpeed = WalkSpeed;
|
||||
}
|
||||
|
||||
private bool IsGoingUp()
|
||||
{
|
||||
return _parent.Velocity.Y > 0;
|
||||
}
|
||||
|
||||
public void MoveAround(MoveAroundParameters param)
|
||||
{
|
||||
var (delta, movementDirection, isOnFloor, isDead, isHeadTouchingCeiling, isHanging, isWallHugging) = param;
|
||||
|
||||
var doesCapsuleHaveCrouchingHeight = _capsuleCollider.IsCrouchingHeight();
|
||||
var doesCapsuleHaveDefaultHeight = _capsuleCollider.IsDefaultHeight();
|
||||
|
||||
if (IsGoingUp() || isOnFloor)
|
||||
{
|
||||
_wasGoingUpLastFrame = true;
|
||||
_timeLeftAtApex = ApexHoldTime;
|
||||
}
|
||||
|
||||
if (isHanging)
|
||||
{
|
||||
_parent.Velocity = Vector3.Zero;
|
||||
_parent.MoveAndSlide();
|
||||
return;
|
||||
}
|
||||
if (isWallHugging)
|
||||
{
|
||||
_parent.Velocity = new Vector3(
|
||||
x: _parent.Velocity.X,
|
||||
y: _parent.Velocity.Y - _gravity.CalculateGravityForce() * (float)delta * WallHugGravityReducingFactor,
|
||||
z: _parent.Velocity.Z);
|
||||
return;
|
||||
}
|
||||
|
||||
// Adding the gravity
|
||||
if (!isOnFloor)
|
||||
{
|
||||
if (!IsGoingUp() && _wasGoingUpLastFrame && _timeLeftAtApex > 0)
|
||||
{
|
||||
_parent.Velocity = new Vector3(
|
||||
x: _parent.Velocity.X,
|
||||
y: 0,
|
||||
z: _parent.Velocity.Z);
|
||||
_timeLeftAtApex -= (float) delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
_parent.Velocity = new Vector3(
|
||||
x: _parent.Velocity.X,
|
||||
y: _parent.Velocity.Y - (_gravity.CalculateGravityForce() * (float)delta),
|
||||
z: _parent.Velocity.Z);
|
||||
}
|
||||
}
|
||||
|
||||
// The code below is required to quickly adjust player's position on Y-axis when there's a ceiling on the
|
||||
// trajectory of player's jump and player is standing
|
||||
if (isHeadTouchingCeiling && doesCapsuleHaveDefaultHeight)
|
||||
{
|
||||
_parent.Velocity = new Vector3(
|
||||
x: _parent.Velocity.X,
|
||||
y: _parent.Velocity.Y - 2.0f,
|
||||
z: _parent.Velocity.Z);
|
||||
}
|
||||
|
||||
if (!isDead)
|
||||
{
|
||||
|
||||
// Used both for detecting the moment when we enter into crouching mode and the moment when we're already
|
||||
// in the crouching mode
|
||||
if (Input.IsActionPressed("crouch") ||
|
||||
(doesCapsuleHaveCrouchingHeight && isHeadTouchingCeiling))
|
||||
{
|
||||
_capsuleCollider.Crouch((float)delta, CrouchTransitionSpeed);
|
||||
_currentSpeed = CrouchSpeed;
|
||||
}
|
||||
// Used both for the moment when we exit the crouching mode and for the moment when we just walk
|
||||
else
|
||||
{
|
||||
_capsuleCollider.UndoCrouching((float)delta, CrouchTransitionSpeed);
|
||||
_currentSpeed = WalkSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
// Each component of the boolean statement for sprinting is required
|
||||
if (Input.IsActionPressed("sprint") && !isHeadTouchingCeiling &&
|
||||
!doesCapsuleHaveCrouchingHeight && !isDead)
|
||||
{
|
||||
_currentSpeed = SprintSpeed;
|
||||
}
|
||||
|
||||
// Basis is a 3x4 matrix. It contains information about scaling and rotation of head.
|
||||
// By multiplying our Vector3 by this matrix we're doing multiple things:
|
||||
// a) We start to operate in global space;
|
||||
// b) We're applying to Vector3 the current rotation of "head" object;
|
||||
// c) We're applying to Vector3 the current scaling of "head" object;
|
||||
Vector3 direction = _headSystem.Transform.Basis * movementDirection;
|
||||
|
||||
if (isDead)
|
||||
{
|
||||
direction = Vector3.Zero;
|
||||
}
|
||||
|
||||
var accelerationFloorFactor = direction.Length() > 0 ? AccelerationSpeedFactorFloor : DecelerationSpeedFactorFloor;
|
||||
var accelerationFactor = isOnFloor ? accelerationFloorFactor : DecelerationSpeedFactorAir;
|
||||
|
||||
float xAcceleration = Mathf.Lerp(_parent.Velocity.X, direction.X * _currentSpeed,
|
||||
(float)delta * accelerationFactor);
|
||||
float zAcceleration = Mathf.Lerp(_parent.Velocity.Z, direction.Z * _currentSpeed,
|
||||
(float)delta * accelerationFactor);
|
||||
_parent.Velocity = new Vector3(xAcceleration, _parent.Velocity.Y, zAcceleration);
|
||||
|
||||
if (isDead)
|
||||
{
|
||||
_parent.MoveAndSlide();
|
||||
}
|
||||
}
|
||||
|
||||
public void Jump(JumpTypes jumpType, Vector3? jumpDirection = null, float boost = 1.0f)
|
||||
{
|
||||
var effectiveJumpDirection = jumpDirection ?? Vector3.Up;
|
||||
var jumpForce = 0.0f;
|
||||
switch (jumpType)
|
||||
{
|
||||
case JumpTypes.DoubleJump:
|
||||
jumpForce = _gravity.CalculateDoubleJumpForce();
|
||||
break;
|
||||
case JumpTypes.SimpleJump:
|
||||
jumpForce = _gravity.CalculateJumpForce();
|
||||
break;
|
||||
case JumpTypes.JumpFromDash:
|
||||
jumpForce = _gravity.CalculateJumpFromDashForce();
|
||||
break;
|
||||
case JumpTypes.JumpFromWall:
|
||||
jumpForce = _gravity.CalculateJumpFromWallForce();
|
||||
break;
|
||||
default:
|
||||
jumpForce = _gravity.CalculateJumpForce();
|
||||
break;
|
||||
}
|
||||
|
||||
var currentHorizontalVelocity = new Vector3(_parent.Velocity.X, 0, _parent.Velocity.Z);
|
||||
var jumpVelocity = jumpForce * effectiveJumpDirection * boost;
|
||||
_parent.Velocity = currentHorizontalVelocity + jumpVelocity;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://dyy5njw6pxoh4
|
||||
@@ -1,5 +0,0 @@
|
||||
[gd_resource type="Curve" format=3 uid="uid://buxwd3wd0nln5"]
|
||||
|
||||
[resource]
|
||||
_data = [Vector2(0, 0), 0.0, 3.01651, 0, 0, Vector2(0.996169, 1), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
@@ -40,7 +40,7 @@ public partial class WallHugSystem : Node3D
|
||||
{
|
||||
foreach (RayCast3D raycast in _raycasts)
|
||||
{
|
||||
if (raycast.IsColliding())
|
||||
if (raycast.IsColliding() && Math.Abs(raycast.GetCollisionNormal().Y) < 0.3f)
|
||||
{
|
||||
WallHugLocation = raycast.GetCollisionPoint().Some();
|
||||
WallHugNormal = raycast.GetCollisionNormal().Some();
|
||||
|
||||
Reference in New Issue
Block a user