I want an entity to rotate a specific amount, but is continuously rotating

I have a code that I want to rotate to 160, then to 180, but it is rotating continuously. I haven’t bee online that often, so I ned a refresher on how to fix this.

var Legs = pc.createScript('legs');

// initialize code called once per entity
Legs.prototype.initialize = function() {
    value1 = 160;
    value2 = 180;
    mumb1 = 0.01;
    mumb2 = -0.01;
};

// update code called every frame
Legs.prototype.update = function() {
    this.entity.findByName("thigh1").rotateLocal(value1, 0, 0);
    this.entity.findByName("thigh2").rotateLocal(value2, 0, 0);
    this.entity.findByName("thigh3").rotateLocal(value2, 0, 0);
    this.entity.findByName("thigh4").rotateLocal(value1, 0, 0);
    if (this.app.keyboard.isPressed(pc.KEY_UP)){
        value1 += mumb1;
        value2 += mumb2;
    }
    if (value1 <= 160) {
        mumb1 = 0.01;
    }
    if (value1 >= 180) {
        mumb1 = -0.01;
    }
    if (value2 <= 160) {
        mumb2 = 0.01;
    }
    if (value2 >= 180) {
        mumb2 = -0.01;
    }
};

Hi @Kyle_3_1415,

If you’d like to rotate your entity just once, then you should be running your code in initialize or an event handler that executes a single time (e.g. on keyboard up).

Sorry, been busy for a long time… What I mean is I want it to move +20 degrees on keypress, than -20 degrees on another keypress.