[SOLVED] Ammo.js mistake

Hey guys, coming from Unity with 0 experience with JavaScript or your engine.

I started a blank project and imported ammo.js which I see in assets. I added a rigidbody component to a cube and ensured gravity is set properly in Physics settings. Rigidbody is dynamic with low mass. Quite simply, no physics occurs.

Checked docs, followed steps identically, no dice. Checked the internet, no additional steps listed. What did I miss?

Can you share the project please?

Hi @Taylor_Brown and welcome!

Sounds like you forgot to add a collision component. I wonder what the docs says about it. Can you share a link of the page you referring to?

1 Like

I should clarify:

The issue is not collision, there is no physics at all. As in, if I spawn the rigidbody in the sky, it won’t fall. It remains as if it is static, and doesn’t have a dynamic rigidbody (which it does).

Without sharing the project since it’s essentially brand new, I did the following:

  1. Start a blank template
  2. Create a cube and make it a prefab
  3. Add a rigidbody to the cube and import ammo when prompted on the rigidbody component
  4. Warning goes away on rigidbody, move to higher Y and set to Dynamic

No falling behavior occurs.

A blank project with your issue is great for sharing a problem - no need to study your code/project and easy to spot an issue.

You should follow Albertos advice. It doesn’t seem that you are adding a collision component (which is different from rigidbody component).

Adding a collider component worked. Migrating from another engine is tough since I am expecting everything to operate as others I have worked with in the past have, wasn’t expecting a collider as a requirement for physics behaviors.

Is it possible to make the rigidbody animate the object without collision? I don’t really need it for the effect I am trying to achieve, and setting a collider to 0x0x0 seems like it would be unnecessary if I can just operate without it.

That is why it is recommended to read the user guide. At least once.

What are you trying to achieve? It’s odd to have a physics object that has no shape/collision volume

To clarify, I want to detect ‘collisions’, but I don’t want the objects to modify each other via collision. They should pass through each other, but still notify me that they collided.

Based on my review of the docs, it seems the only way to achieve a trigger collider on an object is to add a ‘Collision’ component with no rigidbody, but I would like both my objects to have a rigidbody so I can apply a force to move them with linearVelocity. I just want them to pass through each other.

Currently, this happens. I have an object fired from the camera with a rigidbody and collider along with another rigidbody/collider object being spawned a ways away from the camera, but when the objects collide, nothing is detected.

Ah, this is tricky as it’s not supported by PlayCanvas API at least.

What I would do to get around this is instead of using forces and linearVelocity to do this, is to directly apply your own velocity in update.

ie. Have a trigger object move every frame in update with deltatime. Then you can use the trigger enter/exit events to ‘detect’ a collision

I’ll give that a shot as a workaround, I will update the thread if anything else related comes up. Thanks!