Walking / flashlight bobbing animation

Now the flashlight looks fine in a screenshot, but if you walk throughout the world, it will feel very static and unnatural. If a person is actually walking through the forest, there will be a slight bob as you walk, and if someone is actually holding a flash light, it won't be stable the entire time because your hand would move. We can solve both of these problems by writing yet another script. We perform the following steps:

  1. Create a new folder called Scripts. Inside this folder, create a new C# script called BobbingAnimation.
  2. Open the newly created script and use the following code inside it:
    using UnityEngine; using System.Collections; /// <summary> /// Allows the attached object to bob up and down through ...

Get Unity Game Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.