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 is affected by gravity.
Fixed Angle Can the rigidbody rotate when forces are applied?

Is Kinematic Is the rigidbody moved by forces and collisions?
Interpolate How the object's movement is interpolated between physics updates (useful when 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 an estimate of its position in the next frame.
Sleeping Mode How the object "sleeps" to save processor time when it is at rest.
Never Sleep Sleeping is disabled.
Start Awake Object is initially awake.
Start Asleep Object is initially asleep but can be woken by collisions.
Collision Detection How collisions with other objects are 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 have contacted another between updates.

碰撞器Collider 分为两种:

(1)刚体碰撞

(2) 触发碰撞、会穿透其它刚体

相应Collider组件中的is Trigger,两种都会产生碰撞事件

	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);
}

两个方法都属于MonoBehaviour的Message 回调方法,注意区分它们的參数类型是不同的

另外还有 OnTriggerExit2DOnTriggerStay2D、 OnCollisionExit2DOnCollisionStay2D

关节的使用:

SpringJoint和DistantanceJoint有点类似多了弹性參数和频率设置(在unity中临时没看出效果)

hingeJoint 能够理解为一个环绕Z轴旋转的关节,能够设置响应moto、以及角度的限制

sliderJoint 滑动关节类似hingeJoint 以一个角度值设置Moto进行滑动,能够对距离(translation)进行限制

以下是一个用HingeJoint做的一个demo:

两仅仅小鸟同一时候加入HingeJoint 连接到盒子。后面的小鸟加下下面脚本控制方向键盘就可以前后运动

using UnityEngine;
using System.Collections; [RequireComponent(typeof(HingeJoint2D))]
public class MotoControl : MonoBehaviour { public float MotoSpeed = 0;
private JointMotor2D motor;
HingeJoint2D hj; // Use this for initialization
void Start () {
hj = GetComponent<HingeJoint2D>();
motor = hj.motor;
hj.useMotor = true;
motor = hj.motor;
motor.motorSpeed = MotoSpeed;
motor.maxMotorTorque = 10000;
} // Update is called once per frame
void Update () {
motor.motorSpeed = Input.GetAxis("Horizontal") * MotoSpeed;
hj.motor = motor;
}
}

做Demo时遇到的问题:

(1)刚開始用hj.motor.motorSpeed一直报错,后来分两步写最终没问题
motor = hj.motor;
motor.motorSpeed = MotoSpeed;
(2)错是没了,但是小车还是不走,最后知道还须要把motor对象又一次赋给HingeJoint
motor.motorSpeed = Input.GetAxis("Horizontal") * MotoSpeed;
hj.motor = motor;

其它一些经常使用的属性:

breakForce、breakTorque分别设定多大力、多大扭矩能给丫的拆了

connectedBody 连接的另外一个刚体的引用 (Joint2D中不存在)

hj.connectedBody = null;连接到一个空对象上

要想断开关节直接去掉关节组件 destroy(hj);

断开将发送 OnJointBreak Message.

版权声明:本文博客原创文章。博客,未经同意,不得转载。

unity3d 学习笔记_____Native2d 刚体、冲击、联合使用的更多相关文章

  1. Unity3D学习笔记——Rigdbody刚体组件

    Rigdbody刚体组件:必须和碰撞体(Colliders)一起使用,否则会发生穿过的现象.碰撞体(Colliders)不是必须和刚体一起使用. 刚体的作用:使游戏物体能获得重力,接受外界的受力和扭力 ...

  2. unity3d学习笔记(一) 第一人称视角实现和倒计时实现

    unity3d学习笔记(一) 第一人称视角实现和倒计时实现 1. 第一人称视角 (1)让mainCamera和player(视角对象)同步在一起 因为我们的player是生成的,所以不能把mainCa ...

  3. Unity3D学习笔记2——绘制一个带纹理的面

    目录 1. 概述 2. 详论 2.1. 网格(Mesh) 2.1.1. 顶点 2.1.2. 顶点索引 2.2. 材质(Material) 2.2.1. 创建材质 2.2.2. 使用材质 2.3. 光照 ...

  4. Unity3D学习笔记3——Unity Shader的初步使用

    目录 1. 概述 2. 详论 2.1. 创建材质 2.2. 着色器 2.2.1. 名称 2.2.2. 属性 2.2.3. SubShader 2.2.3.1. 标签(Tags) 2.2.3.2. 渲染 ...

  5. Unity3D学习笔记4——创建Mesh高级接口

    目录 1. 概述 2. 详论 3. 其他 4. 参考 1. 概述 在文章Unity3D学习笔记2--绘制一个带纹理的面中使用代码的方式创建了一个Mesh,不过这套接口在Unity中被称为简单接口.与其 ...

  6. Unity3D学习笔记6——GPU实例化(1)

    目录 1. 概述 2. 详论 3. 参考 1. 概述 在之前的文章中说到,一种材质对应一次绘制调用的指令.即使是这种情况,两个三维物体使用同一种材质,但它们使用的材质参数不一样,那么最终仍然会造成两次 ...

  7. Unity3D学习笔记7——GPU实例化(2)

    目录 1. 概述 2. 详论 2.1. 实现 2.2. 解析 3. 参考 1. 概述 在上一篇文章<Unity3D学习笔记6--GPU实例化(1)>详细介绍了Unity3d中GPU实例化的 ...

  8. Unity3D学习笔记8——GPU实例化(3)

    目录 1. 概述 2. 详论 2.1. 自动实例化 2.2. MaterialPropertyBlock 3. 参考 1. 概述 在前两篇文章<Unity3D学习笔记6--GPU实例化(1)&g ...

  9. Unity3D学习笔记12——渲染纹理

    目录 1. 概述 2. 详论 3. 问题 1. 概述 在文章<Unity3D学习笔记11--后处理>中论述了后处理是帧缓存(Framebuffer)技术实现之一:而另外一个帧缓存技术实现就 ...

随机推荐

  1. android集成apk对一些问题经常遇到系统

    1.集成APK必须确认是否release版本号,否则会导致CTS测试失败. 途径:反编译apk,视图manifest.xml文件,看<application>在那里debug属性:andr ...

  2. xhost和XServer相关概念汇总

    1.xhost 控制什么人可以访问当前主机上的增强 X-Windows.语法:xhost [ + | - ] [ Name ] 2.xhost 是用来控制X server访问权限的.通常当你从host ...

  3. 【Java基金会】Java整理面试问题和评论(一)

    1. ArrayList,Vector, LinkedList 存储性能及特点 ArrayList 和 Vector 都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便添加和插入元素,它们都 ...

  4. HDU 1069 Monkey and Banana(DP 长方体堆放问题)

    Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...

  5. [LeetCode66]Plus One

    题目: Given a non-negative number represented as an array of digits, plus one to the number. The digit ...

  6. 编程算法 - 最小的k个数 红黑树 代码(C++)

    最小的k个数 红黑树 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 输入n个整数, 找出当中的最小k个数. 使用红黑树(multiset) ...

  7. 【Java基础】对象的具体创建过程

    所有的类(以Dog类为例)在第一次使用时,动态的加载到JVM中,当首次创建Dog对象时,或者是Dog类的静态方法.静态属性域在第一次被访问时,JVM解释器查找到classpath,定位到Dog.cla ...

  8. IOS开发——手动设置屏幕旋转

    在移动开发过程.您可能需要跨越看看你的手机.有可能是所有的接口必须跨越,有可能是一个交叉通过电话,当用户当,你的接口也希望他能跨越.还有可能的是,界面的一部分需要被侧向显示.视情况而定,有不同的方法来 ...

  9. Mobile Services 提交批量数据

    Mobile Services批量提交数据,參考了文章:Inserting multiple items at once in Azure Mobile Services.里面事实上已经介绍得比較清楚 ...

  10. 通过配置Windows 防火墙允许使用TCP/IP协议远程访问数据库

    原文:通过配置Windows 防火墙允许使用TCP/IP协议远程访问数据库 本文适用于:2005.2008.2008R2所有版本 为了可以通过TCP/IP协议远程访问SQLServer数据库,需要做以 ...