setMoveInput method
Implementation
void setMoveInput(GameJoystickDirection direction, Offset unitVector) {
_direction = direction;
if (unitVector == Offset.zero || direction == GameJoystickDirection.idle) {
_velocity = Vector2.zero();
return;
}
final len = unitVector.distance;
final normalized = len > 0 ? unitVector / len : Offset.zero;
_velocity = Vector2(normalized.dx * speed, normalized.dy * speed);
angle = math.atan2(normalized.dy, normalized.dx);
}