This post has been wikified, any user with enough reputation can edit it.
Question by
datg0602 · Jan 18, 2016 at 09:01 AM ·
scripting problem
help! i am a newbie here and i got a problem in scripting
hi! i am trying to make an object to moving by the music, link:here then when i use the script, i get ton of error like: Assets/Spripts/Beat_fuck.cs(18,35): error CS1525: Unexpected symbol :', expecting
)', ,',
;', [', or
=' the script is:
var qSamples : int = 2048; // QWindow
var channels : int = 2;
var bassMinHz : int = 30; //Min bass Frequency in Hz
var bassMaxHz : int = 120; // Max bass Frequency in Hz
private var bassMinSamples: int ; //Min bass in samples
private var bassMaxSamples : int ; // Max bass in samples
private var spectrumSamples : float[];
var objectToMove : Transform; // Add you object here
var moveMultiplier : float = 10; // Adjust this to move more or less
var audioListener : AudioListener; // Assign one audioListener here
var audioisPlaying : boolean = false;
function Start()
{
spectrumSamples = new float[ qSamples];
bassMinSamples = (bassMinHz * qSamples)/(AudioSettings.outputSampleRate/channels) ;
bassMaxSamples = (bassMaxHz * qSamples)/(AudioSettings.outputSampleRate/channels) ;
}
function Update ()
{
if( audioListener != null && audioisPlaying == true)
AnalizeSpectrum() ;
}
function AnalizeSpectrum(){
audioListener.GetSpectrumData( spectrumSamples, 0, FFTWindow.Rectangular );
for ( var smplN = 0; smplN < spectrumSamples.Length ; smplN ++ ){
// If the current sample is withing the bass range move the object
if( smplN >= bassMinSamples && smplN <= bassMaxSamples ){
objectToMove.position.y = spectrumSamples[smplN] * moveMultiplier ;
}
}
}
please help and sorry for my bad english
Comment
Your answer
Follow this Question
Related Questions
Why isn't my player moving down? 0 Answers
HP, DMG, HUD scripts problem 0 Answers
How to get 2D blocks to break after a certain amount of hits 0 Answers
Debugging Collision script - Help required to understand behaviour 2 Answers
Need to get the difference between the rotation of a normal and an object 0 Answers