# Moving an object along a sine curve...

Hello. I want an object to move along a sine curve. I got this script from the forums (I tweaked it a little bit), but when I try to implement it I run into some problems. When the object’s initial y position is set to 0 and the Height variable is set to 3, the object slowly moves up to 3, dips back down to -3 and then continues back to 3. However, when I move the object’s initial y position to 1, the object peaks at 5 and dips down to -1 (the Height value is still set to 3). I want the object to move up to 4 and dip down to -2. What am I doing wrong? Thanks

``````private var m_centerPosition:Vector3;
private var m_degrees:float = 0;
private var m_speed :float = 1.0f;
private var m_period:float = 1.0f;

var Count : float;
var Speed : float;
var Height: float;

function Start (){
//16.7 is the world space that it takes to complete the Count Cycles.
m_period  = 16.7/Count;
m_speed  *= Speed;
m_period /= Speed;
m_centerPosition = transform.position;
}

function Update(){
m_centerPosition.x += Time.deltaTime * m_speed;
var degreesPerSecond:float = 360.0f / m_period;
m_degrees = Mathf.Repeat(m_degrees + (Time.deltaTime * degreesPerSecond), 360.0f);
``````var offset:Vector3 = Vector3(0.0f, m_centerPosition.y+Height * Mathf.Sin(radians), 0.0f);