/// <summary> /// Try to nudge a downward pointing throw out of the player's way. /// </summary> /// <param name="carriable">The carriable being thrown.</param> /// <param name="direction">The normalized direction of the throw.</param> private void NudgeThrow(Carriable carriable, Vector3 direction) { // Raycast to check if the carriable would collide with the player. In // this case, we need to nudge the box out of the way to prevent it from // effecting the player's physics. Vector2 pos = carriable.Collider.transform.position; RaycastHit2D[] hits = Physics2D.RaycastAll(pos, direction, carriable.Physics.Velocity.magnitude); foreach (RaycastHit2D hit in hits) { if (hit.collider.CompareTag("Player") && player.IsHitBy(carriable.Collider)) { CalculateBackCast(carriable, direction); } } }