gd: inputs for dash
This commit is contained in:
@ -56,6 +56,45 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
private const int NumOfHeadCollisionDetectors = 4;
|
||||
private RayCast3D[] _headCollisionDetectors;
|
||||
|
||||
private Vector3 _inputMove = Vector3.Zero;
|
||||
private float _inputRotateY = 0.0f;
|
||||
private float _inputRotateFloorplane = 0.0f;
|
||||
|
||||
private bool _isAiming = false;
|
||||
|
||||
public void OnInputMove(Vector3 value)
|
||||
{
|
||||
_inputMove = value;
|
||||
}
|
||||
|
||||
public void OnInputRotateY(float value)
|
||||
{
|
||||
_inputRotateY = value;
|
||||
}
|
||||
|
||||
public void OnInputRotateFloorplane(float value)
|
||||
{
|
||||
_inputRotateFloorplane = value;
|
||||
}
|
||||
|
||||
public void OnInputAimPressed()
|
||||
{
|
||||
_isAiming = true;
|
||||
GD.Print("Aim pressed");
|
||||
}
|
||||
public void OnInputAimReleased()
|
||||
{
|
||||
_isAiming = false;
|
||||
GD.Print("Aim released");
|
||||
}
|
||||
public void OnInputAimCanceled()
|
||||
{
|
||||
_isAiming = false;
|
||||
GD.Print("Aim canceled");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@ -286,18 +325,16 @@ public partial class PlayerController : CharacterBody3D
|
||||
_currentSpeed = SprintSpeed;
|
||||
}
|
||||
|
||||
Vector2 inputLookDir = Input.GetVector("look_left", "look_right", "look_up", "look_down");
|
||||
// Vector2 inputLookDir = Input.GetVector("look_left", "look_right", "look_up", "look_down");
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
Mouse.LookAround(-1 * ControllerSensitivity * inputLookDir);
|
||||
|
||||
// Get the input direction
|
||||
Vector2 inputDir = Input.GetVector("left", "right", "up", "down");
|
||||
|
||||
|
||||
// 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 = (Head.Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
||||
Vector3 direction = Head.Transform.Basis * _inputMove;
|
||||
|
||||
if (isPlayerDead)
|
||||
{
|
||||
|
Reference in New Issue
Block a user