Why is my shooting bullet not working properly?

Hi! I’m making an FPS game, but for some reason, my gun won’t shoot properly. It looks like it’s falling down on the ground, rather than shooting objects.

This is my code:

var ShootBulletScript = pc.createScript('shootBulletScript');
ShootBulletScript.attributes.add('bulletEmitter',{
    type:'entity',
});

// initialize code called once per entity
ShootBulletScript.prototype.initialize = function() {

};

// update code called every frame
ShootBulletScript.prototype.update = function(dt) {

    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        
        var bulletFromTheAsset = this.app.assets.get(137934526);
        var bulletInstance = bulletFromTheAsset.resource.instantiate();
        this.app.root.addChild(bulletInstance);

        var bulletPosition = this.bulletEmitter.getPosition();
        
        bulletInstance.rigidbody.teleport(bulletPosition);

        this.force = new pc.Vec3();
        this.force.copy(this.entity.forward);
        this.force.copy(this.entity.forward).scale(800);

        bulletInstance.rigidbody.applyForce(this.force);
        }
};

This is my hierarchy for the gun:

Thank you!

Hi @zero2,

Try using applyImpulse instead of applyForce and adjust the amount you apply. From the manual:

“Apply an impulse (instantaneous change of velocity) to the body at a point.”

Impulse is used when changing the motion state in a single instance whereas force is applied to longer periods of time.

And of course make sure your bullet entity has a collision and dynamic rigidbody component attached.