コード例 #1
0
    private void findTargetLocationToFire()
    {
        MovingAgent humanoidOpponent = opponent as MovingAgent;

        if (humanoidOpponent != null && humanoidOpponent.isCrouched() && humanoidOpponent.isAimed())
        {
            targetLocation = humanoidOpponent.getHeadTransfrom();
        }
        else
        {
            int randomIndex = Random.Range(0, targetLocations.Length - 1);
            targetLocation = targetLocations[randomIndex].transform;
        }



        if (Random.value > m_selfAgent.getSkill())
        {
            randomOffset = Random.insideUnitSphere * 2;
        }
        else if (m_navMeshAgent.remainingDistance > 9)
        {
            randomOffset = Random.insideUnitSphere * 0.7f;
        }
        else
        {
            randomOffset = Vector3.zero;
        }
    }
コード例 #2
0
    /**
     * Get target position of the current aimed agent
     */
    private Vector3 getTargetPositionFromAgent()
    {
        MovingAgent humanoidAgent = m_currentTarget as MovingAgent;

        if (humanoidAgent == null)
        {
            return(m_currentTarget.getTopPosition());
        }
        else
        {
            if (humanoidAgent.isCrouched())
            {
                if (humanoidAgent.isAimed())
                {
                    return(m_currentTarget.getTopPosition());
                }
                else
                {
                    return(m_currentTarget.getCurrentPosition() + new Vector3(0, 0.6f, 0));
                }
            }
            else
            {
                return(m_currentTarget.getCurrentPosition() + new Vector3(0, 1.05f, 0));
            }
        }
    }