gd,fix: player won't go through thin platforms from underneath, added a small cooldown to dash actions, remapped inputs a bit for gamefeel
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=35 format=3 uid="uid://bei4nhkf8lwdo"]
|
[gd_scene load_steps=36 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="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
[ext_resource type="Resource" uid="uid://dgfww8118d8gj" path="res://systems/inputs/base_mode/aim.tres" id="7_cresl"]
|
[ext_resource type="Resource" uid="uid://dgfww8118d8gj" path="res://systems/inputs/base_mode/aim.tres" id="7_cresl"]
|
||||||
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="8_lhb11"]
|
[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="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="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="8_qu4wy"]
|
||||||
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="9_5p2qc"]
|
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="9_5p2qc"]
|
||||||
[ext_resource type="Script" uid="uid://bt0xv2q8iv1vn" path="res://player_controller/Scripts/Gravity.cs" id="9_lsueh"]
|
[ext_resource type="Script" uid="uid://bt0xv2q8iv1vn" path="res://player_controller/Scripts/Gravity.cs" id="9_lsueh"]
|
||||||
@ -19,6 +20,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://0ysqmqphq6mq" path="res://systems/head/head_system.tscn" id="11_rxwoh"]
|
[ext_resource type="PackedScene" uid="uid://0ysqmqphq6mq" path="res://systems/head/head_system.tscn" id="11_rxwoh"]
|
||||||
[ext_resource type="Resource" uid="uid://d2r0ur8k3cuu3" path="res://systems/inputs/base_mode/drop.tres" id="12_34snm"]
|
[ext_resource type="Resource" uid="uid://d2r0ur8k3cuu3" path="res://systems/inputs/base_mode/drop.tres" id="12_34snm"]
|
||||||
[ext_resource type="Script" uid="uid://b6k73aj5povgv" path="res://player_controller/Scripts/FieldOfView.cs" id="12_m2mxi"]
|
[ext_resource type="Script" uid="uid://b6k73aj5povgv" path="res://player_controller/Scripts/FieldOfView.cs" id="12_m2mxi"]
|
||||||
|
[ext_resource type="Shape3D" uid="uid://keseacdcooot" path="res://player_controller/resources/PlayerShape.tres" id="13_r7i3q"]
|
||||||
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
|
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
|
||||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="17_h6vvl"]
|
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="17_h6vvl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cqduhd4opgwvm" path="res://systems/dash/dash_system.tscn" id="18_q5h8a"]
|
[ext_resource type="PackedScene" uid="uid://cqduhd4opgwvm" path="res://systems/dash/dash_system.tscn" id="18_q5h8a"]
|
||||||
@ -36,9 +38,6 @@
|
|||||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
|
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
|
||||||
height = 1.7
|
height = 1.7
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_wydro"]
|
|
||||||
height = 1.7
|
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
script = ExtResource("1_poq2x")
|
script = ExtResource("1_poq2x")
|
||||||
TimeScaleAimInAir = 0.15
|
TimeScaleAimInAir = 0.15
|
||||||
@ -52,6 +51,7 @@ move = ExtResource("17_h6vvl")
|
|||||||
rotate_y = ExtResource("4_rxwoh")
|
rotate_y = ExtResource("4_rxwoh")
|
||||||
rotate_floorplane = ExtResource("5_4u7i3")
|
rotate_floorplane = ExtResource("5_4u7i3")
|
||||||
aim_pressed = ExtResource("7_cresl")
|
aim_pressed = ExtResource("7_cresl")
|
||||||
|
aim_down = ExtResource("8_obsfv")
|
||||||
aim_released = ExtResource("8_lhb11")
|
aim_released = ExtResource("8_lhb11")
|
||||||
aim_canceled = ExtResource("9_5p2qc")
|
aim_canceled = ExtResource("9_5p2qc")
|
||||||
jump = ExtResource("10_4u7i3")
|
jump = ExtResource("10_4u7i3")
|
||||||
@ -65,7 +65,7 @@ mesh = SubResource("CapsuleMesh_xc2g5")
|
|||||||
|
|
||||||
[node name="CapsuleCollider" type="CollisionShape3D" parent="."]
|
[node name="CapsuleCollider" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||||
shape = SubResource("CapsuleShape3D_wydro")
|
shape = ExtResource("13_r7i3q")
|
||||||
script = ExtResource("8_lmtjd")
|
script = ExtResource("8_lmtjd")
|
||||||
CapsuleDefaultHeight = 1.7
|
CapsuleDefaultHeight = 1.7
|
||||||
|
|
||||||
@ -167,6 +167,10 @@ StraightThrowDuration = 0.05
|
|||||||
wait_time = 0.2
|
wait_time = 0.2
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="DashCooldown" type="Timer" parent="."]
|
||||||
|
wait_time = 0.2
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[node name="TimeScaleAimInAir" type="Timer" parent="."]
|
[node name="TimeScaleAimInAir" type="Timer" parent="."]
|
||||||
wait_time = 2.0
|
wait_time = 2.0
|
||||||
one_shot = true
|
one_shot = true
|
||||||
@ -181,7 +185,6 @@ offset_left = 1530.0
|
|||||||
offset_top = 1.0
|
offset_top = 1.0
|
||||||
offset_right = -2.0
|
offset_right = -2.0
|
||||||
offset_bottom = 1.0
|
offset_bottom = 1.0
|
||||||
enabled = false
|
|
||||||
initial_node_to_watch = NodePath("../StateChart")
|
initial_node_to_watch = NodePath("../StateChart")
|
||||||
|
|
||||||
[node name="StateChart" type="Node" parent="."]
|
[node name="StateChart" type="Node" parent="."]
|
||||||
@ -202,7 +205,7 @@ script = ExtResource("27_34snm")
|
|||||||
[node name="ToAiming" type="Node" parent="StateChart/Root/Actions/WeaponInHand"]
|
[node name="ToAiming" type="Node" parent="StateChart/Root/Actions/WeaponInHand"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Aiming")
|
to = NodePath("../../Aiming")
|
||||||
event = &"aim_pressed"
|
event = &"aim_down"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Aiming" type="Node" parent="StateChart/Root/Actions"]
|
[node name="Aiming" type="Node" parent="StateChart/Root/Actions"]
|
||||||
@ -461,6 +464,7 @@ event = &"enable_double_jump"
|
|||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||||
|
[connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"]
|
||||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||||
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
||||||
[connection signal="input_drop" from="InputController" to="." method="OnInputDropPressed"]
|
[connection signal="input_drop" from="InputController" to="." method="OnInputDropPressed"]
|
||||||
|
@ -39,9 +39,12 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private float _inputRotateY;
|
private float _inputRotateY;
|
||||||
private float _inputRotateFloorplane;
|
private float _inputRotateFloorplane;
|
||||||
|
|
||||||
|
// Timers
|
||||||
private Timer _coyoteTimer;
|
private Timer _coyoteTimer;
|
||||||
private Timer _timeScaleAimInAirTimer;
|
private Timer _timeScaleAimInAirTimer;
|
||||||
private Timer _timeAfterDashingTimer;
|
private Timer _timeAfterDashingTimer;
|
||||||
|
private Timer _dashCooldownTimer;
|
||||||
|
|
||||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
public float TimeScaleAimInAir { get; set; } = 0.2f;
|
public float TimeScaleAimInAir { get; set; } = 0.2f;
|
||||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||||
@ -139,6 +142,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
||||||
// State timers
|
// State timers
|
||||||
_coyoteTimer = GetNode<Timer>("CoyoteTime");
|
_coyoteTimer = GetNode<Timer>("CoyoteTime");
|
||||||
|
_dashCooldownTimer = GetNode<Timer>("DashCooldown");
|
||||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||||
_timeAfterDashingTimer = GetNode<Timer>("TimeAfterDashing");
|
_timeAfterDashingTimer = GetNode<Timer>("TimeAfterDashing");
|
||||||
|
|
||||||
@ -229,8 +233,13 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void OnInputAimPressed()
|
public void OnInputAimPressed()
|
||||||
{
|
{
|
||||||
|
GD.Print("InputAimPressed");
|
||||||
_playerState.SendEvent("aim_pressed");
|
_playerState.SendEvent("aim_pressed");
|
||||||
}
|
}
|
||||||
|
public void OnInputAimDown()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("aim_down");
|
||||||
|
}
|
||||||
public void OnInputAimReleased()
|
public void OnInputAimReleased()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("aim_released");
|
_playerState.SendEvent("aim_released");
|
||||||
@ -267,18 +276,17 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
public void OnGrounded()
|
public void OnGrounded()
|
||||||
{
|
{
|
||||||
DashActionsLeft = MaxNumberOfDashActions;
|
DashActionsLeft = MaxNumberOfDashActions;
|
||||||
GD.Print(DashActionsLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPerformDashAction()
|
public bool CanPerformDashAction()
|
||||||
{
|
{
|
||||||
return DashActionsLeft > 0;
|
return DashActionsLeft > 0 && _dashCooldownTimer.IsStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PerformDashAction()
|
public void PerformDashAction()
|
||||||
{
|
{
|
||||||
|
_dashCooldownTimer.Start();
|
||||||
DashActionsLeft--;
|
DashActionsLeft--;
|
||||||
GD.Print(DashActionsLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jumping
|
// Jumping
|
||||||
@ -376,7 +384,9 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
else if (WeaponSystem.PlantedState.Active)
|
else if (WeaponSystem.PlantedState.Active)
|
||||||
{
|
{
|
||||||
// Should we try to resolve with mantle?
|
// Should we try to resolve with mantle?
|
||||||
DashSystem.DashResolve = new DashResolveRecord(false, WeaponSystem.PlayerDashLocation, Vector3.Zero);
|
var dashLocation =
|
||||||
|
DashSystem.ComputeDashLocationForPlayerShape(WeaponSystem.PlantLocation, WeaponSystem.PlantNormal);
|
||||||
|
DashSystem.DashResolve = new DashResolveRecord(false, dashLocation, Vector3.Zero);
|
||||||
}
|
}
|
||||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||||
DashSystem.Dash();
|
DashSystem.Dash();
|
||||||
@ -393,9 +403,9 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
GD.Print(WeaponSystem.GlobalRotation);
|
GD.Print(WeaponSystem.GlobalRotation);
|
||||||
// Store the weapon state before resetting it
|
// Store the weapon state before resetting it
|
||||||
var isPlantedOnWall = Math.Abs(WeaponSystem.GlobalRotation.X) + Math.Abs(WeaponSystem.GlobalRotation.Z) < 0.3;
|
var isPlantedOnWall = WeaponSystem.IsPlantedInWall();
|
||||||
var isPlantedUnderPlatform = WeaponSystem.GlobalRotation.X > 1 && Math.Abs(WeaponSystem.GlobalRotation.Y) > 1;
|
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
||||||
var shouldDashToPlanted = WeaponSystem.PlantedState.Active && (isPlantedOnWall || isPlantedUnderPlatform);
|
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
||||||
var isFlying = WeaponSystem.FlyingState.Active;
|
var isFlying = WeaponSystem.FlyingState.Active;
|
||||||
|
|
||||||
// Get the weapon back
|
// Get the weapon back
|
||||||
@ -412,7 +422,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
return; // In case states aren't exclusives
|
return; // In case states aren't exclusives
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldDashToPlanted)
|
if (shouldDashToHanging)
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("dash_to_planted");
|
_playerState.SendEvent("dash_to_planted");
|
||||||
return; // In case states aren't exclusives
|
return; // In case states aren't exclusives
|
||||||
|
4
player_controller/resources/PlayerShape.tres
Normal file
4
player_controller/resources/PlayerShape.tres
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[gd_resource type="CapsuleShape3D" format=3 uid="uid://keseacdcooot"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
height = 1.7
|
@ -15,6 +15,7 @@ public partial class DashSystem: Node3D
|
|||||||
|
|
||||||
private Node3D _head;
|
private Node3D _head;
|
||||||
private ShapeCast3D _dashCast3D;
|
private ShapeCast3D _dashCast3D;
|
||||||
|
private ShapeCast3D _playerCast3D;
|
||||||
private Camera3D _camera;
|
private Camera3D _camera;
|
||||||
private TweenQueueSystem _tweenQueueSystem;
|
private TweenQueueSystem _tweenQueueSystem;
|
||||||
private Vector3 _dashDirection = Vector3.Zero;
|
private Vector3 _dashDirection = Vector3.Zero;
|
||||||
@ -34,6 +35,8 @@ public partial class DashSystem: Node3D
|
|||||||
public void Init(Node3D head, Camera3D camera, TweenQueueSystem tweenQueueSystem)
|
public void Init(Node3D head, Camera3D camera, TweenQueueSystem tweenQueueSystem)
|
||||||
{
|
{
|
||||||
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
|
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
|
||||||
|
_playerCast3D = GetNode<ShapeCast3D>("PlayerShapeCast3D");
|
||||||
|
|
||||||
_head = head;
|
_head = head;
|
||||||
_camera = camera;
|
_camera = camera;
|
||||||
_tweenQueueSystem = tweenQueueSystem;
|
_tweenQueueSystem = tweenQueueSystem;
|
||||||
@ -53,9 +56,37 @@ public partial class DashSystem: Node3D
|
|||||||
}
|
}
|
||||||
var collisionPoint = _dashCast3D.GetCollisionPoint(0);
|
var collisionPoint = _dashCast3D.GetCollisionPoint(0);
|
||||||
var collisionNormal = _dashCast3D.GetCollisionNormal(0);
|
var collisionNormal = _dashCast3D.GetCollisionNormal(0);
|
||||||
var collisionShape = (SphereShape3D) _dashCast3D.GetShape();
|
// var playerEndLocation = ComputeDashLocationForPlayerShape(collisionPoint, collisionNormal);
|
||||||
var centerSphereLocation = collisionPoint + collisionNormal * 0.2f;
|
|
||||||
return new DashComputationRecord(true, centerSphereLocation, collisionPoint, collisionNormal);
|
var fraction = _dashCast3D.GetClosestCollisionSafeFraction();
|
||||||
|
var globalSweepPath = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition) - _dashCast3D.GlobalPosition;
|
||||||
|
var locationAlongPath = _dashCast3D.GlobalPosition + globalSweepPath * fraction;
|
||||||
|
|
||||||
|
var maxPushDownDistance = 0.9f;
|
||||||
|
var correctionProportion = (float)Mathf.Remap(collisionNormal.Y, -0.5, -1, 0, 1);
|
||||||
|
var proportion = (float) Mathf.Remap(_dashCast3D.GlobalRotation.X, 0, 1.57, 0, 1);
|
||||||
|
locationAlongPath += collisionNormal * maxPushDownDistance * proportion * correctionProportion;
|
||||||
|
|
||||||
|
var otherLocation = ComputeDashLocationForPlayerShape(collisionPoint, collisionNormal);
|
||||||
|
return new DashComputationRecord(true, locationAlongPath, collisionPoint, collisionNormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 ComputeDashLocationForPlayerShape(Vector3 location, Vector3? normal = null)
|
||||||
|
{
|
||||||
|
if (!normal.HasValue)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
var castStartLocation = location + 2 * normal.Value;
|
||||||
|
var castEndLocation = -2 * normal.Value;
|
||||||
|
_playerCast3D.SetGlobalPosition(castStartLocation);
|
||||||
|
_playerCast3D.SetTargetPosition(castEndLocation);
|
||||||
|
|
||||||
|
if (!_playerCast3D.IsColliding())
|
||||||
|
return castEndLocation;
|
||||||
|
|
||||||
|
var fraction = _playerCast3D.GetClosestCollisionSafeFraction();
|
||||||
|
var locationAlongPath = castEndLocation * fraction;
|
||||||
|
return castStartLocation + locationAlongPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareDash()
|
public void PrepareDash()
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://cqduhd4opgwvm"]
|
[gd_scene load_steps=6 format=3 uid="uid://cqduhd4opgwvm"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dwoppk8j5fxeg" path="res://systems/dash/DashSystem.cs" id="1_hwig2"]
|
[ext_resource type="Script" uid="uid://dwoppk8j5fxeg" path="res://systems/dash/DashSystem.cs" id="1_hwig2"]
|
||||||
|
[ext_resource type="Shape3D" uid="uid://keseacdcooot" path="res://player_controller/resources/PlayerShape.tres" id="2_jngg2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="2_pff7b"]
|
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="2_pff7b"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_qu4wy"]
|
|
||||||
radius = 0.2
|
|
||||||
|
|
||||||
[sub_resource type="SphereMesh" id="SphereMesh_qu4wy"]
|
[sub_resource type="SphereMesh" id="SphereMesh_qu4wy"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v31n3"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v31n3"]
|
||||||
@ -13,9 +11,15 @@ radius = 0.2
|
|||||||
[node name="DashSystem" type="Node3D"]
|
[node name="DashSystem" type="Node3D"]
|
||||||
script = ExtResource("1_hwig2")
|
script = ExtResource("1_hwig2")
|
||||||
|
|
||||||
|
[node name="PlayerShapeCast3D" type="ShapeCast3D" parent="."]
|
||||||
|
shape = ExtResource("2_jngg2")
|
||||||
|
target_position = Vector3(0, 0, 0)
|
||||||
|
collision_mask = 2
|
||||||
|
debug_shape_custom_color = Color(0.863327, 0.636844, 0, 1)
|
||||||
|
|
||||||
[node name="DashCast3D" type="ShapeCast3D" parent="."]
|
[node name="DashCast3D" type="ShapeCast3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0)
|
||||||
shape = SubResource("SphereShape3D_qu4wy")
|
shape = ExtResource("2_jngg2")
|
||||||
target_position = Vector3(0, 0, -12)
|
target_position = Vector3(0, 0, -12)
|
||||||
max_results = 1
|
max_results = 1
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
|
14
systems/inputs/base_mode/aim_down.tres
Normal file
14
systems/inputs/base_mode/aim_down.tres
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://c3e0ivgaxrsyb"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cluhc11vixkf1" path="res://addons/guide/guide_action.gd" id="1_gn1pi"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_gn1pi")
|
||||||
|
name = &""
|
||||||
|
action_value_type = 0
|
||||||
|
block_lower_priority_actions = true
|
||||||
|
emit_as_godot_actions = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
metadata/_custom_type_script = "uid://cluhc11vixkf1"
|
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=65 format=3 uid="uid://bl5crtu1gkrtr"]
|
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=71 format=3 uid="uid://bl5crtu1gkrtr"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
||||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
||||||
@ -14,7 +14,9 @@
|
|||||||
[ext_resource type="Script" uid="uid://ckggy40lm0vjc" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="12_kxb2c"]
|
[ext_resource type="Script" uid="uid://ckggy40lm0vjc" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="12_kxb2c"]
|
||||||
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="13_v2ywt"]
|
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="13_v2ywt"]
|
||||||
[ext_resource type="Resource" uid="uid://dgfww8118d8gj" path="res://systems/inputs/base_mode/aim.tres" id="14_vtk18"]
|
[ext_resource type="Resource" uid="uid://dgfww8118d8gj" path="res://systems/inputs/base_mode/aim.tres" id="14_vtk18"]
|
||||||
|
[ext_resource type="Resource" uid="uid://c3e0ivgaxrsyb" path="res://systems/inputs/base_mode/aim_down.tres" id="14_yp12v"]
|
||||||
[ext_resource type="Script" uid="uid://b52rqq28tuqpg" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="15_fykw6"]
|
[ext_resource type="Script" uid="uid://b52rqq28tuqpg" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="15_fykw6"]
|
||||||
|
[ext_resource type="Script" uid="uid://b4cdrn4paoj3i" path="res://addons/guide/triggers/guide_trigger_down.gd" id="15_g6bbx"]
|
||||||
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="16_rvpjj"]
|
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="16_rvpjj"]
|
||||||
[ext_resource type="Script" uid="uid://biiggjw6tv4uq" path="res://addons/guide/triggers/guide_trigger_released.gd" id="17_s8kjn"]
|
[ext_resource type="Script" uid="uid://biiggjw6tv4uq" path="res://addons/guide/triggers/guide_trigger_released.gd" id="17_s8kjn"]
|
||||||
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="18_vibkn"]
|
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="18_vibkn"]
|
||||||
@ -53,7 +55,7 @@ triggers = Array[ExtResource("8_2tfaw")]([])
|
|||||||
script = ExtResource("1_qmhk6")
|
script = ExtResource("1_qmhk6")
|
||||||
action = ExtResource("2_g6bbx")
|
action = ExtResource("2_g6bbx")
|
||||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_1igva")])
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_1igva")])
|
||||||
metadata/_guide_input_mappings_collapsed = false
|
metadata/_guide_input_mappings_collapsed = true
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_05q5j"]
|
[sub_resource type="Resource" id="Resource_05q5j"]
|
||||||
script = ExtResource("10_cvxqo")
|
script = ExtResource("10_cvxqo")
|
||||||
@ -134,7 +136,7 @@ script = ExtResource("10_cvxqo")
|
|||||||
axis = 4
|
axis = 4
|
||||||
joy_index = -1
|
joy_index = -1
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_ib0yi"]
|
[sub_resource type="Resource" id="Resource_li5ak"]
|
||||||
script = ExtResource("15_fykw6")
|
script = ExtResource("15_fykw6")
|
||||||
actuation_threshold = 0.5
|
actuation_threshold = 0.5
|
||||||
|
|
||||||
@ -146,7 +148,8 @@ display_name = ""
|
|||||||
display_category = ""
|
display_category = ""
|
||||||
input = SubResource("Resource_ufouq")
|
input = SubResource("Resource_ufouq")
|
||||||
modifiers = Array[ExtResource("5_0qat1")]([])
|
modifiers = Array[ExtResource("5_0qat1")]([])
|
||||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_ib0yi")])
|
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_li5ak")])
|
||||||
|
metadata/_guide_triggers_collapsed = false
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_0hmrk"]
|
[sub_resource type="Resource" id="Resource_0hmrk"]
|
||||||
script = ExtResource("1_qmhk6")
|
script = ExtResource("1_qmhk6")
|
||||||
@ -154,6 +157,30 @@ action = ExtResource("14_vtk18")
|
|||||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_qbthx")])
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_qbthx")])
|
||||||
metadata/_guide_input_mappings_collapsed = false
|
metadata/_guide_input_mappings_collapsed = false
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_si4d4"]
|
||||||
|
script = ExtResource("10_cvxqo")
|
||||||
|
axis = 4
|
||||||
|
joy_index = -1
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_2tfaw"]
|
||||||
|
script = ExtResource("15_g6bbx")
|
||||||
|
actuation_threshold = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_q86qg"]
|
||||||
|
script = ExtResource("3_yp12v")
|
||||||
|
override_action_settings = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
input = SubResource("Resource_si4d4")
|
||||||
|
modifiers = Array[ExtResource("5_0qat1")]([])
|
||||||
|
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_2tfaw")])
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_cvxqo"]
|
||||||
|
script = ExtResource("1_qmhk6")
|
||||||
|
action = ExtResource("14_yp12v")
|
||||||
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_q86qg")])
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_cqc4k"]
|
[sub_resource type="Resource" id="Resource_cqc4k"]
|
||||||
script = ExtResource("10_cvxqo")
|
script = ExtResource("10_cvxqo")
|
||||||
axis = 4
|
axis = 4
|
||||||
@ -177,7 +204,7 @@ triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_vanwy")])
|
|||||||
script = ExtResource("1_qmhk6")
|
script = ExtResource("1_qmhk6")
|
||||||
action = ExtResource("16_rvpjj")
|
action = ExtResource("16_rvpjj")
|
||||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_bkx7d")])
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_bkx7d")])
|
||||||
metadata/_guide_input_mappings_collapsed = true
|
metadata/_guide_input_mappings_collapsed = false
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_lfx76"]
|
[sub_resource type="Resource" id="Resource_lfx76"]
|
||||||
script = ExtResource("19_qkgmj")
|
script = ExtResource("19_qkgmj")
|
||||||
@ -280,5 +307,5 @@ metadata/_guide_input_mappings_collapsed = false
|
|||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("23_llfhp")
|
script = ExtResource("23_llfhp")
|
||||||
display_name = ""
|
display_name = ""
|
||||||
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_0hmrk"), SubResource("Resource_iihs4"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw"), SubResource("Resource_0qat1")])
|
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_0hmrk"), SubResource("Resource_cvxqo"), SubResource("Resource_iihs4"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw"), SubResource("Resource_0qat1")])
|
||||||
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
||||||
|
@ -11,6 +11,7 @@ class_name InputController
|
|||||||
|
|
||||||
@export_group("Trigger actions")
|
@export_group("Trigger actions")
|
||||||
@export var aim_pressed:GUIDEAction
|
@export var aim_pressed:GUIDEAction
|
||||||
|
@export var aim_down:GUIDEAction
|
||||||
@export var aim_released:GUIDEAction
|
@export var aim_released:GUIDEAction
|
||||||
@export var aim_canceled:GUIDEAction
|
@export var aim_canceled:GUIDEAction
|
||||||
@export var jump:GUIDEAction
|
@export var jump:GUIDEAction
|
||||||
@ -22,6 +23,7 @@ signal input_rotate_y(value: float)
|
|||||||
signal input_rotate_floorplane(value: float)
|
signal input_rotate_floorplane(value: float)
|
||||||
|
|
||||||
signal input_aim_pressed
|
signal input_aim_pressed
|
||||||
|
signal input_aim_down
|
||||||
signal input_aim_released
|
signal input_aim_released
|
||||||
signal input_aim_canceled
|
signal input_aim_canceled
|
||||||
signal input_jump
|
signal input_jump
|
||||||
@ -32,6 +34,7 @@ func _ready() -> void:
|
|||||||
GUIDE.enable_mapping_context(base_mode)
|
GUIDE.enable_mapping_context(base_mode)
|
||||||
|
|
||||||
aim_pressed.triggered.connect(on_input_aim_pressed)
|
aim_pressed.triggered.connect(on_input_aim_pressed)
|
||||||
|
aim_down.triggered.connect(on_input_aim_down)
|
||||||
aim_released.triggered.connect(on_input_aim_released)
|
aim_released.triggered.connect(on_input_aim_released)
|
||||||
aim_canceled.triggered.connect(on_input_aim_canceled)
|
aim_canceled.triggered.connect(on_input_aim_canceled)
|
||||||
jump.triggered.connect(on_input_jump)
|
jump.triggered.connect(on_input_jump)
|
||||||
@ -50,6 +53,9 @@ func on_input_jump():
|
|||||||
func on_input_aim_pressed():
|
func on_input_aim_pressed():
|
||||||
input_aim_pressed.emit()
|
input_aim_pressed.emit()
|
||||||
|
|
||||||
|
func on_input_aim_down():
|
||||||
|
input_aim_down.emit()
|
||||||
|
|
||||||
func on_input_aim_released():
|
func on_input_aim_released():
|
||||||
input_aim_released.emit()
|
input_aim_released.emit()
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
using GodotStateCharts;
|
using GodotStateCharts;
|
||||||
|
|
||||||
@ -23,9 +24,8 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
private Transform3D _startTransform;
|
private Transform3D _startTransform;
|
||||||
|
|
||||||
private Vector3 _throwDirection;
|
private Vector3 _throwDirection;
|
||||||
private Vector3 _plantLocation;
|
public Vector3 PlantLocation { get; set; }
|
||||||
private Vector3 _plantNormal;
|
public Vector3 PlantNormal { get; set; }
|
||||||
public Vector3 PlayerDashLocation { get; set; }
|
|
||||||
|
|
||||||
public void Init(Node3D head, Camera3D camera)
|
public void Init(Node3D head, Camera3D camera)
|
||||||
{
|
{
|
||||||
@ -51,8 +51,8 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
_weaponState.SendEvent("throw");
|
_weaponState.SendEvent("throw");
|
||||||
|
|
||||||
_throwDirection = (end - GlobalPosition).Normalized();
|
_throwDirection = (end - GlobalPosition).Normalized();
|
||||||
_plantLocation = collisionLocation;
|
PlantLocation = collisionLocation;
|
||||||
_plantNormal = collisionNormal;
|
PlantNormal = collisionNormal;
|
||||||
LookAt(end);
|
LookAt(end);
|
||||||
|
|
||||||
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
||||||
@ -72,9 +72,13 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
{
|
{
|
||||||
_weaponState.SendEvent("plant");
|
_weaponState.SendEvent("plant");
|
||||||
Freeze = true;
|
Freeze = true;
|
||||||
GlobalPosition = _plantLocation;
|
GlobalPosition = PlantLocation;
|
||||||
PlayerDashLocation = ComputeDashLocation(_plantLocation, _plantNormal);
|
LookAt(GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
|
||||||
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
|
}
|
||||||
|
|
||||||
|
public void OnThrownWeaponReachesGround(Node other)
|
||||||
|
{
|
||||||
|
PlantWeaponInWall();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetWeapon()
|
public void ResetWeapon()
|
||||||
@ -83,26 +87,25 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
Transform = _startTransform;
|
Transform = _startTransform;
|
||||||
Freeze = true;
|
Freeze = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 ComputeDashLocation(Vector3 collisionLocation, Vector3 collisionNormal)
|
|
||||||
{
|
|
||||||
return collisionLocation + collisionNormal * 0.2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _IntegrateForces(PhysicsDirectBodyState3D state)
|
public override void _IntegrateForces(PhysicsDirectBodyState3D state)
|
||||||
{
|
{
|
||||||
base._IntegrateForces(state);
|
base._IntegrateForces(state);
|
||||||
PlayerDashLocation = GlobalPosition;
|
|
||||||
if (!Freeze && state.GetContactCount() > 0)
|
if (!Freeze && state.GetContactCount() > 0)
|
||||||
{
|
{
|
||||||
_plantLocation = state.GetContactLocalPosition(0);
|
PlantLocation = state.GetContactLocalPosition(0);
|
||||||
_plantNormal = state.GetContactLocalNormal(0);
|
PlantNormal = state.GetContactLocalNormal(0);
|
||||||
PlayerDashLocation = ComputeDashLocation(_plantLocation, _plantNormal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnThrownWeaponReachesGround(Node other)
|
public bool IsPlantedUnderPlatform()
|
||||||
{
|
{
|
||||||
PlantWeaponInWall();
|
return PlantedState.Active && GlobalRotation.X > 1 && Math.Abs(GlobalRotation.Y) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsPlantedInWall()
|
||||||
|
{
|
||||||
|
return PlantedState.Active && Math.Abs(GlobalRotation.X) + Math.Abs(GlobalRotation.Z) < 0.3;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user