Reader small image

You're reading from  Unity 5.x Animation Cookbook

Product typeBook
Published inMay 2016
Reading LevelExpert
PublisherPackt
ISBN-139781785883910
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Maciej Szczesnik
Maciej Szczesnik
author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik

Right arrow

Using waveform of a sound clip to animate objects in the scene


In this recipe, we will use a waveform of a sound effect to create motion based on the average volume of the fragment of the waveform.

Getting ready

To follow this recipe, we need a sound effect. You can use the provided example Unity project and go to the Chapter 07 Special effects\Recipe 09 Using waveform of a sound clip to animate objects in the scene directory. If you open the Example.unity scene there and play the game, you will be able to see a few cubes react to the playing audio clip.

How to do it...

To use sound waveforms for animation, follow these steps:

  1. Import the sound into Unity.
  2. Create an empty game object and name it AudioSource.
  3. Add an Audio Source component to it, and make the sound Loop and Play On Awake. Drag and drop your sound into the AudioClip field.
  4. Create a Cube game object (go to Game Object3D ObjectCube).
  5. Create a new script and call it ScaleWithWaveForm.cs. In this script, we have one public AudioSource...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Unity 5.x Animation Cookbook
Published in: May 2016Publisher: PacktISBN-13: 9781785883910

Author (1)

author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik