I just published my project boost game which is in the show forums and I’m really proud of it but… I noticed a bug that is really easily seen by everybody and it annoys me. Starting on the 2nd lvl the projectiles go crazy every time you die. They shoot several at a time and as time passes the number of projectiles at the start increases. It doesn’t do this in the unity editor at all. Any idea?
using System.Collections.Generic;
using UnityEngine;
public class Projectiless : MonoBehaviour
{
[SerializeField] Rigidbody Projectile;
[SerializeField] Transform barrel;
[SerializeField] float speed = 5f;
[SerializeField] float spawnTimer = 5.0f;
float spawn;
void Start()
{
spawn += spawnTimer;
}
// Update is called once per frame
void Update()
{
ProjectileSpawning();
}
void ProjectileSpawning()
{
if (Time.time >= spawn)
{
Rigidbody projectileInstance;
projectileInstance = Instantiate(Projectile, barrel.position, barrel.rotation) as Rigidbody;
projectileInstance.AddForce(Vector3.down * speed);
spawn += spawnTimer;
}
}
}```