[SOLVED] Raycasting for jumping generates error; same code did not do this before

Hi. I have a first-person project template I use for my students, which includes basic commands for jumping, movement, etc.

Starting today, when I try jumping in the sample project or any derivative projects, I am greeted with the following error:

[playcanvas-1.62.0.dbg.js:85370]: rayCallback.get_m_closestHitFraction is not a function

TypeError: rayCallback.get_m_closestHitFraction is not a function
at RigidBodyComponentSystem.raycastFirst (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:85370:151)
at FirstPersonMovement.update (https://launch.playcanvas.com/api/assets/files/Scripts/first-person-movement.js?id=52637610&branchId=94438020-a78c-4bae-93ba-901be4bfefa1:118:46)
at ScriptComponent._scriptMethod (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:93896:22)
at ScriptComponent._onUpdate (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:93930:15)
at ScriptComponentSystem._callComponentMethod (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:94578:52)
at ScriptComponentSystem._onUpdate (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:94596:11)
at ComponentSystemRegistry.fire (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:947:21)
at Application.update (https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:61925:19)
at https://code.playcanvas.com/playcanvas-1.62.0.dbg.js:62974:20

I have tried playing with the code I’m using, including removing the callback from the code I had, but this error persists. Here is the code that used to work, but now elicits a problem:

        var pos = this.entity.getPosition();
        this.rayEnd.add2(pos, this.groundCheckRay);            
        var onGround = false;

        // Fire a ray straight down to just below the bottom of the rigid body,
        // if it hits something then the character is standing on something.

        app.systems.rigidbody.raycastFirst(pos, this.rayEnd, function (result) {
                onGround = true;

             jumpforce.set(0, this.jumppower*15, 0);


Any advice for getting this code working again? Or is this a symptom of some bugged update to PlayCanvas? It looks like the problem may be in the codebase for raycastFirst() itself?

Hi @lmeeken,

Not sure what’s causing that, but can you try removing the Ammo folder from the project and re-import it?

The import button can be found in your project settings under Physics.

Thanks for checking in, Leonidas!

None of my projects have an Ammo folder, and have never needed one, so I couldn’t delete it. Is it something that you’ve started adding to new default projects?

In any case, I did hunt down the import button and imported Ammo into the broken projects, and they seem to be working fine, now!

I’ve added Ammo to the template I use, so it should be usable for my students. For students who have already started working with the Ammo-less version of the template, I can direct them to the Import button.

(Unfortunately, any previous students of mine with uncompiled projects from previous years will just have broken projects now - but if they find this thread or drop me an email, they may learn about the hidden-away magic button to un-break their projects :smile:).

1 Like

So that’s it, older PlayCanvas projects used a prev Ammo.js version hosted on the PlayCanvas server.

At some point Ammo.js was made available as a WASM build (which loads faster too) and it’s now included in the project.

Happy you solved this.

Thanks for helping to clarify. I’ve been updating my tutorials to reflect the new UI changes, and the new ways that 3D models are imported, but was having trouble sussing this one out.

Hello, have you resolved this issue? I have been experiencing this situation since last night

Hi @wspdsd0307 and welcome!

Can you please check if the the Ammo folder is in your project and follow the steps below?

1 Like