Пример #1
0
    // Update is called once per frame
    void Update()
    {
        //Solo cuando se ponga una textura de agua
        if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            //Poner Path
            Ray        myRay = raycastCamera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;

            LayerMask layerMask = 1 << LayerMask.NameToLayer("Terrain");
            if (Physics.Raycast(myRay, out hitInfo, 10000, layerMask))
            {
                Vector3 hitPosition = hitInfo.point + Vector3.up * heightOffset;

                GameObject go       = Instantiate(nodePrefab, hitPosition, Quaternion.identity) as GameObject;
                MoveNodes  moveNode = go.AddComponent <MoveNodes>();
                moveNode.Init(raycastCamera, heightOffset, this);
                pathNodes.Add(go.transform);

                Debug.DrawLine(myRay.origin, hitPosition);

                if (pathNodes.Count > 1)
                {
                    RegenerateAuxNodes();
                }
            }
        }
        if (Input.GetKey(KeyCode.R))
        {
            RegenerateAuxNodes();
        }
    }
Пример #2
0
    public void CreatePathNodeAt(int index, Vector3 position)
    {
        GameObject go       = Instantiate(nodePrefab, position, Quaternion.identity) as GameObject;
        MoveNodes  pathNode = go.AddComponent <MoveNodes>();

        pathNode.Init(raycastCamera, heightOffset, this);
        pathNodes.Insert(index, go.transform);
        RegenerateAuxNodes();
    }