My game shooting

this is my game cool thing(multiplayer) - PLAYCANVAS i need help with shooting. I want it to shoot wherever the player is facing, please reply and help.

Hi @jus.co_ding_me_23,

You will have to apply a force to your projectile to the direction of movement, something like this:

var forcePower = 1000;
var direction = this.player.forward.clone();
projectile.rigidbody.applyImpulse(direction.scale(forcePower));

There also a lot of older threads on the subject, try searching the forums for “shooting”.

1 Like

Hey @jus.co_ding_me_23,

In addition to what @Leonidas said, you can take a look at this tutorial - https://gamedevelopment.tutsplus.com/tutorials/create-a-space-shooter-with-playcanvas-part-1--cms-28066. This gives a very good introduction to both a shooting mechanism, as well as the playcanvas scripting and physics system in general.

1 Like

thanks you guys, it really helped

2 Likes