Hi Everyone,
I’m totally new to coding and Unity. I’m going through the Space Shooter tutorial and am having some issues with changes from version 4 and 5 of Unity. For example, the below code is supposed to work in unity 4 but when I use this in unity 5 it says my explosion variable has not been assigned.
I believe there has been changes in how you write code for Instantiate judging by the API reference pages on it but I don’t fully understand it yet.
Any help would be greatly appreciated.
Thanks!
using UnityEngine;
using System.Collections;
public class DestroyByContact : MonoBehaviour
{
public GameObject explosion;
public GameObject playerExplosion;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Boundary")
{
return;
}
Instantiate(explosion, transform.position, transform.rotation);
if (other.tag == "Player")
{
Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
}
Destroy(other.gameObject);
Destroy(gameObject);
}
}