Skip to content

Latest commit

 

History

History
 
 

This directory contains scripts that control GameObjects with the beat of the music.

##Scripts

##Script Documentation ###_AbstractRhythmObject.cs This script contains the basic framework for synchronizing events with the beat. ####Usage To create your own script that does things with the beat of the music, create a script that extends _AbstractRhythmObject instead of MonoBehaviour. Then implement the rhythmUpdate() function, which gets executed once every beat.

Important: Remove the Start() and Update() functions that Unity generates for you in your subclasses, otherwise you may get unexpected results when extending this class.

####Field Summary

Type and Modifiers Field Name
protected int BPM
protected float samplesPerBeat
protected float secondsPerBeat

####Field Descriptions

protected int BPM
Tempo of the audio clip in beats per minute.

protected float samplesPerBeat
The number of audio samples in one beat.

protected float secondsPerBeat
The number of seconds in one beat.

####Function Summary

Return Type and Modifiers Function Name and Parameters
protected virtual void asyncUpdate()
protected virtual void init()
protected abstract void rhythmUpdate(int beat)
protected bool onBeat()

####Function Descriptions

protected virtual void asyncUpdate()
This is the replacement for the Update() function that Unity generates.

protected virtual void init()
This is the replacement for the Start() function that Unity generates.

protected abstract void rhythmUpdate(int beat)
This function will be executed once every beat.
######Parameters:

  • beat: The number of beats that have elapsed since the beginning of the clip

protected bool onBeat(float deltaSeconds)
This function will return true if the current time is close enough to a beat. This allows you to detect whether player input is on beat or not.
######Parameters:

  • deltaSeconds: The number of seconds that the current time can be off by. Note that the window of time is twice as long, since this checks before and after the beat.

###ChangeColors.cs This script is an example usage of _AbstractRhythmObject. This applies a series of color transitions to a GameObject if the GameObject has a material with a color setting.

####Usage To use this script, attach it to a GameObject. Then specify the color transitions that you want to apply to the GameObject.

######ColorTransition This script uses a second class called ColorTransition. ColorTransitions is a container for holding information relevant to a color transition. The field descriptions for a ColorTransition is as follows:

public Color endColor The ending color of the transition.

public bool smooth Determines whether the transition will be smooth or not. If true, startColor and endColor will be interpolated in the middle of a beat. If false the material color will be immediately set to endColor.

public Color startColor
The starting color of the transition. This will only be used if smooth is true.

####Field Summary

Type and Modifiers Field Name
public ColorTransition[] colorTransitions
public int[] indices
public int offset
public bool shared

####Field Descriptions

public ColorTransition[] colorTransitions
The list of ColorTransition objects that you want to apply to a GameObject.

public int[] indices
Indices into the colorTransitions array that specfies the order in which the color transitions will be applied to the GameObject. If the size of this array is 0, the color transitions in the colorTransitions array will be used in a round-robin style. If a negative index is specified, the current color will be held.

public int offset
If indices has 0 elements, this is the index of colorTransitions array that you want to start at. Otherwise, this is the index of the indices array that you want to start at.

public bool shared
If true, this will change the shared material's color instead of creating a copy of the material. Use this if you want every object that uses the material to be changed in the same way. Changes to the shared material will stay after the game resets.


###MoveToPositions.cs This script is an example usage of _AbstractRhythmObject. This translates a GameObject through a list of positions, one at a time, in a round-robin style by default.

####Usage To use this script, attach it to a GameObject. Then specify the positions that you want the GameObject to travel through in the inspector.

####Field Summary

Type and Modifiers Field Name
public int[] indices
public bool local
public int offset
public Vector3[] positions
public bool relative
public bool rigid

####Field Descriptions

public int[] indices
Indices into the positions array that specfies the order of the positions through which the GameObject will travel. If the size of this array is 0, the positions in the positions array will be used in a round-robin style.

public bool local
If true, will transform relative to local coordinates instead of world coordinates. This field is ignored if rigid is true.

public int offset
If indices has 0 elements, this is the index of positions array that you want to start at. Otherwise, this is the index of the indices array that you want to start at.

public Vector3[] positions
The list of positions that the GameObject will travel through.

public bool relative
If true, the positions in the positions array are relative to the start position of the GameObject.

public bool rigid
If true, this will use rigid body transforms instead.


###RotateToEulers.cs This script is an example usage of _AbstractRhythmObject. This rotates a GameObject through a list of Euler angle rotations, one at a time, in a round-robin style by default.

####Usage To use this script, attach it to a GameObject. Then specify the rotations that you want the GameObject to travel through in the inspector.

####Field Summary

Type and Modifiers Field Name
public Vector3[] eulerAngles
public int[] indices
public bool local
public int offset
public bool rigid
public bool spherical

####Field Descriptions

public Vector3[] eulerAngles
The list of Euler angle rotations that the GameObject will rotate through.

>**`public int[] indices`** >Indices into the [`eulerAngles`](#eulerAngles) array that specfies the order of the rotations through which the GameObject will travel. If the size of this array is 0, the rotations in the [`eulerAngles`](#eulerAngles) array will be used in a round-robin style.

public bool local
If true, will transform relative to local coordinates instead of world coordinates. This field is ignored if rigid is true.

public int offset
If the indices array has 0 elements, this is the index of the eulerAngles that you want to start at. Otherwise, this is the index of the indices array that you want to start at.

public bool rigid
If true, this will use rigid body transforms instead.

public bool spherical
If true, this will use spherical interpolation instead of linear interpolation.