gd: mapped dash actions on guide inputs
This commit is contained in:
@ -176,3 +176,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.2019, 12.6118, 13.3006)
|
|||||||
[node name="DebugLayer" type="CanvasLayer" parent="."]
|
[node name="DebugLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="GuideDebugger" parent="DebugLayer" instance=ExtResource("2_0xm2m")]
|
[node name="GuideDebugger" parent="DebugLayer" instance=ExtResource("2_0xm2m")]
|
||||||
|
visible = false
|
||||||
|
@ -126,10 +126,11 @@ target_position = Vector3(0, 1, 0)
|
|||||||
script = ExtResource("20_rxwoh")
|
script = ExtResource("20_rxwoh")
|
||||||
WalkSpeed = 10.0
|
WalkSpeed = 10.0
|
||||||
SprintSpeed = 15.0
|
SprintSpeed = 15.0
|
||||||
|
DoubleJumpSpeedFactor = 1.4
|
||||||
|
|
||||||
[node name="Gravity" type="Node3D" parent="."]
|
[node name="Gravity" type="Node3D" parent="."]
|
||||||
script = ExtResource("9_lsueh")
|
script = ExtResource("9_lsueh")
|
||||||
Weight = 10.0
|
Weight = 6.5
|
||||||
StartVelocity = 4.0
|
StartVelocity = 4.0
|
||||||
|
|
||||||
[node name="TweenQueueSystem" parent="." instance=ExtResource("22_rpwev")]
|
[node name="TweenQueueSystem" parent="." instance=ExtResource("22_rpwev")]
|
||||||
|
@ -14,15 +14,19 @@ public partial class DashSystem: Node3D
|
|||||||
private Node3D _head;
|
private Node3D _head;
|
||||||
private ShapeCast3D _dashCast3D;
|
private ShapeCast3D _dashCast3D;
|
||||||
private Camera3D _camera;
|
private Camera3D _camera;
|
||||||
private MeshInstance3D _dashTarget;
|
private TweenQueueSystem _tweenQueueSystem;
|
||||||
|
|
||||||
private MantleSystem _mantleSystem;
|
private MantleSystem _mantleSystem;
|
||||||
|
private MeshInstance3D _dashTarget;
|
||||||
|
|
||||||
|
private DashResolve _dashResolve;
|
||||||
|
|
||||||
public void Init(Node3D head, Camera3D camera)
|
public void Init(Node3D head, Camera3D camera, TweenQueueSystem tweenQueueSystem)
|
||||||
{
|
{
|
||||||
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
|
_dashCast3D = GetNode<ShapeCast3D>("DashCast3D");
|
||||||
_head = head;
|
_head = head;
|
||||||
_camera = camera;
|
_camera = camera;
|
||||||
|
_tweenQueueSystem = tweenQueueSystem;
|
||||||
|
|
||||||
_mantleSystem = GetNode<MantleSystem>("MantleSystem");
|
_mantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||||
_mantleSystem.Init(this);
|
_mantleSystem.Init(this);
|
||||||
@ -69,11 +73,22 @@ public partial class DashSystem: Node3D
|
|||||||
_dashTarget.SetVisible(true);
|
_dashTarget.SetVisible(true);
|
||||||
_dashTarget.SetGlobalPosition(location);
|
_dashTarget.SetGlobalPosition(location);
|
||||||
|
|
||||||
return new DashResolve(shouldMantle, location, mantleLocation);
|
_dashResolve = new DashResolve(shouldMantle, location, mantleLocation);
|
||||||
|
return _dashResolve;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelDash()
|
||||||
|
{
|
||||||
|
_dashTarget.SetVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dash()
|
public void Dash()
|
||||||
{
|
{
|
||||||
_dashTarget.SetVisible(false);
|
_dashTarget.SetVisible(false);
|
||||||
|
_tweenQueueSystem.QueueTween(_dashResolve.DashLocation, 0.1f);
|
||||||
|
if (_dashResolve.EndWithMantle)
|
||||||
|
{
|
||||||
|
_tweenQueueSystem.QueueTween(_dashResolve.MantleLocation, 0.1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private float _inputRotateFloorplane = 0.0f;
|
private float _inputRotateFloorplane = 0.0f;
|
||||||
|
|
||||||
private bool _isAiming = false;
|
private bool _isAiming = false;
|
||||||
|
private bool _dashCanceled = false;
|
||||||
|
|
||||||
public void OnInputMove(Vector3 value)
|
public void OnInputMove(Vector3 value)
|
||||||
{
|
{
|
||||||
@ -55,18 +56,21 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void OnInputAimPressed()
|
public void OnInputAimPressed()
|
||||||
{
|
{
|
||||||
_isAiming = true;
|
if (_dashCanceled)
|
||||||
GD.Print("Aim pressed");
|
return;
|
||||||
|
|
||||||
|
DashSystem.PrepareDash();
|
||||||
}
|
}
|
||||||
public void OnInputAimReleased()
|
public void OnInputAimReleased()
|
||||||
{
|
{
|
||||||
_isAiming = false;
|
if (!_dashCanceled)
|
||||||
GD.Print("Aim released");
|
DashSystem.Dash();
|
||||||
|
_dashCanceled = false;
|
||||||
}
|
}
|
||||||
public void OnInputAimCanceled()
|
public void OnInputAimCanceled()
|
||||||
{
|
{
|
||||||
_isAiming = false;
|
_dashCanceled = true;
|
||||||
GD.Print("Aim canceled");
|
DashSystem.CancelDash();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInputJumpPressed()
|
public void OnInputJumpPressed()
|
||||||
@ -144,7 +148,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||||
|
|
||||||
DashSystem = GetNode<DashSystem>("DashSystem");
|
DashSystem = GetNode<DashSystem>("DashSystem");
|
||||||
DashSystem.Init(HeadSystem, camera);
|
DashSystem.Init(HeadSystem, camera, TweenQueueSystem);
|
||||||
|
|
||||||
HealthSystem = GetNode<HealthSystem>("HealthSystem");
|
HealthSystem = GetNode<HealthSystem>("HealthSystem");
|
||||||
|
|
||||||
@ -166,25 +170,17 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
TweenQueueSystem.ProcessTweens();
|
TweenQueueSystem.ProcessTweens();
|
||||||
|
|
||||||
if (Input.IsActionPressed("aim_dash"))
|
|
||||||
{
|
|
||||||
(_shouldMantle, _dashLocation, _mantleLocation) = DashSystem.PrepareDash();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Input.IsActionJustReleased("aim_dash"))
|
|
||||||
{
|
|
||||||
DashSystem.Dash();
|
|
||||||
TweenQueueSystem.QueueTween(_dashLocation, 0.1f);
|
|
||||||
if (_shouldMantle)
|
|
||||||
{
|
|
||||||
TweenQueueSystem.QueueTween(_mantleLocation, 0.1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var isPlayerDead = HealthSystem.IsDead();
|
var isPlayerDead = HealthSystem.IsDead();
|
||||||
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
var isHeadTouchingCeiling = IsHeadTouchingCeiling();
|
||||||
|
|
||||||
MoveSystem.MoveAround(delta, _inputMove, isOnFloorCustom(), isPlayerDead, isHeadTouchingCeiling);
|
var moveAroundParams = new MoveSystem.MoveAroundParameters(
|
||||||
|
delta,
|
||||||
|
_inputMove,
|
||||||
|
isOnFloorCustom(),
|
||||||
|
isPlayerDead,
|
||||||
|
isHeadTouchingCeiling);
|
||||||
|
MoveSystem.MoveAround(moveAroundParams);
|
||||||
|
|
||||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||||
HeadSystem.LookAround(inputLookDir);
|
HeadSystem.LookAround(inputLookDir);
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ public partial class StairsSystem: Node3D
|
|||||||
if (parameters.IsCapsuleHeightLessThanNormal)
|
if (parameters.IsCapsuleHeightLessThanNormal)
|
||||||
{
|
{
|
||||||
motionVelocityMultiplier = 1.55f; // Going to crouch mode
|
motionVelocityMultiplier = 1.55f; // Going to crouch mode
|
||||||
}else if (parameters.CurrentSpeedGreaterThanWalkSpeed)
|
}
|
||||||
|
else if (parameters.CurrentSpeedGreaterThanWalkSpeed)
|
||||||
{
|
{
|
||||||
motionVelocityMultiplier = 1.1f; // Sprinting
|
motionVelocityMultiplier = 1.1f; // Sprinting
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,14 @@ public partial class MoveSystem : Node3D
|
|||||||
TweenQueueSystem TweenQueueSystem,
|
TweenQueueSystem TweenQueueSystem,
|
||||||
HeadSystem HeadSystem,
|
HeadSystem HeadSystem,
|
||||||
CapsuleCollider CapsuleCollider);
|
CapsuleCollider CapsuleCollider);
|
||||||
|
|
||||||
|
public record MoveAroundParameters(
|
||||||
|
double Delta,
|
||||||
|
Vector3 MovementDirection,
|
||||||
|
bool IsOnFloor,
|
||||||
|
bool IsDead,
|
||||||
|
bool IsHeadTouchingCeiling
|
||||||
|
);
|
||||||
|
|
||||||
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
||||||
public float WalkSpeed { get; set; } = 5.0f;
|
public float WalkSpeed { get; set; } = 5.0f;
|
||||||
@ -48,8 +56,10 @@ public partial class MoveSystem : Node3D
|
|||||||
_currentSpeed = WalkSpeed;
|
_currentSpeed = WalkSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveAround(double delta, Vector3 movementDirection, bool isOnFloor, bool isDead, bool isHeadTouchingCeiling)
|
public void MoveAround(MoveAroundParameters param)
|
||||||
{
|
{
|
||||||
|
var (delta, movementDirection, isOnFloor, isDead, isHeadTouchingCeiling) = param;
|
||||||
|
|
||||||
var doesCapsuleHaveCrouchingHeight = _capsuleCollider.IsCrouchingHeight();
|
var doesCapsuleHaveCrouchingHeight = _capsuleCollider.IsCrouchingHeight();
|
||||||
var doesCapsuleHaveDefaultHeight = _capsuleCollider.IsDefaultHeight();
|
var doesCapsuleHaveDefaultHeight = _capsuleCollider.IsDefaultHeight();
|
||||||
|
|
||||||
@ -77,7 +87,6 @@ public partial class MoveSystem : Node3D
|
|||||||
y: _parent.Velocity.Y - 2.0f,
|
y: _parent.Velocity.Y - 2.0f,
|
||||||
z: _parent.Velocity.Z);
|
z: _parent.Velocity.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isDead)
|
if (!isDead)
|
||||||
{
|
{
|
||||||
@ -152,7 +161,6 @@ public partial class MoveSystem : Node3D
|
|||||||
if (isDead)
|
if (isDead)
|
||||||
{
|
{
|
||||||
_parent.MoveAndSlide();
|
_parent.MoveAndSlide();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user