Skip to main content
deleted 50 characters in body
Source Link

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition;
        for (int i = 0; i < 30; i++)
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5;
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f);
            randomPosition = temp;
            if (NavMesh.SamplePosition(randomPosition, out hit, 2f, NavMesh.AllAreas)
                && !InView(hit.position)
                && hit.position.y < friendPos.position.y + 2f
                && !LineOfSight(hit.position, friendPos.position - Camera.main.transform.forward * 5))
            {
                fsmBehaviour.transform.position = hit.position;
                fsmBehaviour.gameObject.GetComponent<NavMeshAgent>().ResetPath();
                break;
            }
        }

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition;
        for (int i = 0; i < 30; i++)
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5;
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f);
            randomPosition = temp;
            if (NavMesh.SamplePosition(randomPosition, out hit, 2f, NavMesh.AllAreas)
                && !InView(hit.position)
                && hit.position.y < friendPos.position.y + 2f
                && !LineOfSight(hit.position, friendPos.position - Camera.main.transform.forward * 5))
            {
                fsmBehaviour.transform.position = hit.position;
                fsmBehaviour.gameObject.GetComponent<NavMeshAgent>().ResetPath();
                break;
            }
        }

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition;
        for (int i = 0; i < 30; i++)
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5;
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f);
            randomPosition = temp;
            if (NavMesh.SamplePosition(randomPosition, out hit, 2f, NavMesh.AllAreas)
                && !InView(hit.position)
                && hit.position.y < friendPos.position.y + 2f
                && !LineOfSight(hit.position, friendPos.position))
            {
                fsmBehaviour.transform.position = hit.position;
                fsmBehaviour.gameObject.GetComponent<NavMeshAgent>().ResetPath();
                break;
            }
        }
added 312 characters in body
Source Link

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition, teleportPos;randomPosition;
        dofor (int i = 0; i < 30; i++)
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5; 
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f); ;
            randomPosition = temp;
        }
        whileif (!NavMesh.SamplePosition(randomPosition, out hit, .1f2f, NavMesh.AllAreas)
        ||        && !InView(hit.position));
        teleportPos =       && hit.position;position.y < friendPos.position.y + 2f
                && !LineOfSight(hit.position, friendPos.position - Camera.main.transform.forward * 5))
            {
                fsmBehaviour.transform.position = teleportPos;hit.position;
                fsmBehaviour.gameObject.GetComponent<NavMeshAgent>().ResetPath();
                break;
            }
        }

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition, teleportPos;
        do
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5; 
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f); ;
            randomPosition = temp;
        }
        while (!NavMesh.SamplePosition(randomPosition, out hit, .1f, NavMesh.AllAreas)
        || InView(hit.position));
        teleportPos = hit.position;
        fsmBehaviour.transform.position = teleportPos;

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition;
        for (int i = 0; i < 30; i++)
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5;
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f);
            randomPosition = temp;
            if (NavMesh.SamplePosition(randomPosition, out hit, 2f, NavMesh.AllAreas)
                && !InView(hit.position)
                && hit.position.y < friendPos.position.y + 2f
                && !LineOfSight(hit.position, friendPos.position - Camera.main.transform.forward * 5))
            {
                fsmBehaviour.transform.position = hit.position;
                fsmBehaviour.gameObject.GetComponent<NavMeshAgent>().ResetPath();
                break;
            }
        }
new code update
Source Link

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition, teleportPos;
        do
        {
            Vector3 temp = RandomfriendPos.insideUnitCircleposition - Camera.normalizedmain.transform.forward * 5f;5; 
            randomPositiontemp.x =+= Random.Range(-5f, 5f);
            temp.z ++= friendPosRandom.position;Range(-5f, 5f); ;
            randomPosition = temp;
        }
        while (!NavMesh.SamplePosition(randomPosition, out hit, .1f, NavMesh.AllAreas)
        || InView(hit.position));
        teleportPos = hit.position;
        fsmBehaviour.transform.position = teleportPos;

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition, teleportPos;
        do
        {
            Vector3 temp = Random.insideUnitCircle.normalized * 5f;
            randomPosition = temp + friendPos.position;
        }
        while (!NavMesh.SamplePosition(randomPosition, out hit, .1f, NavMesh.AllAreas)
        || InView(hit.position));
        teleportPos = hit.position;
        fsmBehaviour.transform.position = teleportPos;

This is what I've got so far. The problem is that with navmesh areas that are 2 story high, the SamplePosition can only find the top layer for some reason.

        Transform friendPos = fsmBehaviour.gameObject.GetComponent<vAICompanion>().friend.transform;
        NavMeshHit hit;
        Vector3 randomPosition, teleportPos;
        do
        {
            Vector3 temp = friendPos.position - Camera.main.transform.forward * 5; 
            temp.x += Random.Range(-5f, 5f);
            temp.z += Random.Range(-5f, 5f); ;
            randomPosition = temp;
        }
        while (!NavMesh.SamplePosition(randomPosition, out hit, .1f, NavMesh.AllAreas)
        || InView(hit.position));
        teleportPos = hit.position;
        fsmBehaviour.transform.position = teleportPos;
deleted 15 characters in body
Source Link
Loading
added 70 characters in body
Source Link
Loading
Source Link
Loading