Hello. I am trying “sined” wave on Motor6D and, i cant get them to go the opposite way.
Here’s my script.
--basically i want L5-L8 to go the opposite direction than L1-L4
local L1 = "N1"
local L2 = "N2"
local L3 = "N3"
local L4 = "N4"
local L5 = "N5"
local L6 = "N6"
local L7 = "N7"
local L8 = "N8"
spawn(function()
while wait() do
Offset = _G.BeamSine
end
end)
spawn(function()
x = 0
while true do
local waitspeed = 0.001
local xspeed = 0.10
wait(waitspeed)
x = x + xspeed
end
end)
spawn(function()
while wait() do
spawn(function()
for i,v in pairs(game.Workspace.Wash_Set:GetChildren()) do
if v.Name == L1 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*1+x)
end
if v.Name == L2 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*2+x)
end
if v.Name == L3 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*3+x)
end
if v.Name == L4 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*4+x)
end
if v.Name == L5 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*5+x)
end
if v.Name == L6 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*6+x)
end
if v.Name == L7 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*7+x)
end
if v.Name == L8 then
v.Motors.Pan.DesiredAngle = math.cos(Offset*8+x)
end
end
end)
end
end)
Make sure you convert your numbers to radians before doing trig on them. Otherwise, this should work as intended. Just remember that sin and cosine are not going to move in opposite directions, they are just 180* out of phase of each other. So sin(theta)-cos(theta) will always equal 0.
Update: I think you’re relying on sine and cosine to move in opposite directions. Instead, just pick sine or cosine for all calculations and feed those operators the numbers in a reverse order. This can very simply be achieved by doing ReversedNum=MaxNum-NormalNum. This should cause a motor to move in reverse order.
This works. I use tilt to (i use math.sin and turning the number in the middle into a negative. But the circle loop starts only on its part rotation. I need to to continue of its motor6d position. Ill show my script once i get home. So basically, how do i get the sine to continue of the current position of the motor6d?
local L1 = "N1"
local L2 = "N2"
local L3 = "N3"
local L4 = "N4"
local L5 = "N5"
local L6 = "N6"
local L7 = "N7"
local L8 = "N8"
spawn(function()
while wait() do
Offset = _G.BeamsSine
end
end)
spawn(function()
x = 0
while true do
local waitspeed = 0.001
local xspeed = 0.10
wait(waitspeed)
x = x + xspeed
end
end)
spawn(function()
while wait() do
spawn(function()
for i,v in pairs(game.Workspace.Wash_Set:GetChildren()) do
if v.Name == L1 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*1-x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-1+x+1.571)
--tried to make the tilt stay at 90 degrees
end
if v.Name == L2 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*2-x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-2+x)
end
if v.Name == L3 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*3-x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-3+x)
end
if v.Name == L4 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*4-x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-4+x)
end
if v.Name == L5 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*-4+x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-4+x)
end
if v.Name == L6 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*-3+x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-3+x)
end
if v.Name == L7 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*-2+x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-2+x)
end
if v.Name == L8 then
v.Motors.Pan.DesiredAngle = math.sin(Offset*-1+x)
v.Motors.Tilt.DesiredAngle = math.cos(Offset*-1+x)
end
end
end)
end
end)