I have a problem with the angle of my arrow when shooting it because the angle of my arrow is on its side whenever I shoot.
Here’s my game:
(PlayCanvas | HTML5 Game Engine)
I have a problem with the angle of my arrow when shooting it because the angle of my arrow is on its side whenever I shoot.
Here’s my game:
(PlayCanvas | HTML5 Game Engine)
Hi @Pixels!
Below your code with some minor changes.
var ShootBullet = pc.createScript('shootBullet');
ShootBullet.attributes.add('bulletEmitter',{type:'entity'});
// initialize code called once per entity
ShootBullet.prototype.initialize = function() {
};
// update code called every frame
ShootBullet.prototype.update = function(dt){
if (this.app.keyboard.wasPressed(pc.KEY_SPACE) || this.app.keyboard.isPressed(pc.MOUSEBUTTON_LEFT)) {
var BulletFromTheAsset = this.app.assets.get(121685507);
var BulletInstance = BulletFromTheAsset.resource.instantiate();
this.app.root.addChild(BulletInstance);
var BulletPosition = this.bulletEmitter.getPosition();
var BulletRotation = this.bulletEmitter.getRotation();
BulletInstance.rigidbody.teleport(BulletPosition, BulletRotation);
this.force = new pc.Vec3();
this.force.copy(BulletInstance.right).scale(1000);
BulletInstance.rigidbody.applyForce(this.force);
}
};