Added stretch and snap to slingshot
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user