Hiya, i’m trying to get a item to spawn in game using a trigger point however it doesn’t seem to work. No errors are running, and i’ve tried making the spawn method private…any help?
public class SpawnTriggerScript : MonoBehaviour {
public SpawnScript spawnScript;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.name=="Player")
{
Debug.Log ("Player Entered Trigger");
spawnScript.Spawn();
}
}
}
Spawn script—
public class SpawnScript : MonoBehaviour {
public GameObject spawnedObject;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Spawn()
{
Instantiate(spawnedObject,transform.position,Quaternion.identity);
}
}