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

long title short, i need help with turret scripting???

Asked by 3 years ago
Edited 3 years ago

Essentially, I have this turret and it is working fine excpet for the gun iteslf. \The turret workss by rotationg on its base to face the target. Then, the gun will use an x rotation to face the target so it can shoot. How would i go about calculating the angle i need for the gun thing to face the target, after the base is facing its zy coordinates? Once again, gun can only rotate on x axis.

Help is needed, thx.

1 answer

Log in to vote
1
Answered by
DollorLua 235 Moderation Voter
3 years ago
Edited 3 years ago

You could probably construct a CFrame using CFrame.new(Vector3 Pos, Vector3 Lookat) and if you want to lock any axis, do:

local pos = Vector3.new() -- set these variables accordingly
local Lookat = Vector3.new()

local turret = workspace.Turret -- The turret

local facing = CFrame.new(pos, Lookat)

-- set turret's CFrame to facing
-- extract the orientation, set Y and Z rotation to a fixed number or whatever axis's you want locked
-- once those are set, you have rotation on only the X axis.

0
TANK YOU, KIND SIR!!!!!!!!!!!!!!!!!!!!!! R_LabradorRetriever 198 — 3y
0
*thank R_LabradorRetriever 198 — 3y
Ad

Answer this question