# Rotating an object to match another object

**URL:** <https://forum.kirupa.com/t/rotating-an-object-to-match-another-object/310525>\
**Category:** flash\
**Created:** [June 12, 2010, 12:48pm UTC](https://forum.kirupa.com/t/rotating-an-object-to-match-another-object/310525 "2010-06-12T12:48:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caffeen](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@Caffeen](https://forum.kirupa.com/u/Caffeen)\
**Post date:** [June 12, 2010, 12:48pm UTC](https://forum.kirupa.com/t/rotating-an-object-to-match-another-object/310525/1 "2010-06-12T12:48:28Z")

</div>

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!
