Hey guys and girls.
I’ve got this roll a ball game and i made a killCube that destroys the player Ball when it touches it.
According to my script it respawns the ball at Vector3.zero but i want it to respawn on an empty gameObject to my choosing.
this is my current KillCube script:
public class KillCube : MonoBehaviour {
void OnCollisionEnter(Collision player)
{
if (player.gameObject.name == "player") {
player.gameObject.SetActive (false);
}
}
}
and this is my current respawn script:
public class Respawn : MonoBehaviour {
public GameObject player;
public Transform spawnpoint;
void Start() {
spawnpoint = player.transform;
}
void Update()
{
if (player.gameObject.activeInHierarchy == false)
{
player.transform.position = Vector3.zero;
player.SetActive (true);
}
}
}
it should be possible to spawn the ball back at the empty gameobject “spawnpoint” right? i just can’t figure out how to do that.