I’m trying to make a game where if the player runs into different obstacles(Water, Fire) they will respawn at different locations. I know how to make a spawn point, but I don’t know how to link certain obstacles to certain spawn points. Can someone help?,I’m trying to make a game where different obstacles (Water, Fire) send the player back to different spawn points earlier in the level. I’ve made more than one spawn point, but I’m still not sure how to make the obstacles send you to a specific one.
public GameObject waterSpawnObject;
public GameObject fireSpawnObject;
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.CompareTag("Water"))
{
spawnPoint = waterSpawnObject.transform.position;
}
if(collision.gameObject.CompareTag("Fire"))
{
spawnPoint = waterSpawnObject.transform.position;
}
}
Dunno if this code will give you an idea. Here is also a good link to get an objects Vector3
link text