Search Unity

Powerup or Head Bobbing using AnimationCurve

Discussion in 'Animation' started by RageByte, Apr 1, 2021.

  1. RageByte

    RageByte

    Joined:
    Jul 2, 2017
    Posts:
    34
    Hi all,

    Was researching on how to do a simple bobbing effect on a game object using Sin or Cos and ran into the old "yes it's fast enough" and "AnimationCurve is 18% faster" etc. So after some dabbling, I came up with the attached C# script for a bobbing effect using AnimationCurve. Oh and was there a learning curve (pun intended). Took me awhile to get the inTangent and outTanget parts right (still may not be 100% correct but they're really close :confused:).

    Create a cube, slap this script on it and check it out.
     

    Attached Files: