Change height of a sine wave?
I have an object moving up and down on a sine wave via it's Y-axis. The range of vertical motion isn't enough, however. Anyone know how to stretch the sine wave vertically? Thanks!
#pragma strict
var Step : float; //A variable we increment
var Offset : float; //How far to offset the object upwards
function Start () {
//Store where we were placed in the editor
var InitialPosition = transform.position;
//Create an offset based on our height
Offset = transform.position.y + transform.localScale.y;
}
function FixedUpdate () {
Step +=.05;
//Make sure Steps value never gets too out of hand
if(Step > 99999){Step = 2;}
//Float up and down along the y axis,
transform.position.y = Mathf.Sin(Step)+Offset;
}
Comment