[SOLVED] Ammo is not defined when downloading build. Bug?

Since Playcanvas has moved to the new method of importing Ammo in the physics section of settings, I am having issues when downloading my project for self-hosting.

I do not need to import a custom version of Ammo for this project and I am happy to use the legacy version. The physics in the project work perfectly when testing in Playcanvas but when I download the project for self-hosting as I usually do, I am getting an error as shown below in the JS console.

59

Short term fix is to grab the legacy version yourself from GitHub and include it within the html https://github.com/playcanvas/ammo.js/tree/master/builds

Okay, that’s what I was thinking of doing, thanks!. This must be a known issue?

Hi @evandarcy,

We definitely don’t want this! Please could you explain precisely the steps I can to replicate this issue?

Thanks

@codebon

Come to think of it, I reckon this error would only occur if you are directly calling the Ammo API in a script.

  1. Create a project where the “enable physics” checkbox is not visible.
  2. Click “Import Ammo”
  3. Add code into your project that directly calls the Ammo API such as the Raycast vehicle script or a constraints script (hinges, point to point etc)
  4. Download the project for self-hosting.
  5. Create a HTML page for the project you downloaded.
  6. Serve HTML page over server.
  7. Check console for errors

Hope that helps!

Hi @evandarcy

I just tested using this vehicle physics demo https://playcanvas.com/project/644223. It worked fine.

Can I confirm you receive no other errors when you run published game? For example, the server must deliver wasm files with mime type ‘application/wasm’ else the browser will fail to load it correctly.

Thanks!

Hi @codebon

Looking at that project, I can see that the “enable physics” checkbox is visible, it looks like you forked that project from a project that used the legacy physics import system.

Also, I can confirm that I wasn’t writing any different code to deliver as WASM. However, this had been working pre-legacy.

Yes those are the only errors.

On top of that, I’m not sure what could be different.

Sorry you’re right. This time I started from scratch and apply an impulse during script initialize:
https://playcanvas.com/project/644240

This doesn’t result in error for me either.

If possible could you give me access to your failing project or alternatively just a cutdown version that demonstrates the issue?

Thanks for you help on this!

This project throws a 404

Hi @codebon

See if you can replicate issue with this https://playcanvas.com/project/644251/overview/bug-fixing-pc-forum

If not, perhaps I am just missing something…

Thanks @evandarcy

This project fails even when launching from the editor.

Looks like line 202:
this.graphics.chassis = this.entity.findByName(‘ARM_Buggy’);

returns null because the object has been renamed and so later on when chassis is accessed the following output appears:
‘TypeError: Cannot read property ‘setPosition’ of null’

Hi,

Yeah I know that, I copied the code from the other project you sent.

I’ll take a look again.

Fixed, try again.

That works for me.

To confirm, I do ‘Download build and host it on your own server’, extract the zip then navigate to index.html through my local server.

Is it possible your local server is caching files?

Yep that is exactly it.

It’s possible regarding the caching, if I run into the issue again, I will let you know.