Hi guys… i am trying to figure out how to implement physics engine so i can use the rigidbody component from code. But i cant seem to find any documentation on how to do so.
Now i understand you have an Online Editor for those extra tooling features, but you cannot really
be purpose withholding the information on how to integrate ammo.js into our Engine Only Projects.
So from I can tell… to enable the physics engine, you include the ammo.js script and you enable or active physics using app.systems.rigidbody.setGravity
Is there no ‘enable physics’ function or does setting the gravity enable the physics engine ???
IIRC, just including the ammo.js script is enough. I think there is some code that checks for the existence of ammo on startup and if it does exist, then creates the ‘physics world’. Check RigidBodyComponentSystem in the engine.
setGravity sets the gravity, it doesn’t enable/disable the physics engine.
What does that mean… Render my self… Render what… There is no info on the ENTIRE PLANET that tells me What i need to render to make a collider visible…
Are you saying i need to somehow MAGICALLY find the internals of your collision system, find the bound box for said collider and what… actually create ANOTHER separate mesh with visibility that is supposed to represent my collider…
Are saying there is know way for your engine to Visually represent the Bonding Box area of the collider…
And worst of all… With NO DOCS… How are we (Engine Only Developers) supposed to know how to do such things ???
I dont have much hair left… but CRAWLING the web All day and night looking FOR ANYHTING to help me write my PlayCanvas games is makeing me pull out the little hair i got left
There’s nothing magical about it. The source code is open. Just pull it from a repo and search through it.
Nope. There is a mesh builder in PlayCanvas for cubes/cuboids, cylinders and sphere that you can create, scale to the correct size of the collider and attach it to the root of the scene.
The API is pretty well documented https://developer.playcanvas.com/en/api/ (generated from the engine source code comments). Most of the tutorials can mostly be used with the engine only as well. Additionally there are examples in the repo.
Now the docs don’t show where the to get the rigid body position in the simulation as it’s not deemed to be public but because we are in Javascript, it’s all accessible anyway. So when you go through the engine source for this component, you can see it is given a ‘body’ which represents the rigid body in Ammo.js for the simulation: https://github.com/playcanvas/engine/blob/master/src/framework/components/rigid-body/component.js#L205
That’s what I’m saying… most other engines have some bonding box visualization for debugging your collider. But apparently in PlayCanvas you have to create some kind of proxy mesh at runtime and calculate out size if you want a visual representation…
My problem is, how would I know to that. Know I know, and now that I know , that’s no problem.
But it doesn’t say anywhere I have to do that for my colliders… as a matter a fact , it doesn’t say anything about colliders, but to add it in the editor
I’m just trying to explain where I’m coming from, Not trying to be A hole it appears I am on the forums
And all the editor is really doing is setting the attributes on the components of the rigid body and collision volumes.
Is there something about the engine that you haven’t grokked? I appreciate there is a component based framework on top of the rendering and physics which is perhaps abstracting any understanding.
Sooner or later I hope there is a sane standard for glTF physics, but until then, nothing stops us to already implement lots of physics code which makes use of glTF. E.g. implement stuff like skeletonToRopes(), skeletonToConstraints(), meshToSoftBody() or whatever is needed.
click add mesh or 3D object, make a cuboid entity, add physics > collision, it will prompt with “import ammo.js” click it, delete the cuboid if needed, or go into project settings > asset tasks (I think) and add ammo.js (it my be physics > “import ammo.js”)