i'm working on a 2D game and i want to make characters spawn from the door to enter the store the script i have keeps spawning them in circle unit which is not what i want. i want them to spawn from the door then i will assign movements to them to walk around the store later. what should i do to achieve spawning them inside a area that i want like shown in this picture.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterSpawn : MonoBehaviour
{
[SerializeField]
private float spawnRadius = 7, time = 1.5f;
public GameObject[] enemies;
void Start()
{
StartCoroutine(SpawnAnEnemy());
}
IEnumerator SpawnAnEnemy()
{
Vector2 spawnPos = GameObject.Find("Bengal").transform.position;
spawnPos += Random.insideUnitCircle.normalized * spawnRadius;
Instantiate(enemies[Random.Range(0, enemies.Length)], spawnPos, Quaternion.identity);
yield return new WaitForSeconds(time);
StartCoroutine(SpawnAnEnemy());
}
}
