# arc object's position using sin

How would I convert this into Javascript.
Right now this work inside of 3ds Max as is.

the number 12 references to 12 frames a second. So the for loop goes frame by frame.
the number 20 refers to how high on the y position the object will go at it’s peak

for i = 0 to 12 do
(
y = abs(sin(180.0*i/12))*20.0
)

In unity I’m not sure how to right it out since there is the time.deltaTime thing.
For my case I want the arc to take course of the life of 2 seconds.

My attempt in javascript

``````private var counter = 0.0;

function Start () {
InvokeRepeating("IncreaseCounter", 1.0, 1.0); //adds X to 'counter' each second
}

function IncreaseCounter () {
counter += 1.0;
}

function Update () {
stepY = ( Mathf.Abs( Mathf.Sin(180.0*counter / Time.deltaTime)) * 5.0);
transform.position.y = stepY;
}
``````

o The math keys of off the angle going from 0 to 180. To get it to take 2 seconds, set the angle to: `180*timePassed/2`. Check: when `timePassed` is 2, 180*2/2 = 180.

o Real trig uses radians, not degrees, so before you use sin you have to convert by multiplying the angle by `Math.DegToRad` (which is really just 2PI/360.)

o To get the time that passed, grab the current time, and count from there:

``````var startTime : float;

// In Start:
startTime = Time.time; //  Grab the time the shot started

// In Update:
var timePassed : float = Time.time - startTime;
``````

The you can use `timePassed` and the 2-second angle in radians in your sin function. Of course, lots of other ways to write the same thing.