Rotating an object to match another object

Hi! I’ve been trying to figure this out for days on my own, and I’ve spent hours searching, but I’m not really sure what I should be searching for. :puzzled:

Here’s what I’m trying to do: I have one sprite that I can rotate freely, and a second one that rotates based on the first. So, for example, Sprite A is rotated from 0 degrees to 70 degrees. I want Sprite B to gradually adjust its rotation to match A’s using the shortest path. (Rotate clockwise 70 degrees, rather than rotating CCW 290 degrees.)

I’m intending for it to re-calculate the shortest direction on the fly, so using the previous example, if Sprite A was 70 degrees, and B was rotating toward 70 and currently at 50 degrees, and I suddenly rotated A to -20 degrees, B would switch directions rather than take “the long way.” (This part I should be able to figure out on my own once I understand the basic method, I’m just including it to make sure my intentions are clear.)

I hope my question is clear enough. If not, I’ll try and figure out how to clarify.

I felt like I was close at one point, but I just got the equation wrong somehow.

Thanks in advance for any help!