Exemplo n.º 1
0
    public void HaltAgent(DCAgent doomCube)
    {
        Rigidbody rigidbody = doomCube.GetComponent <Rigidbody>();

        rigidbody.velocity        = Vector3.zero;
        rigidbody.angularVelocity = Vector3.zero;
    }
Exemplo n.º 2
0
    public void PlaceAgent(DCAgent doomCube)
    {
        // Physics
        HaltAgent(doomCube);

        // Spawn zone
        int zone = Random.Range(0, 9);

        // Spawn position
        var newPosition = Vector3.zero;

        Collider[] hitColliders;
        bool       overlaps = false;

        float colliderRadius = doomCube.GetComponent <SphereCollider>().radius;

        do
        {
            newPosition  = ChooseRandomPosition(zone);
            hitColliders = Physics.OverlapSphere(newPosition, colliderRadius);
            overlaps     = false;

            foreach (Collider hitCollider in hitColliders)
            {
                DCAgent otherAgent = hitCollider.transform.GetComponent <DCAgent>();

                if (otherAgent != null)
                {
                    overlaps = true;
                }
            }
        } while (overlaps);

        doomCube.transform.position = newPosition;

        // Spawn direction
        doomCube.transform.rotation = ChooseRandomRotation();
    }