this is my shooting script
var GunShoot = pc.createScript('gun');
GunShoot.prototype.update = function(dt) {
var app = this.app;
this.pistol = this.app.root.findByName('pistol');
if(this.app.keyboard.wasPressed(pc.KEY_R)) {
this.magsizeP = 12;
}
if (this.app.root.findByName('pistol').enabled === true) {
// shooting code
if (this.app.mouse.isPressed(pc.MOUSEBUTTON_LEFT)) {
// shoot
if (this.magsizeP !== 0) {
var bullet = this.app.root.findByName('bulletP').clone();
this.app.root.addChild(bullet);
bullet.reparent(this.app.root);
bullet.setPosition(this.app.root.findByName('bulletP').getPosition());
bullet.setRotation(this.app.root.findByName('bulletP').getRotation());
bullet.enabled = true;
console.log(bullet);
// update magazine
this.magsizeP = this.magsizeP - 1;
}
}
}
};
and can i add recoil?