Added stretch and snap to slingshot
This commit is contained in:
parent
1794d081dd
commit
5e9e2d7790
8
Assets/Audio.meta
Normal file
8
Assets/Audio.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df5a8dd98d1a3f7978206210c7573972
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Audio/snap.wav.meta
Normal file
22
Assets/Audio/snap.wav.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3bcc3f70685bc574ac5ac44459fe48f
|
||||
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:
|
22
Assets/Audio/stretch.wav.meta
Normal file
22
Assets/Audio/stretch.wav.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 858b2b16654e59e4c9ab8a854cc63a7d
|
||||
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:
|
@ -1260,6 +1260,7 @@ GameObject:
|
||||
- component: {fileID: 1540568165}
|
||||
- component: {fileID: 1540568166}
|
||||
- component: {fileID: 1540568167}
|
||||
- component: {fileID: 1540568168}
|
||||
m_Layer: 0
|
||||
m_Name: Slingshot
|
||||
m_TagString: Untagged
|
||||
@ -1314,10 +1315,110 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
prefabProjectile: {fileID: 7364702671587352604, guid: bdf63a487fce38097b5e77b912360559, type: 3}
|
||||
velocityMult: 8
|
||||
stretchBandSound: {fileID: 8300000, guid: 858b2b16654e59e4c9ab8a854cc63a7d, type: 3}
|
||||
snapBandSound: {fileID: 8300000, guid: e3bcc3f70685bc574ac5ac44459fe48f, type: 3}
|
||||
launchPoint: {fileID: 0}
|
||||
launchPos: {x: 0, y: 0, z: 0}
|
||||
projectile: {fileID: 0}
|
||||
aimingMode: 0
|
||||
audioSource: {fileID: 0}
|
||||
volume: 0.5
|
||||
--- !u!82 &1540568168
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1540568164}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
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!1 &1695677383
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -8,6 +8,8 @@ public class Slingshot : MonoBehaviour
|
||||
[Header("Set in Inspector")]
|
||||
public GameObject prefabProjectile;
|
||||
public float velocityMult = 8f;
|
||||
public AudioClip stretchBandSound;
|
||||
public AudioClip snapBandSound;
|
||||
// fields set dynamically
|
||||
[Header("Set Dynamically")]
|
||||
public GameObject launchPoint;
|
||||
@ -15,6 +17,8 @@ public class Slingshot : MonoBehaviour
|
||||
public GameObject projectile;
|
||||
public bool aimingMode;
|
||||
private Rigidbody projectileRigidbody;
|
||||
public AudioSource audioSource;
|
||||
public float volume = 0.5f;
|
||||
static public Vector3 LAUNCH_POS {
|
||||
get {
|
||||
if (s == null) return Vector3.zero;
|
||||
@ -48,6 +52,8 @@ public class Slingshot : MonoBehaviour
|
||||
// Set it to isKinematic for now
|
||||
projectileRigidbody = projectile.GetComponent<Rigidbody>();
|
||||
projectileRigidbody.isKinematic = true;
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
audioSource.PlayOneShot(stretchBandSound, volume);
|
||||
}
|
||||
void Update() {
|
||||
// If Slingshot is not in aimingMode, don't run this code
|
||||
@ -81,6 +87,7 @@ public class Slingshot : MonoBehaviour
|
||||
MissionDemolition.ShotFired();
|
||||
ProjectileLine.s.poi = projectile;
|
||||
slingshotBand.SetPosition(1, new Vector3(0,0,0));
|
||||
audioSource.PlayOneShot(snapBandSound, volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user