- Home /
Why are gravity rigidbodies so performance costly?
I've read that rigidbodies are costly, but rigidbodies with use gravity checked are just a performance killer on their own, especially on mobile. I have tested it and can confirm that the gravity has a huge performance impact. So my question is, why is gravity so performance costly, and how can I simulate it without as much of a performance hit?
Answer by zach-r-d · Jul 27, 2015 at 08:30 AM
The same setup has a huge performance hit when all that changes is checking Use Gravity? That's super weird. Good news is it's not hard to do manually, just put the following in FixedUpdate:
rigidbody.velocity += new Vector3(0f, Physics.gravity*Time.fixedDeltaTime, 0f);
If that doesn't solve the performance issue, then it's not the gravity alone that's the problem.
Strangely, this helped get rid of the performance issue. This is pretty much what gravity is supposed to do, so I have no clue why using this ins$$anonymous$$d is faster.
Your answer
Follow this Question
Related Questions
Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer
Performance of 2D Apps on mobile: Optimizations? 0 Answers
optimizing Gravitacional object-to-object calculations 1 Answer
Why is my rigidbody getting stuck in the air when using mouse movement? 1 Answer
SketchUp Sandbox vs. Unity Terrain 2 Answers