Help with getting gun to point at player + math

Could you elaborate more? Like have the nozzle in a separate model to the base?

Then the calculation needs to be either:
math.asin(white arrow / hypotenuse)

or:

local magnitude = math.sqrt(hypotenuse^2 - white arrow^2)

math.asin(magnitude / hypotenuse)

You need to convert the answer to degrees using math.deg though

1 Like

I’ve just accidentally done this by forgetting to comment out a line, and it appears to work? It doesn’t use the Hinge, but that’s fine with me. I think this is a solution

base.CFrame = CFrame.new(base.Position, Vector3.new(tHumPart.Position.X, base.Position.Y, tHumPart.Position.Z))
nozzle.CFrame = CFrame.new(nozzle.Position, tHumPart.Position)

Feel guilty for marking my own post as the answer, but thank’s a lot to @JohhnyLegoKing, @BuilderDolphin and @creepersaur for giving up your time

2 Likes

Yeah exactly. The base rotating is fine, but you can separate the nozzle into a model, making it the primary part of the model and using PivotTo() on that. It’ll make the maths way easier (hopefully), and you wont have to use hinges.

1 Like

Looks great to me :grin: 30charlimit

1 Like

Yea it works with just those two lines. Was expecting it to be way harder

1 Like

Appreciate your help, can’t believe we didn’t need all that trig after all. Also saves the use of HingeConstraints, since they are a bit glitchy!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.