Pages

Sunday, June 26, 2011

Basics Of Physics In Unity3d

Physics

Unity has NVIDIA PhysX physics engine built-in. This allows for unique emergent behaviour and is generally very cool.

Basics

To put an object under physics control, simply add a Rigidbody to it. When you do this, the object will be affected by gravity, and can collide with other objects in the world.

Rigidbodies

Rigidbodies are physically simulated objects. You use Rigidbodies for things that the player can push around, eg. crates or loose objects, or you can move Rigidbodies around directly by adding forces to it by scripting.

Rigidbody

Rigidbodies enable your GameObjects to act under the control of physics. The Rigidbody can receive forces and torque to make your objects move in a realistic way. Any GameObject must contain a Rigidbody to be influenced by gravity, act under added forces via scripting, or interact with other objects through the NVIDIA PhysX physics engine.




Properties



MassThe weight of the object in kilograms. It is recommended to make masses not more or less than 100 times that of other Rigidbodies.
DragHow much air resistance affects the object when moving from forces. 0 means no air resistance, and infinity makes the object stop moving immediately.
Angular DragHow much air resistance affects the object when rotating from torque. 0 means no air resistance, and infinity makes the object stop rotating immediately.
Use GravityIf enabled, the object is affected by gravity.
Is KinematicIf enabled, the object will not be driven by the physics engine, and can only be manipulated by its Transform. This is useful for moving platforms or if you want to animate a Rigidbody that has a HingeJoint attached.
InterpolateTry one of the options only if you are seeing jerkiness in your Rigidbody's movement.
NoneNo Interpolation is applied.
InterpolateTransform is smoothed based on the Transform of the previous frame.
ExtrapolateTransform is smoothed based on the estimated Transform of the next frame.
Freeze RotationIf enabled, this GameObject will never rotate based on collisions or forces added via script -- it will only rotate when using transform.Rotate().
Collision DetectionUsed to prevent fast moving objects from passing through other objects without detecting collisions.
DiscreteUse Discreet collision detection against all other colliders in the scene. Other colliders will use Discreet collision detection when testing for collision against it. Used for normal collisions (This is the default value).
ContinuousUse Discrete collision detection against dynamic colliders (with a rigidbody) and continuous collision detection against static MeshColliders (without a rigidbody). Rigidbodies set to Continuous Dynamic will use continuous collision detection when testing for collision against this rigidbody. Other rigidbodies will use Discreet Collision detection. Used for objects which the Continuous Dynamic detection needs to collide with. (This has a big impact on physics performance, leave it set to Discrete, if you don't have issues with collisions of fast objects)
Continuous DynamicUse continuous collision detection against objects set to Continuous and Continuous Dynamic Collision. It will also use continuous collision detection against static MeshColliders (without a rigidbody). For all other colliders it uses discreet collision detection. Used for fast moving objects.


Now How To Add Rigid Body To Your Selected Object :

You can add a Rigidbody to your selected object from
Components->Physics->Rigidbody in the menubar. 
Now your object is physics-ready; it will fall under gravity and can receive forces via scripting, but you may need to add a Collider or a Joint to get it to behave exactly how you want.

So From This You Can add Physics to your Object.
For Physics Collider Is Important So will Come in Next POST ...

--
Vivek P Shah
Game Developer in Unity3d
Source : www.unity3d.com

1 comment:

  1. ROBLOX is powered by a growing membership base of over 300,000 creator players who provide an infinite variety of highly immersive experiences.

    These experiences range from 3D multiplayer games and contests, to interactive adventures where players can take on new avatars to explore what it would be like to be a dinosaur, a miner in a quarry or an astronaut out in space.

    ReplyDelete