Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable physics system in unity

I want to develop native android app in unity engine, and does not need to use physics, could it possible to disable physics engine for specific project in unity.

like image 757
Muhammad Ameen Avatar asked Sep 06 '17 10:09

Muhammad Ameen


People also ask

How do I enable physics in Unity?

To enable the Unity Physics Engine for a separate or empty GameObject, select the Add Component button in the Inspector window, select Physics, and specify the type of Collider.

Do you need physics for Unity?

Physics in Unity is handled by the built-in Physics Engine. The built-in Physics Engine in Unity handles the physics for gameobject interactions and the various effects like gravity, acceleration, collisions, etc.

How do you change physics in Unity?

Use the Physics settings (main menu: Edit > Project Settings, then select the Physics category) to apply global settings for 3D physics. Note: To manage global settings for 2D physics, use the Physics 2D settings instead. These settings define limits on the accuracy of the physical simulation.

Where is physics manager Unity?

The Physics Manager lets you provide global settings for 3D physics (menu: Edit > Project Settings > Physics).


2 Answers

How to disable physics system in unity

This was not possible in the past but is now possible if you have Unity 2017 and above.

Disable Physics Simulation:

Physics.autoSimulation = false;

Enable Physics Simulation

Physics.autoSimulation = true;

For 2D, use Physics2D.autoSimulation.

Once you do that, make sure you don't have FixedUpdate() function in any of your script. The physics will not be simulating. I would also set the fixed timestep to be small as possible.

Actually I want the settings like when my app start in device it should not load whole physics classes

No, you can't do this one. Forget about it. If your app is loading very slow, you need to look somewhere else as the problem not the Physics API. One example is the using the Resources folder. This is very slow. Also, you should simplify your main scene with just UI to make it load faster then use LoadAsyncScene to load the rest of the scenes. Make sure to disable audio decompressing on load. You can Google "Unity optimize load time" for more information on this.

like image 183
Programmer Avatar answered Sep 17 '22 11:09

Programmer


Starting in Unity 2019, you can use the "Unity Package Manager" to disable built-in packages altogether. Code referencing them will not compile, and they will not be included in your built application.

Unity Package Manager Documentation

like image 25
Andrew Gotow Avatar answered Sep 19 '22 11:09

Andrew Gotow