private void AimUpdate()
    {
        Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        Plane plane = new Plane(Camera.main.transform.forward, transform.position + Camera.main.transform.forward * 20);

        float   distance;
        Vector3?aimPosition = null;

        if (plane.Raycast(mouseRay, out distance))
        {
            aimPosition = mouseRay.GetPoint(distance);
        }

        if (aimPosition.HasValue)
        {
            m_animator.SetAimDirection(Vector3.Normalize(aimPosition.Value - m_aimPoint.position));
        }
    }
Example #2
0
 private void Awake()
 {
     Initialize(gameObject);
     m_animator.SetAimDirection(transform.forward);
 }