Here are the reading notes after watching 2D Game Creation in Unity Tutorial.
Sprite Renderer
“Sprites/Diffuse” is an optimised material for use with sprite, which can react to the light. Usually, light is not a necessary part in 2D game creation. But if you want the light effect, remember to set the z-order of the light to a negative value (e.g. -3).
The Sprite Editor
Sprite editor is only used for atlas and sprite sheets. Use “slice” tool can automatically generate sprites from the resource. For atlas we use automatic type slice, and for sprite sheets we use grid type slice.
Sorting Layer
Sorting layer is used for rendering objects in different order, as an optimised alternative of z-order. And order in layer defines the render order in that sorting layer. The object with the small value will be rendered first.
Rigidbody 2D
- Material allows you to control the collision effect (fraction and boundness).
- Mass is like a normal mass in real world. For example, a heavier object is harder to move.
- Linear/Angular Drag is like the air force, which lower the object’s linear/angular speed.
- Gravity Scale means how much scales of gravity the object is affected.
- Collision Detection is usually set to discrete to save computational resource. If you want a precise collision control (usually for high speed object), you can set the value to continuous.
- Sleeping Mode defines how the GameObject “sleep” to save processor time when it’s at rest. Of course, in this case you will lose a little physical precision (usually acceptable).
- Interpolate can be set to obtain a more smooth movement for the rigidbody2d.
- Constraints is set to freeze position/rotation.
Body Type:
- Dynamic: Normal rigidbody2d.
- Kinematic: Rigidbody2d not affected by collision/gravity, and should be manually controlled.
- Static: Static rigidbody2d.
Hinge Joint 2D
The hinge joint 2D is a component that allows a sprite to rotate around a point while being controlled by 2D rigidbody physics.
- Anchor is in world space when attached to a point, on the contrary in local space while attached to a rigidbody2d.
- Motor is used to power the hinge joint (Try to apply a constant speed by setting).
- Limit is the angle limit for the hinge joint.
By using hinge joint 2D, we can realize some interesting mechanics in games. For example, a spring-load trap door, a chain or a rope.
Area Effector
The area effector is used to apply physics forces to objects whthin a specific area. The area object attached the area effector should also have a collider with “Used by Effector” set to true. It’s not necessary to use a trigger collider. If it’s not a trigger, the force will only be applied on the surface of the collision.
- Force target: If set to rigidbody, the force will be applied to the mass center of the rigidbody. If set to collider, the force will be applied to the collider.
- Damping is used to set the linear and augular drag to better control the movement and avoid rotation.
Distance Joint 2D
Distance joint 2d is a component that allows a sprite to maintain a fix distance with a point while being controlled by 2d rigidbody physics.
If the designed distance is less than the actual distance, a relative force will be applied to them to make them near and reach the designed distance.
Point Effector
Point effector is like area effector. The only difference is that for area effector, the force is directional. Howerver, in point effector, the direction of the force is from the source to the object. For example, the gravity of the earth can be considered as a point effector.
Most of the variables are the same as area effector.
- Distance Scale: To scale the calculated distance from source to target, without changing the actual distance.
- Force Mode: The mode used to apply the effector force.