Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sprite weapon sway

Discussion in 'Animation' started by KowlDoog, Aug 17, 2020.

  1. KowlDoog

    KowlDoog

    Joined:
    Aug 17, 2020
    Posts:
    10
    Hey,
    I'm looking for a method to recreate this kind of weapon sway:



    I'm assuming its animated by code so that the weapon goes in a ∞ when moving. Would this be a LERP or something similar?

    I also wanted to try a method that uses physics to tether the sprites around a point and would drag behind the central mouse movement, which I've only seen 3D examples of.

    Any help or suggestions in either of these would be greatly appreciated.

    Cheers
     
  2. clownhunter

    clownhunter

    Joined:
    May 26, 2013
    Posts:
    49
    I achieved this in a retro FPS using the following scripts:

    https://github.com/EricFreeman/DungeonGame/blob/master/src/Assets/Scripts/Weapons/TurnSway.cs
    https://github.com/EricFreeman/DungeonGame/blob/master/src/Assets/Scripts/Player/Bobber.cs
    https://github.com/EricFreeman/DungeonGame/blob/master/src/Assets/Scripts/Player/Tilter.cs

    The weapon sprite gets all three and the player camera gets just the bobber and tilter.

    You can see an example of the values I used in the project itself: https://github.com/EricFreeman/DungeonGame

    Here's what it looks like in practice:


    No animations needed, just scripts.
     
  3. KowlDoog

    KowlDoog

    Joined:
    Aug 17, 2020
    Posts:
    10
    woah that's perfect, exactly what i was looking for, I appreciate the help!