I wrote a script modifying a very useful one that I wrote to make a Cube float up and down. This script is supposed to make the cube float left and right, but for some reason when it gets all the way to the right it just sits there and quivers. Can someone take a look at my script and tell me what’s wrong? Thanks!
var min = -4.4;
var max = -12;
var right = true;
function Update () {
if (transform.position.x < min) {
right = true;
}
if (transform.position.x > max) {
right = false;
}
if (right == true) {
transform.position += Vector3.right * Time.deltaTime;
}
if (right == false) {
transform.position += Vector3.left * Time.deltaTime;
}
}