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;
}
};