My beautiful drawings will explain better than many words (or at least I hope):
The structure:
- The black rectangle is a GameObject (my weapon sprite).
AandBare also GameObjects (children of black rectangle):StartShotPointandShotPointused 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 Vector2 destination 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.



transform.LookAtor simplyVectorB - VectorAto find the direction and then the angle, because the direction must be given byAandB(go throughAandB) by rotating the rectangle (father ofAandB). Or at least I can't find the correct way for useLookAtin my case (similar in concept, but very different in the specific case). \$\endgroup\$Vector3 FakeTarget = new Vector3(RealTarget + (ShotPoint - Rectangle.position));anddirection = FakeTarget - Rectangle.postion. I don't know how to thank you !!! Indeed, yes I know ... Write the answer and I'll accept it :). Thanks again. \$\endgroup\$