Tuesday, August 30, 2022
HomeGame Developmentunity - What ought to I do to exclude objects getting instantiated...

unity – What ought to I do to exclude objects getting instantiated on a sure space inside the perimeter I’ve set?


    public class RocksSpawn : MonoBehaviour
{
    [SerializeField] GameObject PrefabRocks;
    [SerializeField] int Spawned;
    void Begin()
    {
        for (int i = Spawned; i > 0; i--)
        {
            SpawnRocks();
        }
    }

    void SpawnRocks()
    {
        Vector3 SpawnX = new Vector3(Random.Vary(40.2f, -124.75f), -0.58f, (Random.Vary(129.31f, -36.05f)));
        Instantiate(PrefabRocks, SpawnX, Quaternion.identification);
    }
}

this is the instance. There is a particular space I do not need it to spawn is inside that “SpawnX” I’ve put up, Any ideas what I ought to do? I used to be to place AABB bounds however, no tutorials have on this. Please let me know if there’ different different too.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments