Actually it might just be the box cast that’s “wrong”. Right now it’s position is in the middle of the character, (the rotation aligns) so you need to make it reposition to work with the pivot. What this will do is make it so the boxcast the same as the gizmo (which I guess is what you want to do). Let me sketch it up.
That is how it looks right now. The arrow is the mouse, the dotted lines as the gizmos, the full lines are the rat cast and the point is the player.
This is how we want to move the boxcast. In the same angle as the gizmo, half the length of the boxcast (that might be the width or height I’m not sure).
So we want to take the angle of the cast, convert it to a vector, set that vectors magnitude to be half the length of the boxcast and then offset the boxcast by that vector. In code it would be something like:
Vector2 offset = new Vector2(cos(angle), sin(angle)); offset = offset * length / 2; Vector2 positionOfCast = transform.position + offset;