Ejemplo n.º 1
0
    public static NavMeshPathEx CalculatePath(this Lego_Character character, GameObject destination)
    {
        var path = new NavMeshPath();
        var dist = Vector3.Distance(character.transform.position, destination.transform.position);

        character.GetComponent <NavMeshAgent>().CalculatePath(new Vector3(destination.transform.position.x, 0, destination.transform.position.z), path);

        var length = path.Length(dist);

        return(new NavMeshPathEx
        {
            NavPath = path,
            Length = length,
            Object = destination
        });
    }