I cant manage to move the car in my project. I can’t figure out how to do it.Can anyone help me script it’s 4 way movement?
I see your control script is failing because toward the bottom you have
KeyboardHandler.prototype.onKeyDown being used in the script, but your script is defined as :
var Control = pc.createScript(‘control’);
You will want to remove the “KeyboardHandler” parts of your script or rename them to Control to match the script your created at the beginning of the file.
Edit: Actually after seeing your intialize function :
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this); this.app.keyboard.on(pc.EVENT_KEYUP, this.onKeyUp, this); this.app.keyboard.on(pc.EVENT_LEFT, this.onKeyLeft, this); this.app.keyboard.on(pc.EVENT_RIGHT, this.onKeyRight, this);
It looks like you want to use those functions rename any “KeyboardHandler” sections to Control. Here’s an example. KeyboardHandler.prototype.onKeyDown becomes Control.prototype.onKeyDown
Thanks , that helped.