# 2D Weapon Sway

**URL:** <https://discussions.unity.com/t/2d-weapon-sway/1735871>\
**Category:** Physics\
**Tags:** Question, 6.5, Rigidbodies\
**Created:** [September 6, 2026, 4:29pm UTC](https://discussions.unity.com/t/2d-weapon-sway/1735871 "2026-09-06T16:29:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyzogirard](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@flyzogirard](https://discussions.unity.com/u/flyzogirard)\
**Post date:** [September 6, 2026, 4:29pm UTC](https://discussions.unity.com/t/2d-weapon-sway/1735871/1 "2026-09-06T16:29:12Z")

</div>

So I am trying to make a game where there is an axe that follows the mouse. The mouse holds the handle of the axe, so the head of the axe should have a sway. I now have a bug where if the axe goes for a long time in one direction, it snaps back to 20 degrees ( my max angle ). I can’t figure out how to make it smooth. Thanks !

```auto
private void Move()
{
    // weapon movement
    Vector3 MousePosition = Camera.main.ScreenToWorldPoint(touchPositionAction.ReadValue<Vector2>());
    if (MousePosition.x < -0.2f && MousePosition.y < -1.5f)
    {
        MousePosition.x = -0.2f;
    }
    Vector3 AxePosition = axe.transform.position;
    Vector2 Difference = new Vector2(MousePosition.x - AxePosition.x, MousePosition.y - AxePosition.y);

    float speed = Mathf.Pow((Difference.magnitude)*8, 1.3f);
    Vector2 Direction = Difference.normalized;
    Vector2 newVelocity = Direction * speed;
    axeRigidbody.linearVelocity = newVelocity;

    // weapon sway
    float z = axe.transform.eulerAngles.z;
    if (z > 180f) z -= 360f;

    float targetAngular = 0f;
    if (speed > 1f && Mathf.Abs(z) < 20f)
    {
        targetAngular = -axeRigidbody.linearVelocity.x * swayMultiplier;

    }
    else
    {
        targetAngular = -z * restoreMultiplier;
    }

    float newAngular = Mathf.Lerp(axeRigidbody.angularVelocity, targetAngular, Time.deltaTime * swaySmoothing);
    newAngular = Mathf.Clamp(newAngular, -maxAngularVelocity, maxAngularVelocity);
    axeRigidbody.angularVelocity = newAngular;
}

```

---

<div class="post-metadata">

**Author:** ![bugfinders](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/bugfinders/32/886124_2.png) [@bugfinders](https://discussions.unity.com/u/bugfinders)\
**Post date:** [September 6, 2026, 4:39pm UTC](https://discussions.unity.com/t/2d-weapon-sway/1735871/2 "2026-09-06T16:39:52Z")

</div>

sounds like some debugging needed, is it because the mouse goes off the edge of the window?

---

<div class="post-metadata">

**Author:** ![flyzogirard](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@flyzogirard](https://discussions.unity.com/u/flyzogirard)\
**Post date:** [September 12, 2026, 7:45pm UTC](https://discussions.unity.com/t/2d-weapon-sway/1735871/3 "2026-09-12T19:45:35Z")

</div>

No It’s because when the axe’s rotation is bigger than 20 degrees it goes back but I can’t figure out how to smooth it out
