Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (selectedTurret != null && !this.selectedTurret.IsTurning)
        {
            RaycastHit hitInfo;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hitInfo, 1000.0f, terrainLayer))
            {
                Vector3 turretPos = this.selectedTurret.turretToRotateHorizontal.transform.position;
                // clamp the position to within the arc, then set it.
                this.transform.position = turretPos + selectedTurret.GetClampedDir(hitInfo.point, float.MaxValue);

                lineRenderer.SetPosition(0, this.transform.position);
                lineRenderer.SetPosition(1, turretPos);
            }
        }
    }