[SOLVED] Cannot read property of Y undefined with camera Euler

this is the error


and this is the script in problem

and here is the editor → PlayCanvas | HTML5 Game Engine
I would look at my old game for a reference, but I think my “crew” deleted it. they don’t know what they’re doing

Hi @Thebosser_24,

It looks like you’ve changed your project since I forked it, but the problem at that time appears to have been that you redefined the FirstPersonMovement initialize function in your gun.js file by using FirstPersonMovement.prototype.initialize instead of GunShoot.prototype.initialize Doing this caused the FirstPersonMovement script’s initialize function to be overwritten and not longer create the required variables for the update function.

When defining things like an initialize function it is important to ensure that you are referencing the correct variable (matching the name of the script). I would tend to avoid copying the default functions between scripts of different names to avoid this issue in the future.

1 Like

I used Ctrl-F and these don’t seem to be the issue, I don’t see an issue in my script dealing with those, but you might be right, can you show me?

and i deleted the master folder in the project, and I had to restart :sweat_smile:
so I had to restart

@Thebosser_24 I had a quick look to see how you are doing. I get an error running your code. This time it is these lines of code that are outside of a function. Remember you have had this issue before which prevented you from moving forward.

    // use direction from keypresses to apply a force to the character
    if (x !== 0 && z !== 0) {
        force.set(x, 0, z).normalize().scale(this.power);
        this.entity.rigidbody.applyForce(force);
    }

    // update camera angle from mouse events
    this.camera.setLocalEulerAngles(this.eulers.y, this.eulers.x, 0);

:skull: ok, thank you @Tirk182
i see what i did, i was adding a weapon switch thing, and I ended the function there

it can be marked as solved