diff --git a/Assets/AssetsFORELLE/Script/KitchenGun.cs b/Assets/AssetsFORELLE/Script/KitchenGun.cs index 9a0da40..01ec075 100644 --- a/Assets/AssetsFORELLE/Script/KitchenGun.cs +++ b/Assets/AssetsFORELLE/Script/KitchenGun.cs @@ -1,12 +1,15 @@ using System.Collections; using UnityEngine; +using UnityEngine.Serialization; public class KitchenGun : MonoBehaviour { // The shot projectiles public GameObject projectilePrefab; // Time between shots, game needs to be restarted to take effect - public float shotInterval = 1f; + public float shotIntervalSeconds = 1f; + // Time alive for the projectiles + public float shotAliveSeconds = 1f; // Speed of projectiles public Vector2 shotSpeed = new Vector2(1f, 0f); // Smallest step size for shot speed @@ -15,7 +18,7 @@ public class KitchenGun : MonoBehaviour // Start is called before the first frame update void Start() { - InvokeRepeating("RecurringBang",0f,shotInterval); + InvokeRepeating("RecurringBang",0f,shotIntervalSeconds); } // Update is called once per frame @@ -43,15 +46,14 @@ public class KitchenGun : MonoBehaviour if (t.localScale.x < 0) { force *= -1; } - force *= shotSpeedStepSize; // add force to projectile Rigidbody2D pBody = projectile.GetComponent(); pBody.AddRelativeForce(force); - yield return new WaitForSeconds(shotInterval); - Debug.Log("Bang!"); + // wait given time before destroying + yield return new WaitForSeconds(shotAliveSeconds); Destroy(projectile); }