I making a trying yo make a follow spotlight that tracks/follows players. I am using motor6D, but I am not sure on how to do the maths to pan and tilt the head/beam to face the player. I am open for suggestions.
I ran a quick test and this is a proof of concept, I hardcoded my username but you could change it to look for the closest person.
I didn’t implement my own math, I just used
I guess you could also just set the CFrame for the turret itself too
local motor = script.Parent:WaitForChild("Motor6D") local plr = workspace:WaitForChild(USERNAME) -- PoC, just add your username local hrp = plr:WaitForChild("HumanoidRootPart") while wait() do local rot = CFrame.lookAt(script.Parent.Position, hrp.Position) motor.C1 = CFrame.new(0,1,0) * rot.Rotation end
I guess this won’t work for this person because it looks like he using 2 motor6d’s for pan and tilt
Ah, I see, I have a better example place if 2 Motor6Ds are required
motor6dturret.rbxl (33.3 KB)
this uses two motor6ds, although a similar thing could be done with just plain CFrames too
I would do that but then I cant use any other functions of the beams as it requires motors
This turret is exactly what im trying to do with the beams. When I try it, it breaks the motors, any ideas?
When I try it, it breaks the motors, any ideas?
I’m not sure I understand what breaking the motors means:
Do the motors say Active?
Make sure the turret pieces are not Anchored and also make sure the Motor6D.Part0 and Motor6D.Part1 are correct
You could also use this method for a Motor6D with yaw and pitch
I have never heard of this before, Would you mind explain please if that’s not a problem, because I’m not sure how that would work?
I believe you could theoretically use the
CFrame.lookAt() constructor and then use
Motor6D:Transform() to position and/or rotate the motor accordingly, though I have a feeling that it’s not that simple due to the distinct differences between “world position” and “relative position” with
I don’t work with Motor6D’s myself (mostly because I’ve been using my own tween module’s
Model:SetPrimaryPartCFrame() as a cheap alternative), so take my advice with a decently-sized grain of salt.
Spotlight Demo.rbxl (37.6 KB)
Here’s a demo spotlight that should do what you want. The script is located at
workspace.Spotlight.Script, feel free to adapt it to your needs.