Hello,
I’m doing this tutorial Procedural Cave Generation - Unity Learn
How can i spawn a player or object at random position once map is generated?
Hello,
I’m doing this tutorial Procedural Cave Generation - Unity Learn
How can i spawn a player or object at random position once map is generated?
using UnityEngine;
using System.Collections;
public class PlayerCreator : MonoBehaviour
{
public Transform player;
private Vector3 pos;
// Use this for initialization
void Start()
{
// Choose the player position from somewhere random on the map.
pos.x = Random.Range(-81, 55);
pos.y = -4;
pos.z = Random.Range(-39, 35);
GameObject.Instantiate(player, pos, player.transform.rotation);
}
void Update()
{
}
}
While using script above i can spawn player at random location. However it’s a Player(clone) and camera is not following clones. How to get rid of that?