GetMaxRadius() public static method

public static GetMaxRadius ( UnityEngine in_GameObjId ) : float
in_GameObjId UnityEngine
return float
Example #1
0
    // Use this for initialization
    void Awake()
    {
        m_agent = GetComponent <NavMeshAgent>();
        //surfaceStone.SetValue(this.gameObject);

        maxDistance = AkSoundEngine.GetMaxRadius(this.gameObject);

        currUnderground = Underground.Stone;
    }
Example #2
0
    void OcclusionCalc()
    {
        maxAtt      = AkSoundEngine.GetMaxRadius(gameObject); //getting attenuation data from sound source
        originPoint = transform.position;                     //coordinates of soundsource
        playerPoint = gameObjectPlayer.transform.position;    //coordinates of Player


        //we are gonna control occlusion only based on the wall thickness (distance between point of raycast hitting 1st wall and point of raycast goes out of the wall to hit the Player)

        if (distToPlayer <= maxAtt) //raycasting starts once Player is within the attenuation radius
        {
            targetDirection1 = playerPoint - originPoint;
            distToPlayer     = Vector3.Distance(playerPoint, originPoint);
            if (Physics.Raycast(originPoint, targetDirection1, out hitInfo1, distToPlayer, layerMask))
            {
                wallPointIn = hitInfo1.point;

                targetDirection2 = Vector3.zero - targetDirection1;
                if (Physics.Raycast(playerPoint, targetDirection2, out hitInfo2, distToPlayer, layerMask))
                {
                    wallPointOut = hitInfo2.point;
                    if (Physics.Raycast(playerPoint, Vector3.down, 2.0f, layerMask))
                    {
                        insideRoom = true;
                    }
                    else
                    {
                        insideRoom = false;
                    }
                }
                else
                {
                    wallPointOut = Vector3.zero;
                }
            }

            else
            {
                wallPointIn = Vector3.zero;
            }

            if (wallPointIn == Vector3.zero)
            {
                wwiseOcclusion = 0.0f;
            }

            else
            {
                wallThickness  = Vector3.Distance(wallPointOut, wallPointIn);
                wwiseOcclusion = wallThickness / maxWallThickness;
                if (insideRoom == true)
                {
                    wwiseOcclusion += 1.0f;
                }

                if (wwiseOcclusion > 1.0f)
                {
                    wwiseOcclusion = 1.0f;
                }
            }

            AkSoundEngine.SetObjectObstructionAndOcclusion(gameObject, gameObjectListener, 0.0f, wwiseOcclusion);
        }
    }