Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

0

TANK YOU, KIND SIR!!!!!!!!!!!!!!!!!!!!!!

0

*thank

This discussion is preserved as it was. New answers, comments, and votes are closed.