engine sfx
This commit is contained in:
8
Assets/SFX.meta
Normal file
8
Assets/SFX.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dbefe8adad7d9b9489b4e78a9ca341a8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/SFX/car_sfx.wav
Normal file
BIN
Assets/SFX/car_sfx.wav
Normal file
Binary file not shown.
22
Assets/SFX/car_sfx.wav.meta
Normal file
22
Assets/SFX/car_sfx.wav.meta
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fe8155a3ab489f042ba310e422dd52ea
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -133,6 +133,102 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 5544791521660097144, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
m_CorrespondingSourceObject: {fileID: 5544791521660097144, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
||||||
m_PrefabInstance: {fileID: 894327812}
|
m_PrefabInstance: {fileID: 894327812}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!82 &238971429
|
||||||
|
AudioSource:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 238971427}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
|
m_audioClip: {fileID: 8300000, guid: fe8155a3ab489f042ba310e422dd52ea, type: 3}
|
||||||
|
m_PlayOnAwake: 1
|
||||||
|
m_Volume: 1
|
||||||
|
m_Pitch: 1
|
||||||
|
Loop: 1
|
||||||
|
Mute: 0
|
||||||
|
Spatialize: 0
|
||||||
|
SpatializePostEffects: 0
|
||||||
|
Priority: 128
|
||||||
|
DopplerLevel: 1
|
||||||
|
MinDistance: 1
|
||||||
|
MaxDistance: 500
|
||||||
|
Pan2D: 0
|
||||||
|
rolloffMode: 0
|
||||||
|
BypassEffects: 0
|
||||||
|
BypassListenerEffects: 0
|
||||||
|
BypassReverbZones: 0
|
||||||
|
rolloffCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
panLevelCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
spreadCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
reverbZoneMixCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
--- !u!60 &238971433
|
--- !u!60 &238971433
|
||||||
PolygonCollider2D:
|
PolygonCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1266,6 +1362,14 @@ PrefabInstance:
|
|||||||
propertyPath: speedF
|
propertyPath: speedF
|
||||||
value: 1500
|
value: 1500
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5544791521660097031, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
||||||
|
propertyPath: maxVelocity
|
||||||
|
value: 1000
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5544791521660097031, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
||||||
|
propertyPath: revSfxSpeed
|
||||||
|
value: 0.05
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5544791521660097031, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
- target: {fileID: 5544791521660097031, guid: 0377c534f7e04574aa8b817cda7b7571, type: 3}
|
||||||
propertyPath: gameOverPanel
|
propertyPath: gameOverPanel
|
||||||
value:
|
value:
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ public class carController : MonoBehaviour
|
|||||||
public float carRotationSpeed;
|
public float carRotationSpeed;
|
||||||
|
|
||||||
public static bool isAlive = true;
|
public static bool isAlive = true;
|
||||||
|
private AudioSource audioSource;
|
||||||
|
public float maxVelocity = 100;
|
||||||
|
public float EngineSFXsmooth = 0.05f;
|
||||||
public static void GameOver(){
|
public static void GameOver(){
|
||||||
if(!isAlive){return;}
|
if(!isAlive){return;}
|
||||||
|
|
||||||
@@ -81,6 +84,8 @@ public class carController : MonoBehaviour
|
|||||||
torqueF = torqueB = Torque[DataManager.SpeedLevel];
|
torqueF = torqueB = Torque[DataManager.SpeedLevel];
|
||||||
|
|
||||||
carRotationSpeed = RotationSpeed[DataManager.inAirLevel];
|
carRotationSpeed = RotationSpeed[DataManager.inAirLevel];
|
||||||
|
|
||||||
|
audioSource= GetComponent<AudioSource>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@@ -89,6 +94,7 @@ public class carController : MonoBehaviour
|
|||||||
if(!isAlive){
|
if(!isAlive){
|
||||||
rearWheel.useMotor = false;
|
rearWheel.useMotor = false;
|
||||||
frontWheel.useMotor = false;
|
frontWheel.useMotor = false;
|
||||||
|
audioSource.pitch = Mathf.Lerp(audioSource.pitch, 0,0.1f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Input.GetAxisRaw("Horizontal") > 0)
|
if (Input.GetAxisRaw("Horizontal") > 0)
|
||||||
@@ -105,6 +111,8 @@ public class carController : MonoBehaviour
|
|||||||
motorBack.maxMotorTorque = torqueF;
|
motorBack.maxMotorTorque = torqueF;
|
||||||
rearWheel.motor = motorBack;
|
rearWheel.motor = motorBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RevEngine(2f);
|
||||||
}
|
}
|
||||||
else if (Input.GetAxisRaw("Horizontal") < 0)
|
else if (Input.GetAxisRaw("Horizontal") < 0)
|
||||||
{
|
{
|
||||||
@@ -120,13 +128,21 @@ public class carController : MonoBehaviour
|
|||||||
motorBack.maxMotorTorque = torqueB;
|
motorBack.maxMotorTorque = torqueB;
|
||||||
rearWheel.motor = motorBack;
|
rearWheel.motor = motorBack;
|
||||||
}
|
}
|
||||||
|
// RevEngine(1.5f);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rearWheel.useMotor = false;
|
rearWheel.useMotor = false;
|
||||||
frontWheel.useMotor = false;
|
frontWheel.useMotor = false;
|
||||||
|
// RevEngine(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// audioSource.pitch = 1 +(Mathf.Abs(GetComponent<Rigidbody2D>().velocity.magnitude) / maxVelocity);
|
||||||
|
audioSource.pitch = Mathf.Lerp(audioSource.pitch, 1 +(Mathf.Abs(frontWheel.jointSpeed) / maxVelocity), EngineSFXsmooth);
|
||||||
|
|
||||||
|
|
||||||
if (Input.GetAxisRaw("Horizontal") != 0)
|
if (Input.GetAxisRaw("Horizontal") != 0)
|
||||||
{
|
{
|
||||||
GetComponent<Rigidbody2D>().AddTorque(carRotationSpeed * Input.GetAxisRaw("Horizontal") * 1);
|
GetComponent<Rigidbody2D>().AddTorque(carRotationSpeed * Input.GetAxisRaw("Horizontal") * 1);
|
||||||
@@ -135,4 +151,9 @@ public class carController : MonoBehaviour
|
|||||||
|
|
||||||
// CameraFollower.UpdateFrame();
|
// CameraFollower.UpdateFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// void RevEngine(float value){
|
||||||
|
// audioSource.pitch = Mathf.Lerp(audioSource.pitch, value, revSfxSpeed);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user