[SOLVED] pc.Vec2 is not a function error

I keep getting this error in the editor when I try to refresh my script:

Could not parse https://playcanvas.com/api/projects/375437/repositories/directory/sourcefiles/rocket.js?access_token=y8ugotztlun9pcoocqqgs1gcydfq8n5j - TypeError: pc.Vec2 is not a function

However, the script runs fine, and shows not run-time errors. I have tried commenting out every reference to vec2 an it just switches to something else giving a similar error (eg. pc.Vec3 is not a function). Although it works fine, I can’t edit the exposed properties when it is giving this error.

Any clue what this all means?

Here is the script in question: PlayCanvas | HTML5 Game Engine

This is because you are creating various vectors outside the pc.script.create block. The script attribute parser that reads the script and checks for script attributes is rather basic and doesn’t know about the rest of the engine. So you are getting errors from the parser.

Try initializing all those variables inside the pc.script.create block instead.

Makes sense. Thanks!

1 Like