Пример #1
0
 private void TickFree()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit, 100.0f))
         {
             Debug.Log("You selected the " + hit.transform.name); // ensure you picked right object
             _state = eSelectionState.SELECTED;
         }
     }
 }
Пример #2
0
    private void TickSelected()
    {
        Vector3 point = GetPointUnderMouse();

        Vector3 lineAngle = (point - transform.position);
        //Vector3 lineAngle = this.transform.position - point;

        // GameObject.Instantiate(PREFAB, point, Quaternion.identity);


        Vector3 direction = new Vector3(lineAngle.x, this.transform.position.y, lineAngle.z).normalized;

        Debug.DrawLine(this.transform.position, direction, Color.red, 10);


        if (Input.GetMouseButtonUp(0))
        {
            ShootBallInDirection(direction);
            _state = eSelectionState.FREE;
        }
    }