Typescript error for Mesh.OnCollide (missing the mesh argument)

The oncollide function in typescript is missing to pass the Mesh it collided with; so something like this should be allowed (since it works in Javascript); but it gives an error in typescript

mymesh.onCollide = (collidedWith:AbstractMesh) => {
console.log(‘I collided’);
};

if forces me to only use

mymesh.onCollide = () => {
console.log(‘I collided’);
};

You are absolutely right, it is missing in typescript. I’ll take care of that right away!

1 Like

Many thanks!

Just a noob question; how will I know this updated in the typedef file ? and how will I be able to update it; will and npm update take care of this ?

You can see the fix by RaananW here:

And so it will be in the next “release”. In this case, I believe that means it will be in "5.0.0-rc.0"

To get it in your dev environment, it depends on how you are specifying your versions in your package.json. But for example, if using ES6 modules, adding this to your package.json, and then running npm install would work:

  "dependencies": {
    "@babylonjs/core": "^5.0.0-rc.0",

As to if npm update would work to get the latest for you, that’s complicated (IMO) and depends on a few other things. I would refer to you articles like this:

…that said, because babylon.js 5 is still in preview and is using -rc/beta type version labels, the normal NPM update mechanisms might not always work the way you expect. If unsure, specifying version explicitly (per example here) always works.

2 Likes

Many thanks for this; for now I have updated the babylonjs version to 5.0.0-rc.0 and it seems to work; since its a release candidate; I am hoping I will be able to push it to production for the next 2-3 months with this version; till 5.0 actually comes around.
So for now I am able to use the collide function :slight_smile:

1 Like