What about the script above, is that right? script name is drive
It’s right, but the script below is more optimized.
var Start = pc.createScript('start');
// initialize code called once per entity
Start.prototype.initialize = function() {
this.box = this.app.root.findByName('Box');
};
// update code called every frame
Start.prototype.update = function(dt) {
if (this.app.keyboard.isPressed(pc.KEY_W)) {
this.box.script.drive.enabled = true;
}
};
If you want to move the box directly without using the other script, you can replace line 11.
// move a kinematic rigidbody
this.box.translateLocal(-1, 0, 0);
it didn’t work
Can you share a link of your project please?
Have you figured out the problem yet?
I fixed it, it did not have a rigidbody.
1 Like