gd: dash target

This commit is contained in:
2025-05-23 16:00:20 +02:00
parent db20eaac85
commit 6ed8ebff26
6 changed files with 129 additions and 21 deletions

View File

@ -24,6 +24,20 @@ public partial class Mouse : Node3D
_isPlayerDead = isDeadFunc;
}
public void LookAround(Vector2 lookDir)
{
// Horizontal movement of head
float angleForHorizontalRotation = lookDir.X * Sensitivity;
_head.RotateY(angleForHorizontalRotation);
// Vertical movement of head
Vector3 currentCameraRotation = _camera.Rotation;
currentCameraRotation.X += Convert.ToSingle(lookDir.Y * Sensitivity);
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
_camera.Rotation = currentCameraRotation;
}
public override void _UnhandledInput(InputEvent @event)
{
if (_isPlayerDead())
@ -33,16 +47,8 @@ public partial class Mouse : Node3D
if (@event is InputEventMouseMotion eventMouseMotion)
{
// Horizontal movement of head
float angleForHorizontalRotation = -eventMouseMotion.Relative.X * Sensitivity;
_head.RotateY(angleForHorizontalRotation);
// Vertical movement of head
Vector3 currentCameraRotation = _camera.Rotation;
currentCameraRotation.X += Convert.ToSingle(-eventMouseMotion.Relative.Y * Sensitivity);
currentCameraRotation.X = Mathf.Clamp(currentCameraRotation.X, Mathf.DegToRad(-90f), Mathf.DegToRad(90f));
_camera.Rotation = currentCameraRotation;
var lookDir = new Vector2(-eventMouseMotion.Relative.X, -eventMouseMotion.Relative.Y);
LookAround(lookDir);
}
}
}