Example #1
0
    public void ShootWind()
    {
        windAnimator.TriggerGust();
        PositionWind();

        Vector3 mousePosition = PlayerAimWeapon.GetMouseWorldPosition();

        // working on a 2d game, rotation works differently

        Vector3 aimDirection = (mousePosition - transform.position).normalized;

        float angle = Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg;

        Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, new Vector2(5, 1), angle, interactables);

        foreach (Collider2D collider in hits)
        {
            Debug.Log(collider.name);

            IWindable wind = collider.transform.GetComponent <IWindable>();

            if (wind != null)
            {
                wind.Wind(aimDirection.normalized);
            }
        }
    }
Example #2
0
    public void WindBlast(Vector3 startPos, Vector2 direction)
    {
        RaycastHit2D hit = Physics2D.Raycast(startPos, direction, 100f, interactables);

        if (hit.collider != null)
        {
            Debug.Log(hit.collider.name);

            IWindable wind = hit.collider.GetComponent <IWindable>();

            Debug.Log("Wind Object Hit");
            wind.Wind(direction);
        }
    }