Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I keep my moving gun turret's position relative to another object?

Asked by 7 years ago

Alright, so I made this turret, that when you press a, it turns left by doing this:

script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,.01,0)

and when you press b, it turns right by doing the same thing but negated. Anyways, the point is, the turret moves, and I have no idea how to keep it steadily positioned on something. Of Course, I could anchor the whole thing, but I was thinking of putting it on a car or something, so the turret needs to be able to turn functionally like I already have done, but stay positioned relative to the object I need. Also, welding the turret to anything isn't an option because if I do, it will move that object with it. Thanks to anyone that can help me, this may seem a little vague, if you need more information just comment and I can get it to you.

0
A couple of ideas at the top of my head. You'll have to ditch your current directional script if you want to implement any of the following. You could hinge your turret to a foundation and use BodyAngularVelocity/BodyGyro to orient it through ROBLOX physics. You could weld the turret to its base and incrementally manipulate the weld's CFrame. Redbullusa 1580 — 7y
0
^ viltsuviltsu 4 — 7y
0
Thanks, helped a ton. Your_Momdotcom 91 — 7y

Answer this question