[SOLVED] Error - Mouse not defined

Hello!
In my game im getting an error for mouse is not defined. Screenshot is here

Link to editor is here https://playcanvas.com/editor/scene/1095384. Hope I get a reply soon!

This just allows me not to switch weapons and shoot.

This is the only problem

:thinking: don’t understand why it does that, seems to be the correct syntax

1 Like

Same here, Im not sure why it does that :thinking:

Started happening when I added my shotgun in the same Shotty and then I put it in the script and now there is a error in launch :confused:

Forked your project to see the problem and debug it, seems that you have placed the code outside the update function, this should work

Shoot.prototype.update = function(dt) {
    if (this.app.mouse.was(pc.MOUSEBUTTON_LEFT) && this.weapon == "Pistol") {
        this.Shoot({
            par: this.app.root.findByName(this.weapon),
            spd: 0.5,
            spos: this.app.root.findByName("Bullet_Hole").getPosition()
        });
    }
};
2 Likes

Ok I will try! Thanks for your help.

1 Like

Worked!