Ammo crash

Can anyone tell me what type of error is this? Im just creating tiles/materials 1000000 in runtime. Once play canvas loads then it stuck . Need help thanks

Try to search for OOM here on forums. There are a few topics around. For example:

Basically, the message says your Ammo instance has ran out of memory. It has only 64 Mb in total, so you need to manage your resources, e.g. remove rigidbodies that are no longer needed. A million of primitives is too much.

Thanks for the reply i didnt apply rigidbody .just use the collisions and make a template.But still getting an issue .

Adding a collision component will still create a rigidbody in the physics world. Albeit its a special rigidbody, that doesn’t collide with “normal” rigidbodies.

So whats the best solution can you tell me .Thanks

Don’t create a million primitives at once. Use a 100 or so around player. As player moves, create new ones ahead and remove old ones behind.

1 Like

Got it thanks.But these is not player movment ,its just the camera movement

If no player, do you still need collision components? What are they used for?

it just to load the low poly model ,on the tile thats it which you picked it

I would not use physics for this. You can store the positions of tiles and create a ray intersection test to see which tile was “picked”. There is an example on how to select stuff without physics that should get you going.

https://developer.playcanvas.com/en/tutorials/entity-picking-without-physics/

This method will be slow if you use it as is, since it just loops through all objects. In your case it will loop through all tiles, making it a loop of million steps. You would have to come up with some strategies how to break your tiles into smaller sets, so you don’t loop through all. The topic of creating an acceleration structure is broad and I can’t advise you. Perhaps a grid based particle method (GBPM) could be a good start.

Ok let me check

well, I just checked to disable the collision and rigid-body component from the template which I have made and instantiated 1 million times but it still cant be loaded. So the thing is that I have to reduce the files and there is only to work .

I have loaded 10000 tiles through code and its working

You have some infinite loop bug or a loop that is too long to complete. I would suggest starting your development with some small numbers that are easier to handle. Make 2 x 2 grid that works well. Then expand from that.

I did it and its working well but once i increase the tiles then it crash

Then you have to find what the limits are and work around them. You don’t have infinite memory and processing power. One option is to only display N amount of tiles at a time, so the app never has more than N of them at any point of time.

1 Like