- Home /
Help improving performance with 40-80 rigid bodies.
Hi,
I'm creating a game where I need physical interaction between tens of objects, I think the average will be around 50. Is this possible to accomplish with v6 devices on android? My coliders should be cylinders but we all know unity (physx) doesn't provide such primitive, so, I would use a mesh collider. Every mesh collider should be a cylinder of 12 sides. I have seen other games on the store (not unity) that do this and they work nicely. Has anybody tried to accomplish something like this with success on unity?
P.D. I have done some tests with 80 objects with a mesh collider created from a unity3d cyllinder and it really lags. Could anyone give any insights please?
P.D. More data, I have just left 40 objects with just box colliders and still lags a lot. Don't really know how I could get this better. On the other hand I have lowered the physics iteration to 3 too.
Thanks in advance.
FYI there have already been some huge discussions about this. $$anonymous$$gest you use search here on "coindozer"
http://answers.unity3d.com/questions/318841/what-approach-would-you-recommend-for-a-coindozer.html
Answer by Karsnen_2 · Dec 17, 2012 at 04:27 PM
Well hexdump ->
First I would like to clarify whether you are using Mesh Colliders or Cylindrical Colliders.
Either way, I would suggest you to use box collider as they have less vertices comparatively.
Try to make most of the meshes 'static' if they are not moving during run time.
For rigidbodies, what matters more is - how often do you apply force or torque etc on a rigidbody?
Do all the 80 rigidbodies fill the screen on your small Android device? if so, you might have to explain a little bit more on what are you trying to accomplish.
Do all the rigid bodies have scripts attached on it? if so, do all the scripts have Update() or FixedUpdate() functions?
Final word -> Avoid mesh colliders on a mobile device.
Hi!,
Thanks a lot for the insights. I'm trying to do something like this: http://www.hydom.cn/en/pages/1291017544109.html
Some answers to your questions:
1) I have used box colliders too (I did tests with that type of collider too). The device lagged a lot too.
2) I haven't tried to flag meshes as static, but it seems gfx is not limiting at this moment.
3) I do not apply forces because this game doesn't need that. Coins fall from the top and a wall moves back and forward making the coins fall from the bottom part of the screen.
4)No rigid body have scripts attached. I did just a fast test to check performance and I was really disappointed :(. 5) I would really like to do this, but I don't see how I could do this in this type of games. Perhaps I could use some type of collider combination to simulate the coin shape.
Thanks in advance.
1 - Then you might have to consider the usage of rigid bodies on your game. Try to fake certain things. Just use rigid bodies for coins and colliders for coins. Nothing else. 2. $$anonymous$$eshes could be static only if there DO NOT move. So look into it. From what you say, I do not think coins could be static. 3. As coins just fall, then there is nothing you could do on that part in regard to optimization. 4. Hmmm things are not working in your way. 5. Okay. First try to be more conservative on your working model. If nothing works, will see to work with something else.
Try to upload a screenshot of your scene. I would like to see that. Buzz me at willow47 on "Unity3d" room at IRC. I am online right now.
I know this post is really old
But $$anonymous$$arsnen_2, THAN$$anonymous$$ YOU.
I have been struggling with lag on a mobile device with Rigidbodies and I changed them all to Box Colliders and Voila, perfectly smooth.
SO HAPPY I COULD $$anonymous$$ISS YOU #NOHO$$anonymous$$O
:D
Answer by Alec Thilenius · Dec 19, 2012 at 07:52 AM
Sphere collides are the fastest. Next up are box collides, and very last on the list are mesh collides. The game you liked is constrained to a 2D plane, this changes everything. If I were you I would just constrain all the ridged bodies to the X Z plane ( Un-check all the other options under ridged body including rotations ) and add a sphere collider to each. Do not have a collider for the table that they are moving across, just let the constrained ridged bodies make it look like they are on a table. Write a script that removes the ridged body restrains at the end of the table.
Hi!
The game is not constraiend in any axis. Coins can move in any axis and rotate. If I use sphere colliders I wouldn't be able to have bodies on top of other bodies (coins on coins). On the other hand could you comment on your last sentence (The remove restrains one), don't really understand what you mean.
Thanks a lot for you suggestions and time. I really apreciate it.
It looks like what Fattie posted is for you. Sounds like they are going with the same type of idea. There is simply no way to simulate a boat load of coins like that with PhysX and ridged bodies. Not on PC, and certainty not on mobile. Even if you did my guess would be that it would look very unnatural.
One way I see to do it (Still not sure if its fast enough for mobile) is to use sphere colliers only, and have a single layer of coins. The coins only need to be simulated in a single moment plane at the point, and physics gets turned back on when they reach the end of the ramp, so that they 'fall'.
Your answer
Follow this Question
Related Questions
Is PhysX being used on mobile 1 Answer
Unity Cloth on Mobile? 2 Answers
Mobile Device Video Camera 1 Answer
testing on an android device 1 Answer
Accelerometer - accounting for gravity for arbitrary device angle 1 Answer