I have been working on a FPS and cant seem to find a way to fire projectiles when the mouse is clicked. Can anybody help?
@PhilipJeffrey This needs to go in initialize
// Event for mouse button left fire
this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.mouseDown, this);
And then you have to handle the event.
// Handle mouse down event
GunShoot.prototype.mouseDown = function(e) {
// Check for Mouse left button
if(this.entity.enabled && e.button == pc.MOUSEBUTTON_LEFT) {
if(this.bulletCntr != 0) {
// Process action
this.shoot();
}
}
};
You could also look at
1 Like
Thanks so much! This really helped!
1 Like