- Home /
I am getting LOW Fps, because of simple Physics. Help.
I am using very simple physics with box-coliders. I can get down to 3 FPS. My teachers can´t figure it out. I hope you can. Webb-Player Link: https://dl.dropboxusercontent.com/s/0vp0lu768unj6dk/Public.html?token_hash=AAEvzQ0goAOXYPT7AJXF7iIUt-UlKsaBo-GDS7eIfu500Q
The object that is dropped.
Here is the project if you want to take a look. https://www.dropbox.com/s/03dlm8mr1099y9l/blockubuilder.rar
You can drag things around with the cursor.
You can edit the spawning in the "Spawner" object.
I really do hope you can help! / J
the link makes my browser to download "Public.html". Fix the link taking "&dl=1" part away. You should also show some code ..cant really tell what might be wrong without more info.
Do you move things around that don't have a rigidbody attached?
Walls and the floor do not have rigidbodys attatched, I dont have any code running in the scene, Just normal Unity physics.
$$anonymous$$issread your comment, No, the only things we move around have rigid bodys attatched. $$anonymous$$y thoughts are that the objects do not go into sleep mode, which may make the physics go crazy?
Answer by Jeaper · May 08, 2013 at 06:50 PM
It appears to be a problem with using the terrain as the ground. change that to a plain with a box collider and it doesn't seem to have the same frame hitch - Adamcbrz
Solved all my problems. Thank you. Now why is that though?
(assumptions) I believe in is doing collision using a mesh collider. And since terrains can be very high poly it is much more expensive to handle. Unity and most game engines will calculate physics faster with a lot of primitive colliders then one mesh/terrain collider.
Answer by Graham-Dunnett · May 08, 2013 at 03:14 PM
Some thoughts... Your boxes have a box collider on them, and that has size 1x1x1. Your boxes have a mass of 1. So, you have a one metre cube that weighs 1kg. They must be made out of some super aeronautical foam material that is mostly empty space. It's not realistic.
Also, a stack of boxes face on is about the worst case scenario for a physics engine. The physics engine has to constantly adjust the positions of each box to stop them penetrating each other. For a stack of boxes, if one box is moved very slightly up to stop it penetrating a box beneath it, it'll penetrate more deeply into the box above it. The amount of work needed to simulate this is huge. (I know conceptually you "just" need to move all the boxes up a little, but that's hard to implement in a physics solver.) You say you have "very simple physics" but in reality you have extremely complicated physics, just the everyday scenario is very simple to describe.
Unfortunately, I can't think of a simple way for you to solve this problem.
Just to point out, units in Unity are not actually like 1mass = 1kg. Okay it can be :) but not always. I had trouble to understand it until i stumbled to: http://answers.unity3d.com/questions/39818/does-unity-3-use-si-units.html
Quote from Eric5h5: "A mass of 1 can be an ant or a planet. It's all relative."
So basically, I need to get the objects to "sleep"? any simple way to do this?
If you missed the downloadlink for the project. https://www.dropbox.com/s/03dlm8mr1099y9l/blockubuilder.rar
Answer by Adamcbrz · May 08, 2013 at 03:48 PM
Ok i did a test with just the information you have provided. I did increase the gravity to y: -1000 to get a decent gravity feel but I had no lag. Here is my what i put together let me know if it works for you.
[1]: /storage/temp/10844-archive.zip
Works fine with me with 70 boxes. let me se what I can do.
When I increase the gravity in the project the fps gets even worse.
Do you mean in your project or the one I uploaded?
Without a project to look at I don't know how else to help.
It appears to be a problem with using the terrain as the ground. change that to a plain with a box collider and it doesn't seem to have the same frame hitch
i can keep mouse down with s$$anonymous$$dy 60fps until container is full. After that approx 30s until fps drops to 20 something, and at that point there is lots of cubes falling to ..void. Didnt do any changes, but there was scripts missing, so i just reassigned them. I suppose you use windows Adamcbrz? And thats why the project didnt open correctly with my mac?
edit: and this aint any hi-end machine. Couple years old i$$anonymous$$ac (cheapest at the time).
@Jeaper have you tried your project / build in any other machine?
Answer by Jeaper · May 08, 2013 at 06:27 PM
Here is a link with the project (deactivated non related scripts) you can drag the boxes with your cursor. You can adjust spawning in the Spawner object. https://www.dropbox.com/s/03dlm8mr1099y9l/blockubuilder.rar