iPhone physics performance issues

I love Unity3d and I just started on a game but I’ve already hit a road block when it comes to performance. All I’m doing is a simple test with around 40 boxes and they have rigid body and box collider applied. Anyhow I noticed when I compile this is runs so sluggish at around maybe (5 frames or maybe even less). Trying to cut down the boxes to 20 we getter something far better. But I would like to use minimum 40 boxes and it seems like our polys are so simple and draws are like 60. Anyhow could it be to many physics calculations are going on at once? (I have the boxes sliding off each other and bouncing).

Anyhow I’m really new and I need help,am I missing something simple in terms of optimizing.

There are many optimization techniques, but two that I can think of that might apply to your test:

change the Time Manager’s fixed timestep to something bigger like 0.1 (this should work out to ~ 10 fps, if the cpu can handle it)

change the Physics Manager settings to be less agressive, particular the sleep settings and solver iteration count.

Trial and error!

TripleA - you need to be a bit realistic. It’s phone not a desktop.

Also make sure it’s really a box collider (Unity will probably put in a mesh collider when you first import an asset).

Just wanted to say I changed the sleep velocity, physics iterations and timestep and it made a huge difference!!

Thanks so much!

Awesome! just remember too - the more cpu you use, the more faster user’s battery drains. And physics takes a lot of cpu on the iphone.

Ok so having been playing around with the aforementioned settings I can’t seem to stack my boxes on top of each other without them first bouncing off each other. Even when I try to leave no space in between. There has to be a way to just stack like 10 boxes on top of each other and have them stay still when I click play, but they always tend to bounce a bit.

Any clue why?

Thanks again for any help, much appreciated.

That is where the sleep velocity comes in. As long as it’s moving faster than the sleep velocity, it will appear to bounce. Also the physic material setting controls the bounciness. If you have a stack of things, it will be exagerated. In a real game you would probably want to use a trigger and set the rigidbody to kinematic after it collides, and maybe then adjust the transform of the block by script. Just an idea.

Not a bad idea, Just played around with IsKinematic and looks like maybe one way to go is enable it (noticed they dont bounce), then enable it after a few seconds or something.

Thanks for the help.

Use rigidbody.Sleep() to put objects to sleep so they won’t move unless something hits them.

–Eric

Cool thanks Eric I put that code in a script and attached it to my cubes, worked but looks like its equivalent to iskinematic in that it kills all physics and remains in sleep, I guess I just need to awake the cubes after a certain time? Or can I and should I just awaken then on collision?

Thanks

Sleep() only puts objects to sleep for one frame…after that they behave as normal. (i.e., will be woken up if something collides with them, etc.) isKinematic means the object doesn’t react to physics at all and can only be moved by scripting.

–Eric

Thanks again eric, I threw a ball into it and it worked properly as expected.