I have my player flying through the scene correctly but would like to add a very minimal vertical Sin movement to the y-axis...so it looks like it's floating a little while flying (should go back and forth from moving up and down) Any help would be appreciated as I keep hitting a dead end.
So basically I want to get rid of the counter and transforming the position by 0.1 all the time and replace it with an appropriate sin value. private var hCtr = 0; function Hover() { if(hCtr >= 10) { transform.position.y -= (transform.position.y * 0.1) * Time.deltaTime; if(hCtr >= 20) { hCtr = 0; } } else { transform.position.y += (transform.position.y * 0.1) * Time.deltaTime; } hCtr++; }
try something like var amplitude:float; var frequency:float; transform.position += amplitude*(Mathf.Sin(2*Mathf.PI*frequency*Time.time) - Mathf.Sin(2*Mathf.PI*frequency*(Time.time - Time.deltaTime)))*transform.up; might be further optimizable.