My beautiful drawings will explain better than many words (or at least I hope):
- The black rectangle is a GameObject (my weapon sprite).
Bare also GameObjects (children of black rectangle):
ShotPointused for the direction of my projectile.
Cis the first hypothetical target
In this situation my sprite will be rotate of 0 degree.
In this second image there is the question. I want to find the rotation of my sprite (-10 degree in the example) knowing the
D and of course all the coordinates of the 3 GameObjects.
The situation is simple as long as the player rotates the weapon, but in this case is the AI (after finding the player at the point
D) must turn the weapon in the right direction. I know how to find the direction between one point and another, but between two decentralized points and a third one messed up my brain.
I really don't know which "direction" to take.
Thanks for your help.