# How do I make an arrow line up with a bow when rotating them?

I am trying to create a bow and arrow animation in which the player can drag downwards to increase the bow strength (see the image) and release it to hit a target. I can't get the arrow to align with the bow when the arrow's height is changed (third image). I am rotating both the bow and arrow around their respective origins (w/2, h/2).

What is the correct way to do it?

• you should rotate the arrow around the bows origin. Basically you would be parenting the arrow to the bow (so all bow movement and rotation would get propagated to the arrow). Commented Apr 24, 2013 at 18:51

Since the arrow is rotating around a center point (the same point of the bow), when you draw back on the bow, you need to keep the center point at the same point as the bow, but move the arrow back across it.

That way, you're rotating both the bow and arrow around the same point.

• i am rotating both bow and arrow at the same point but when i move the arrow back, the centre point of arrow changes naturally. Commented Apr 24, 2013 at 17:26
• When you move the arrow back, you have to keep the centre point of the arrow the same as the centre point of the bow. This means they are still rotating around the same point, and are at the same place as well, assuming you're drawing where the centre point/origin is. Commented Apr 25, 2013 at 2:21
• When i keep the centre of both arrow and bow same, at one point the arrow starts to rotate slower since its new center will be farther than the its older point.hence error occurs as shown in image 3. Commented Apr 30, 2013 at 7:19

If the arrow is of different dimensions than the bow the point which it should rotate around should not be its own center but rather the around the same point of rotation the bow rotates around, which might very well be outside the image of the arrow.

• Or to put it another way: There are two parameters to rotation: A point and an angle. If your bow and arrow are supposed to rotate together, make sure they're rotating by the same angle around the same point.
– Anko
Commented Apr 24, 2013 at 11:26
• @Anko It works only when the arrow is not being moved vertically. Commented Apr 24, 2013 at 13:09
• The movement of the arrow should always be perpendicular to the direction of the length of the bow. Hence you should only be moving the arrow vertically when the bow is horizontal. Are you doing that and keeping their points of rotation the same?
– Anko
Commented Apr 24, 2013 at 20:48
• the arrow works well when the bow is perfectly horizontal. But when the bow is tilted to either right or left(see 3rd image), they get misaligned. Both are rotated at the same point but arrow's centre will never be the same since it needs to move vertically. Commented Apr 30, 2013 at 7:17

Try setting up a rotation matrix for both sprites.

Rotation matrix - Wikipedia

Set the point to where you want to rotate. Although to make it an easier point of reference, I would rotate at the point where the bow crosses the arrow.

If i knew what language you're programming in I could look up more information to help. If you haven't worked with matrices yet, do a search for the language you're using and graphics matrix. Eg "c# graphics matrix".