Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Aiming turret (math question)

$
0
0
I really can't figure out the angles needed to aim a certain turret rig I have. The skeleton looks like first image. The red arrow is pointing to the joint that is used to aim (via skeletal controller) and the blue arrow is pointing to the joint that needs to be aimed ie this joints forward x vector needs to point to the target. When aimed the turret likes like the second image. The red dot is the red joint being controlled and the blue dot is the blue joint being aimed. I just can't seem to calculate theta as a function of (x,y) the targets position. So the first thing I tried is the math in third image. The first line we get from the law of sines, the second line is just the definition of tangent, the third line is plugging the first equation into the second, and the fourth line is obtained from the general formula for a linear combination of sine and cosine (https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Linear_combinations). The last line is theta as a function of (x,y) simplified which is my goal. But trying all this out in UE4 I get something that's obviously not correct (see last image). I have a feeling the math is wrong. Math isn't really my wheelhouse and I'm surprised I even came up with anything even it appears wrong. Anyone able to tell me what stupid overcomplicated mistake I'm making in the math? I would really like an analytical solution and not just iteratively error correct it into aiming correctly. I would really appreciate a pair of eyes on this. Thanks!

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>