Hi, this is my solution. I’ll see what Rick did now.
One thing I’m not sure about is if it is good practice to do this in a separate script altogether, such as a Debug Script.
public class CollisionHandler : MonoBehaviour
{
[SerializeField] float loadLevelDelay = 2f;
[SerializeField] AudioClip spaceShipCrash;
[SerializeField] AudioClip successClip;
[SerializeField] bool isDebug = true;
[SerializeField] ParticleSystem spaceShipCrashParticlesFX;
[SerializeField] ParticleSystem successParticlesFX;
AudioSource audioSource;
bool isTransitioning = false;
bool isCollision = true;
Movement movement;
private void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void Update()
{
if (isDebug)
{
if (Input.GetKey(KeyCode.C))
{
isCollision = !isCollision;
Debug.Log("Colliosion is, " + isCollision);
}
if (Input.GetKey(KeyCode.L))
{
LoadnextLevel();
Debug.Log("Next Level");
}
}
}
private void OnCollisionEnter(Collision collision)
{
if (!isTransitioning && isCollision)
{
switch (collision.gameObject.tag)
{
case "Friendly":
break;
case "Fuel":
break;
case "Finish":
SuccessSequence();
break;
case "Ball":
break;
default:
CrashSequence();
break;
}
}
}