Commit dbeb5460 authored by Nathan De Castro's avatar Nathan De Castro

Corrected some glitches

parent 46cf885f
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory> <BaseDirectory>Assets</BaseDirectory>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
...@@ -24,8 +23,7 @@ ...@@ -24,8 +23,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
...@@ -33,8 +31,7 @@ ...@@ -33,8 +31,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.XML" /> <Reference Include="System.XML" />
...@@ -145,9 +142,6 @@ ...@@ -145,9 +142,6 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Advertisements"> <Reference Include="UnityEditor.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath>
</Reference> </Reference>
...@@ -190,9 +184,6 @@ ...@@ -190,9 +184,6 @@
<Reference Include="UnityEngine.HoloLens"> <Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.VR"> <Reference Include="UnityEditor.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath>
</Reference> </Reference>
...@@ -218,4 +209,5 @@ ...@@ -218,4 +209,5 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory> <BaseDirectory>Assets</BaseDirectory>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
...@@ -24,8 +23,7 @@ ...@@ -24,8 +23,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
...@@ -33,8 +31,7 @@ ...@@ -33,8 +31,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.XML" /> <Reference Include="System.XML" />
...@@ -137,9 +134,6 @@ ...@@ -137,9 +134,6 @@
<Reference Include="Assembly-UnityScript"> <Reference Include="Assembly-UnityScript">
<HintPath>C:/Users/yuki/Documents/Work/Listen/Library/ScriptAssemblies/Assembly-UnityScript.dll</HintPath> <HintPath>C:/Users/yuki/Documents/Work/Listen/Library/ScriptAssemblies/Assembly-UnityScript.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Advertisements"> <Reference Include="UnityEditor.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath>
</Reference> </Reference>
...@@ -182,9 +176,6 @@ ...@@ -182,9 +176,6 @@
<Reference Include="UnityEngine.HoloLens"> <Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.VR"> <Reference Include="UnityEditor.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath>
</Reference> </Reference>
...@@ -201,8 +192,6 @@ ...@@ -201,8 +192,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="Assembly-CSharp-firstpass.csproj"> <ProjectReference Include="Assembly-CSharp-firstpass.csproj">
<Project>{AE6F01BE-C035-8190-5EA0-F4E015BA1AA5}</Project> <Name>Assembly-CSharp-firstpass</Name> </ProjectReference> <Project>{AE6F01BE-C035-8190-5EA0-F4E015BA1AA5}</Project> <Name>Assembly-CSharp-firstpass</Name> </ProjectReference>
<ProjectReference Include="Assembly-CSharp.csproj">
<Project>{5387FFB3-27F8-102A-A952-46EE5E594FD5}</Project> <Name>Assembly-CSharp</Name> </ProjectReference>
<ProjectReference Include="Assembly-CSharp-Editor-firstpass.csproj"> <ProjectReference Include="Assembly-CSharp-Editor-firstpass.csproj">
<Project>{FC5182C2-BC2C-59E8-06A2-46F98E721705}</Project> <Name>Assembly-CSharp-Editor-firstpass</Name> </ProjectReference> <Project>{FC5182C2-BC2C-59E8-06A2-46F98E721705}</Project> <Name>Assembly-CSharp-Editor-firstpass</Name> </ProjectReference>
</ItemGroup> </ItemGroup>
...@@ -214,4 +203,5 @@ ...@@ -214,4 +203,5 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory> <BaseDirectory>Assets</BaseDirectory>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
...@@ -24,8 +23,7 @@ ...@@ -24,8 +23,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
...@@ -33,8 +31,7 @@ ...@@ -33,8 +31,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.XML" /> <Reference Include="System.XML" />
...@@ -208,9 +205,6 @@ ...@@ -208,9 +205,6 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI"> <Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference> </Reference>
...@@ -226,9 +220,6 @@ ...@@ -226,9 +220,6 @@
<Reference Include="UnityEngine.HoloLens"> <Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VR"> <Reference Include="UnityEngine.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath>
</Reference> </Reference>
...@@ -241,4 +232,5 @@ ...@@ -241,4 +232,5 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory> <BaseDirectory>Assets</BaseDirectory>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
...@@ -24,8 +23,7 @@ ...@@ -24,8 +23,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
...@@ -33,8 +31,7 @@ ...@@ -33,8 +31,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn> <NoWarn>0169</NoWarn>
<LangVersion>default</LangVersion> </PropertyGroup>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.XML" /> <Reference Include="System.XML" />
...@@ -147,9 +144,6 @@ ...@@ -147,9 +144,6 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI"> <Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference> </Reference>
...@@ -165,9 +159,6 @@ ...@@ -165,9 +159,6 @@
<Reference Include="UnityEngine.HoloLens"> <Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VR"> <Reference Include="UnityEngine.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath> <HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath>
</Reference> </Reference>
...@@ -184,4 +175,5 @@ ...@@ -184,4 +175,5 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
This diff is collapsed.
...@@ -4,7 +4,8 @@ public class AI : MonoBehaviour { ...@@ -4,7 +4,8 @@ public class AI : MonoBehaviour {
//GAMEOBJECT RELATED VARIABLE //GAMEOBJECT RELATED VARIABLE
public GameObject target; //In this case the player public GameObject target; //In this case the player
protected bool played_alert = false; //Makes sure the alert sound isn't looping protected bool played_alert = false; //Makes sure the alert sound isn't looping
public GameObject exclamation; //The exclamation point public GameObject left_eye; //The exclamation point
public GameObject right_eye;
static public Vector3 last_player_T; //Remembers the player's location at the moment of death for the death cam. static public Vector3 last_player_T; //Remembers the player's location at the moment of death for the death cam.
public Light flashlight; public Light flashlight;
...@@ -140,10 +141,13 @@ public class AI : MonoBehaviour { ...@@ -140,10 +141,13 @@ public class AI : MonoBehaviour {
void image_effects () { void image_effects () {
if (sees_the_player) { if (sees_the_player) {
flashlight.gameObject.SetActive (true); flashlight.gameObject.SetActive (true);
exclamation.SetActive (true); left_eye.SetActive (true);
right_eye.SetActive (true);
} else { } else {
flashlight.gameObject.SetActive (false); flashlight.gameObject.SetActive (false);
exclamation.SetActive (false); left_eye.SetActive (false);
right_eye.SetActive (false);
} }
} }
} }
\ No newline at end of file
...@@ -18,6 +18,7 @@ public class AudioManager : MonoBehaviour { ...@@ -18,6 +18,7 @@ public class AudioManager : MonoBehaviour {
} }
void Update () { void Update () {
GetSpeqData();
if (GetAverageVolume () >= 5.0f) { if (GetAverageVolume () >= 5.0f) {
making_sound = true; making_sound = true;
} //Only grabs the 128th value form the spectrum (so about 7000Hz)) } //Only grabs the 128th value form the spectrum (so about 7000Hz))
...@@ -28,7 +29,6 @@ public class AudioManager : MonoBehaviour { ...@@ -28,7 +29,6 @@ public class AudioManager : MonoBehaviour {
public Vector3 GetFreqSpec3 () { public Vector3 GetFreqSpec3 () {
float[] spec_data = new float[44100]; //Creates an array pre-allocated (We want it quite small to reduce latency, I made it tweakable from the inspector) float[] spec_data = new float[44100]; //Creates an array pre-allocated (We want it quite small to reduce latency, I made it tweakable from the inspector)
mic.GetData (spec_data, 0); //Stores all the output data into the array I pre-allocated mic.GetData (spec_data, 0); //Stores all the output data into the array I pre-allocated
//Low Pitch //Low Pitch
...@@ -54,4 +54,15 @@ public class AudioManager : MonoBehaviour { ...@@ -54,4 +54,15 @@ public class AudioManager : MonoBehaviour {
public float GetAverageVolume () { public float GetAverageVolume () {
return ((GetFreqSpec3 () [0]) + (GetFreqSpec3 () [1]) + (GetFreqSpec3 () [2] / 3)); //Grouping all 3 arrays into 1 to get average of all values (global volume) return ((GetFreqSpec3 () [0]) + (GetFreqSpec3 () [1]) + (GetFreqSpec3 () [2] / 3)); //Grouping all 3 arrays into 1 to get average of all values (global volume)
} }
public void GetSpeqData () {
float[] spectrum = new float[256];
for (int i = 1; i < spectrum.Length - 1; i++) {
Debug.DrawLine (new Vector3 (i - 1, spectrum[i] + 10, 0), new Vector3 (i, spectrum[i + 1] + 10, 0), Color.red);
Debug.DrawLine (new Vector3 (i - 1, Mathf.Log (spectrum[i - 1]) + 10, 2), new Vector3 (i, Mathf.Log (spectrum[i]) + 10, 2), Color.cyan);
Debug.DrawLine (new Vector3 (Mathf.Log (i - 1), spectrum[i - 1] - 10, 1), new Vector3 (Mathf.Log (i), spectrum[i] - 10, 1), Color.green);
Debug.DrawLine (new Vector3 (Mathf.Log (i - 1), Mathf.Log (spectrum[i - 1]), 3), new Vector3 (Mathf.Log (i), Mathf.Log (spectrum[i]), 3), Color.blue);
}
}
} }
\ No newline at end of file
//The Plane Vertices calculations have been made by Ben Britten (Open source project: http://benbritten.com/2009/05/19/fun-with-unity/) // An extremely dilute part of this script has been written thanks to the help of some contributors on Stack Overflow.
//And then modified and re-wrote to suit my needs
using UnityEngine; using UnityEngine;
...@@ -7,7 +6,7 @@ public class RippleEffect : MonoBehaviour { ...@@ -7,7 +6,7 @@ public class RippleEffect : MonoBehaviour {
private int[] buffer1; //Is the first buffer of vertices private int[] buffer1; //Is the first buffer of vertices
private int[] buffer2; //Is the second buffer of vertices private int[] buffer2; //Is the second buffer of vertices
private int[] vertex_indices; //Sotres the indices of the vertices private int[] vertex_indexes; //Stores the indexes of the vertices
//Because we want a whole plane to distort, we need the plane have more then just 4 vertices to simulate the wave //Because we want a whole plane to distort, we need the plane have more then just 4 vertices to simulate the wave
//This is why we need to create our own plane with many many vertices //This is why we need to create our own plane with many many vertices
...@@ -20,8 +19,9 @@ public class RippleEffect : MonoBehaviour { ...@@ -20,8 +19,9 @@ public class RippleEffect : MonoBehaviour {
private int splash_force_mic = 0; //Variable that will update the splash_force according to the mic private int splash_force_mic = 0; //Variable that will update the splash_force according to the mic
private bool swap_buffer = true; //Switches between the first and the second buffer private bool swap_buffer = true; //Switches between the first and the second buffer
private bool ticked = false; private bool ticked = false;
public int tick_at = 120; public int update_rate = 120;
public int mic_threshold = 200; public int mic_threshold = 200;
public int spread_bit_shift = 1;
public int cols = 128; //Number of the columns we want our plane to have (The bigger this is, the more computer intensive the calculations will be) public int cols = 128; //Number of the columns we want our plane to have (The bigger this is, the more computer intensive the calculations will be)
public int rows = 128; //Number of the rows we want our plane to have public int rows = 128; //Number of the rows we want our plane to have
...@@ -30,19 +30,19 @@ public class RippleEffect : MonoBehaviour { ...@@ -30,19 +30,19 @@ public class RippleEffect : MonoBehaviour {
MeshFilter mesh_filter = GetComponent<MeshFilter> (); //Attaches the mesh filter in he object to the mesh filter variable MeshFilter mesh_filter = GetComponent<MeshFilter> (); //Attaches the mesh filter in he object to the mesh filter variable
mesh = mesh_filter.mesh; //Sets mesh as the mesh of the mesh filter mesh = mesh_filter.mesh; //Sets mesh as the mesh of the mesh filter
vertices = mesh.vertices; //Sets the vertices variable to the vertices of the the created mesh vertices = mesh.vertices; //Sets the vertices variable to the vertices of the the created mesh
buffer1 = new int[vertices.Length]; //Initialises both buffers with the number of vertices in the mesh buffer1 = new int[vertices.Length]; //Initializes both buffers with the number of vertices in the mesh
buffer2 = new int[vertices.Length]; buffer2 = new int[vertices.Length];
Bounds bounds = mesh.bounds; Bounds bounds = mesh.bounds;
float xStep = (bounds.max.x - bounds.min.x) / cols; //Sets the number of tiles to annimate on the X axies according to the number of columns we selected and the size of the mesh float xStep = (bounds.max.x - bounds.min.x) / cols; //Sets the number of tiles to animate on the X axis according to the number of columns we selected and the size of the mesh
float zStep = (bounds.max.z - bounds.min.z) / rows; //Sets the number of tiles to annimate on the Y axies according to the number of columns we selected and the size of the mesh float zStep = (bounds.max.z - bounds.min.z) / rows; //Sets the number of tiles to animate on the Y axis according to the number of columns we selected and the size of the mesh
vertex_indices = new int[vertices.Length]; // Create an int array and allocates it's size to the number of vertices vertex_indexes = new int[vertices.Length]; // Create an int array and allocates it's size to the number of vertices
/* ***************** Initializes and Populates the buffers (I DID NOT WRITE THIS PART, I ONLY RE-WROTE IT TO WORK FOR MY IDEA) ******************** */ /* ***************** Initializes and Populates the buffers (These two for loops have originally been written by Ben Britten) ******************** */
int vertices_index = 0; int vertices_index = 0;
for (vertices_index = 0; vertices_index < vertices.Length; vertices_index++) { for (vertices_index = 0; vertices_index < vertices.Length; vertices_index++) {
vertex_indices[vertices_index] = -1; vertex_indexes[vertices_index] = -1;
buffer1[vertices_index] = 0; buffer1[vertices_index] = 0;
buffer2[vertices_index] = 0; buffer2[vertices_index] = 0;
} }
...@@ -51,7 +51,7 @@ public class RippleEffect : MonoBehaviour { ...@@ -51,7 +51,7 @@ public class RippleEffect : MonoBehaviour {
float column = ((vertices[vertices_index].x - bounds.min.x) / xStep); float column = ((vertices[vertices_index].x - bounds.min.x) / xStep);
float row = ((vertices[vertices_index].z - bounds.min.z) / zStep); float row = ((vertices[vertices_index].z - bounds.min.z) / zStep);
float position = (row * (cols + 1)) + column + 0.5f; float position = (row * (cols + 1)) + column + 0.5f;
vertex_indices[(int) position] = vertices_index; vertex_indexes[(int) position] = vertices_index;
} }
} }
...@@ -84,7 +84,7 @@ public class RippleEffect : MonoBehaviour { ...@@ -84,7 +84,7 @@ public class RippleEffect : MonoBehaviour {
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
ticked = tick (tick_at); ticked = tick (update_rate);
splash_force_mic = (int) EchoSound.instance.Volume; splash_force_mic = (int) EchoSound.instance.Volume;
//if (splash_force > wave_force_max) splash_force = wave_force_max; //if (splash_force > wave_force_max) splash_force = wave_force_max;
//if (splash_force_mic > wave_force_max) splash_force_mic = wave_force_max; //if (splash_force_mic > wave_force_max) splash_force_mic = wave_force_max;
...@@ -103,12 +103,12 @@ public class RippleEffect : MonoBehaviour { ...@@ -103,12 +103,12 @@ public class RippleEffect : MonoBehaviour {
/* ************************************************************************************************************************************** */ /* ************************************************************************************************************************************** */
// THE CODE THAT RAISES THE WAVE // THE CODE THAT RAISES THE WAVE
Vector3[] current_vertices = new Vector3[vertices.Length]; // initiates a array of verctor3 vertices Vector3[] current_vertices = new Vector3[vertices.Length]; // initiates a array of vector3 vertices
int current_index; //Will store the current index of a vertex int current_index; //Will store the current index of a vertex
int i = 0; int i = 0;
for (i = 0; i < current_buffer.Length; i++) //For all the vertices in the current buffer for (i = 0; i < current_buffer.Length; i++) //For all the vertices in the current buffer
{ {
current_index = vertex_indices[i]; current_index = vertex_indexes[i];
current_vertices[current_index] = vertices[current_index]; current_vertices[current_index] = vertices[current_index];
current_vertices[current_index].y += (current_buffer[i] * 1.0f / splash_force); //This is what raises the current "tile"'s Y value by the splash force times the maximum height of the wave} current_vertices[current_index].y += (current_buffer[i] * 1.0f / splash_force); //This is what raises the current "tile"'s Y value by the splash force times the maximum height of the wave}
//print(current_vertices[current_index].y); //print(current_vertices[current_index].y);
...@@ -124,7 +124,7 @@ public class RippleEffect : MonoBehaviour { ...@@ -124,7 +124,7 @@ public class RippleEffect : MonoBehaviour {
/* Ray cast function to set the splash position */ /* Ray cast function to set the splash position */
RaycastHit hit; //Will store all the info on the object the ray will collide RaycastHit hit; //Will store all the info on the object the ray will collide
Vector3 down = PlayerSettings.instance.player.transform.TransformDirection (Vector3.down); //Create a raycast from the player's position downwards Vector3 down = PlayerSettings.instance.player.transform.TransformDirection (Vector3.down); //Create a raycast from the player's position downwards
if (Physics.Raycast (PlayerSettings.instance.player.transform.position, down, out hit)) // Draws a ray dowards from the player and stores the impact location if (Physics.Raycast (PlayerSettings.instance.player.transform.position, down, out hit)) // Draws a ray downwards from the player and stores the impact location
{ {
// First we must init the tiles // First we must init the tiles
Bounds bounds = mesh.bounds; Bounds bounds = mesh.bounds;
...@@ -141,7 +141,6 @@ public class RippleEffect : MonoBehaviour { ...@@ -141,7 +141,6 @@ public class RippleEffect : MonoBehaviour {
} }
//THE CODE THAT MAKES THE WAVE MOVE AND FADE OUT //THE CODE THAT MAKES THE WAVE MOVE AND FADE OUT
//From Ben Britten's code
void ripple_effect (int[] source, int[] dest) { void ripple_effect (int[] source, int[] dest) {
int x = 0; int x = 0;
int y = 0; int y = 0;
...@@ -149,7 +148,7 @@ public class RippleEffect : MonoBehaviour { ...@@ -149,7 +148,7 @@ public class RippleEffect : MonoBehaviour {
for (y = 1; y < rows - 1; y++) { for (y = 1; y < rows - 1; y++) {
for (x = 1; x < cols; x++) { for (x = 1; x < cols; x++) {
position = (y * (cols + 1)) + x; position = (y * (cols + 1)) + x;
dest[position] = (((source[position - 1] + source[position + 1] + source[position - (cols + 1)] + source[position + (cols + 1)]) >> 1) - dest[position]); //Makes the wave move forward dest[position] = (((source[position - 1] + source[position + 1] + source[position - (cols + 1)] + source[position + (cols + 1)]) >> spread_bit_shift) - dest[position]); //Makes the wave move forward
dest[position] = (int) (dest[position] * dampner); //Makes the wave fade out dest[position] = (int) (dest[position] * dampner); //Makes the wave fade out
} }
} }
...@@ -157,9 +156,9 @@ public class RippleEffect : MonoBehaviour { ...@@ -157,9 +156,9 @@ public class RippleEffect : MonoBehaviour {
//Timer function to control how has you want to update the splash while using th mic //Timer function to control how has you want to update the splash while using th mic
int timer; int timer;
public bool tick (int tick_at) { public bool tick (int update_rate) {
timer++; timer++;
if (timer >= tick_at) { if (timer >= update_rate) {
timer = 0; timer = 0;
return true; return true;
} }
......
...@@ -8953,13 +8953,23 @@ Prefab: ...@@ -8953,13 +8953,23 @@ Prefab:
- target: {fileID: 114249406734343344, guid: ef8622c6f07c11e47aae43d93e8e076a, - target: {fileID: 114249406734343344, guid: ef8622c6f07c11e47aae43d93e8e076a,
type: 2} type: 2}
propertyPath: wave_height_max propertyPath: wave_height_max
value: 0.3 value: 0.4
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 114249406734343344, guid: ef8622c6f07c11e47aae43d93e8e076a, - target: {fileID: 114249406734343344, guid: ef8622c6f07c11e47aae43d93e8e076a,
type: 2} type: 2}
propertyPath: mic_threshold propertyPath: mic_threshold
value: 100 value: 100
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 23110908225744306, guid: ef8622c6f07c11e47aae43d93e8e076a,
type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114249406734343344, guid: ef8622c6f07c11e47aae43d93e8e076a,
type: 2}
propertyPath: update_rate
value: 5
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ef8622c6f07c11e47aae43d93e8e076a, type: 2} m_ParentPrefab: {fileID: 100100000, guid