我有一个创建对象并将其显示在场景上的方法。唯一的问题是,我发送给创建的对象的点有时会重叠,因此这些对象也会重叠。
private IEnumerator doBallSpawn()
{
while (currentBallsCount < maxBallsIndex)
{
Vector3 pos = new Vector3(UnityEngine.Random.Range(MinX, MaxX), -8f, 0f);
ObjectSequence ball = Instantiate(BallSequence, pos, Quaternion.identity) as ObjectSequence;
ball.setCurrentChildIndex(BallColorRandom.getRandom());
Vector3 goPosition = new Vector3(UnityEngine.Random.Range(MinX, MaxX), UnityEngine.Random.Range(MinY, MaxY));
ball.transform.DOMove(goPosition, moveDuration);
currentBallsCount++;
ball.gameObject.GetOrAddComponent<SequenceMouseEvent>().MouseEvent += BallClickEvent;
yield return new WaitForSeconds(delay);
}
}
goPosition
是我唯一需要更改的东西,但我不知道如何更改。