Пример #1
0
    public void SpawnTarget()
    {
        var newPosition = transform.position + GetRandomPosition();
        var collision   = Physics.OverlapBox(newPosition, new Vector3(1f, 1f, 1f)).Where(x => x.name != "TargetDetector").ToList();

        if (collision.Count == 0)
        {
            var newTarget = TargetFac.GetTarget();
            if (newTarget != null)
            {
                newTarget.Reset(_settings.max_shoots_alive);
                newTarget.transform.position = newPosition;
                newTarget.transform.parent   = transform;
                newTarget.transform.GetComponent <Rigidbody>().isKinematic = false;
                newTarget.transform.GetComponent <Rigidbody>().velocity    = GetRandomSpeed();
                //spawned = true;
                _targetsScene.Add(newTarget);
                _targetsInScene++;
            }
        }
    }