Hello all,
In our new game, I am trying to rotate a wheel when the key D is pressed. Code is below.
var WheelRotation = pc.createScript('wheelRotation');
// initialize code called once per entity
WheelRotation.prototype.initialize = function() {
};
// update code called every frame
WheelRotation.prototype.update = function(dt) {
if (this.app.keyboard.isPressed(pc.KEY_D)) {
this.entity.rotateLocal(10, 0, 0);
}
};
// swap method called for script hot-reloading
// inherit your script state here
// WheelRotation.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/
As evident, the code is extremely simple. However, the wheel does not rotate perfectly - https://launch.playcanvas.com/838901?debug=true - the tyre and rim are rotating at different speeds.
I am trying to keep the Wheel Parent in the center of the ‘treckter’ model, but I am not getting the perfect center position. The rim and the tyre are separate meshes. Is there any way I could solve this issue?