Error in raycast script

Hello, i have an error in my raycast script but i don’t see it can you help me?

onMouseDown: function (e) {
    // scale coords to be in canvas resolution
    var device = app.graphicsDevice;
    var _x = e.screenX;
    var camera = app.systems.camera.cameras[0].entity;
    this.rayStart.copy(camera.getPosition());
    camera.camera.screenToWorld(e.x, e.y, 1, this.rayEnd);
    this.rayEnd.sub(this.rayStart).normalize().scale(RAY_LENGTH).add(this.rayStart);
    app.systems.rigidbody.raycastFirst(this.rayStart, this.rayEnd, this.onRayHit.bind(this));
},

What’s the error? Debugging code by inspection is never easy. It’s always good to link to a scene showing the problem, copy/paste or screenshot errors, and so on.

https://playcanvas.com/editor/scene/452611
this is the project…and…uhm,the error is not there anymore ?_? , am i going senile?

When you say error do you mean an error message in the Code Editor? If so we fixed a bunch of them today…

when i lunched the game it gave an error in stable 0 if i remember correctly
i have another error that i can’t understand the origin in this project
https://playcanvas.com/editor/scene/456908

Error loading scripts. Open the browser console for details.

can u point me to the right direction?

One error I see if that you’re doing this in enemy.js:

    this.entity.collision.on('collisionstart', this.onCollisionStart, this);

But onCollisionStart is not defined in the script. Passing ‘undefined’ as the callback parameter will cause exceptions to be thrown internally in the engine. It’s the same story in prey.js.

Thanks a lot will…it’s a line i don’t need atm so i wil put it as comment … i remember as well i have some other line as the one… i will investigate and remove all of them to clean the code. Thanks @will

1 Like