of     1   

Omnisxiii2
#220177547Saturday, July 01, 2017 6:55 AM GMT

I'm working on some turrets for a naval game...they operate on HingeConstraints. I've figured out (somehow) how to make the turrets aim in the right X and Z axis, but I'm still figuring out how to calculate the appropriate elevation angle. In other words, how could I use the Dot product to calculate the angle between ### ####### height? I've tried inputting it all manually as trigonometry but for some reason it's not working out the way it's supposed to, and I suspect that would lag quite a bit.
Omnisxiii2
#220217440Saturday, July 01, 2017 7:21 PM GMT

bump
ExtremeBuilder15
#220217630Saturday, July 01, 2017 7:23 PM GMT

How do you currently make them aim on the X and Z axis?
FPSPwnz0r
#220218960Saturday, July 01, 2017 7:39 PM GMT

I think I asked a similar question a while ago, don't know if it's the same thing because of the tags though https://forum.roblox.com/Forum/ShowPost.aspx?PostID=218130608 cntkillme: "local initialCF = topPart.CFrame -- while wait() do ?? if bottomPart moves. here i assume toppart doesn't move local vecA = initialCF.lookVector local vecB = (topPart.Position - bottomPart.Position).unit local angle = math.acos(vecA:Dot(vecB)) topPart.CFrame = CFrame.new(topPart.Position) * CFrame.Angles(angle-math.pi, 0, 0) -- end" R$1
Omnisxiii2
#220231278Saturday, July 01, 2017 10:21 PM GMT

I'm using Hinge Constraints, not welds Therefore I need to find the exact angle in degrees I already know I can use math.deg tho
ExtremeBuilder15
#220248407Sunday, July 02, 2017 2:37 AM GMT

I looked through an old project and found this function: function ###################### local deltaY = Y2-Y1 local ###### # ##### return math.deg(math.atan2(deltaY,deltaX)) end This might be of some help
ExtremeBuilder15
#220248516Sunday, July 02, 2017 2:38 AM GMT

lol function myFunction(xPos1, yPos1, xPos2, yPos2) local deltaY = yPos2-yPos1 local deltaX = xPos2-xPos1 return math.deg(math.atan2(deltaY,deltaX)) end

    of     1