hi there, i have script that has 2 public array variables called spawnPoints and spawnObjects, i have 9 spawnPoints and 4 spawnObjects. These 4 spawnObjects are placed on 4 spawnPoints. Here what i am doing is whenever i press the mouse button i m changing the position of spawnObjects to other spawnPoints, its working fine but the spawnObjects are overlapping some times.
please can anyone rewrite this code
using UnityEngine;
using System.Collections;
public class Forward : MonoBehaviour
{
public GameObject[] spawnPoint;
private GameObject spawn;
public GameObject[] spawnObjects;
private GameObject objectSpawn;
void Update ()
{
if (Input.GetMouseButtonDown (0)) {
int a = Random.Range (0, spawnPoint.Length);
int b = Random.Range (0, spawnObjects.Length);
spawn = spawnPoint [a];
objectSpawn = spawnObjects **;**
objectSpawn.transform.position = spawn.transform.position;
}
}
}