|
|
Mass |
Mass of the Rigidbody. |
Linear Drag |
Drag coefficient affecting positional movement. |
Angular Drag |
Drag coefficient affecting rotational movement. |
Gravity Scale |
degree to which the object was affected by gravity. |
Fixed Angle |
Can the Rigidbody rotate when forces is applied? |
Is kinematic |
Is the rigidbody moved by forces and collisions? |
Interpolate |
How the object's movement is interpolated between physics updates (useful if motion tends to be jerky). |
None |
No movement smoothing is applied. |
Interpolate |
Movement is smoothed based on the object ' s positions in previous frames. |
Extrapolate |
Movement is smoothed based on a estimate of its position in the next frame. |
Sleeping Mode |
How the object, "sleeps" to save processor time, was at rest. |
Never Sleep |
Sleeping is disabled. |
Start Awake |
Object is initially awake. |
Start asleep |
Object is initially asleep but can being woken by collisions. |
Collision Detection |
How collisions and other objects is detected. |
Discrete |
A collision is registered only if the object's collider is in contact with another during a physics update. |
Continuous |
A collision is registered if the object's collider appears to has contacted another between updates. |
Collider collider are divided into two types:
(1) Rigid body collision
(2) Triggering collisions, penetrating other rigid bodies
The is Trigger in the corresponding collider component , two of which will produce collision events
void oncollisionenter2d (collision2d cod) {print (cod.gameObject.name); if (cod.rigidbody) Cod.rigidbody.AddForce (new Vector2 (0,500f));}
void Ontriggerenter2d (collider2d other) {Destroy (other.gameobject);}
All two methods belong to the Monobehaviour message callback method, and note that the type of the parameter that distinguishes them is different
There are also ontriggerexit2d, ontriggerstay2d, ONCOLLISIONEXIT2D, oncollisionstay2d
Use of joints:
Springjoint and Distantancejoint are a little bit like the elastic parameters and frequency settings (temporarily not seen in unity)
The hingejoint can be understood as a joint that rotates around the z axis and can be set to respond to Moto and angle limits
Sliderjoint slide joint similar to hingejoint with an angle value set Moto to slide, can limit the distance (translation)
Here is a demo with Hingejoint:
Two just birds join hingejoint to the box at the same time. Behind the birds add the following script to control the direction of the keyboard can move forward and backward
Using unityengine;using System.Collections; [Requirecomponent (typeof (HINGEJOINT2D))]public class Motocontrol:monobehaviour {public float motospeed = 0;private JOINTMOTOR2D Motor; HINGEJOINT2D hj;//Use the-initializationvoid Start () {HJ = getcomponent
Problems when doing demo:
(1) Just started to use Hj.motor.motorSpeed has been error, and then two steps to write finally no problem
Motor = Hj.motor;motor.motorspeed = Motospeed;
(2) Wrong is not, but the car still does not go, finally know also need to put motor object again to Hingejoint
Motor.motorspeed = Input.getaxis ("horizontal") * motospeed;hj.motor = motor;
Some other frequently used properties are:
Breakforce, Breaktorque respectively set more vigorously, how much torque can give ya the demolition
A reference to another rigid body connected by the Connectedbody (not present in joint2d)
Hj.connectedbody = null; Connect to an empty object
To disconnect the joints directly remove the joint components destroy (HJ);
Disconnect will send Onjointbreak Message.
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Unity3d Learning Notes _____native2d rigid body, impact, combined use