Created
December 19, 2025 22:54
-
-
Save MartinZikmund/e2219ec011ac06204784dca99be05693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (_movementPointerId.HasValue) | |
| { | |
| var dx = _movementCurrent.X - _movementCenter.X; | |
| var dy = _movementCurrent.Y - _movementCenter.Y; | |
| var distance = Math.Sqrt(dx * dx + dy * dy); | |
| var normalizedDistance = Math.Min(distance / JoystickRadius, 1.0); | |
| if (normalizedDistance > DeadZone) | |
| { | |
| var angle = Math.Atan2(dy, dx); | |
| var adjustedDistance = (normalizedDistance - DeadZone) / (1.0 - DeadZone); | |
| // Forward/backward (Y axis, inverted) | |
| forward = (float)(-Math.Sin(angle) * adjustedDistance); | |
| // Strafe (X axis) | |
| strafe = (float)(Math.Cos(angle) * adjustedDistance); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment