Hello. I am producing a game where I cannot get a very simple mechanic to work.
Basically, in the context of my project (An overhead Bullet Hell shooter produced in 3D); A Big Yellow Cube heads downwards and if the Player Touches it, the player dies and respawns at a set point.
The Coordinates have been set for this respawn point and the Player and Enemy definitely make contact when I run it. But the player does not respawn at the designated point and instead just phases through the big yellow cube to no effect.
Here is the script that I have attatched to the big yellow cube in it’s entirety:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerCollide : MonoBehaviour {
GameObject player = GameObject.FindWithTag("Player");
GameObject respawnPoint = GameObject.FindWithTag("Respawn");
// Use this for initialization
void Start () {
}
void onTriggerEnter(Collider other)
{
//When player collides with Enemy Object, Should Despawn and Respawn plyaer.
player.SetActive(false);
player.SetActive(true);
player.transform.position = respawnPoint.transform.position;
//Should Respawn the player on the "Respawn" Object.
}
}
Nothing I have done has managed to get this to work the way I want. I have no idea what to do. Please Help.