[SOLVED] RigidBody raycast, setting value not possible

I’m trying to fix an issue where I do a simple, useless raycast

var v = new pc.Vec3(1, 2, 3);
var v2 = new pc.Vec3(1, 2, 3);
console.log(app.systems.rigidbody.raycastFirst(v, v2));

But I’m getting

TypeError: Cannot read properties of undefined (reading 'setValue')
    at RigidBodyComponentSystem.raycastFirst

Have you loaded Ammo?

See example here: PlayCanvas Examples

1 Like

Thank you, that worked!

For future reference, I pulled the ammo files from here engine/examples/src/lib/ammo at main · playcanvas/engine · GitHub and did

pc.WasmModule.setConfig("Ammo", {
       glueUrl: "/static/lib/ammo/ammo.wasm.js",
       wasmUrl: "/static/lib/ammo/ammo.wasm.wasm",
       fallbackUrl: "/static/lib/ammo/ammo.js",
});

pc.WasmModule.getInstance("Ammo", demo);

function demo() {
  ... (raycast code n stuff)
}

Appreciate the swift reply :slight_smile: