i usually dont script i usually build but i wanted to create something cool
I am trying to acheave a good sine wave for my breathing animation but i cant get sines to work and im using my own method for breathing wich is more of a triangle wave
local SineW = 0
local function Bsine ()
if Breath == true then
SineW = SineW + -0.0001
if SineW <=-0.025 then --lowest hight
Breath = false
end
end
if Breath == false then
SineW = SineW + 0.0001
if SineW >=-0.005 then -- highest hight
Breath = true
end
end
all the solutions i found on Dev-fourm and Dev-hub i havent really helped with it so i just made my own solution that i prefer not to use. it goes into a offset with Cframe data and i just add it in.
how would i execute a sine wave that i correct. {{This script is run in RenderStepped!}}
local INCREMENT = 0.05
local angle = 0
while true do
print(math.sin(angle))
angle = angle + INCREMENT
wait()
if angle >= (math.pi * 2) then
angle = 0
end
print(angle)
end
As x increases, y (angle) oscillates* between 1 and -1. You can use the value of math.sin(angle) in your script.
And as @Kacper pointed out, you’ll want to set angle to 0 when it reaches 2 * PI
Note : actual math
Isn’t y=sin(0.05 x pie x Y) the same frequency as what you sent because if so I’ll use this on a graphing calculator to visually check what it is.