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在API推荐的方式来实现SQLite数据库的增长、删除、变化、检查操作

    package com.examp.use_SQLite.dao; import java.util.ArrayList; import java.util.List; import android. ...

  2. Zoj 3545 Rescue the Rabbit(ac自己主动机+dp)

    标题效果: 鉴于DNA有一个正确的顺序值.请构造一个长度I的DNA在这个序列使DNA正确的顺序值极大.它被认为是负的输出噼啪. .. IDEAS: 施工顺序是,ac己主动机上走,求最大要用到dp dp ...

  3. 慎重使用MySQL auto_increment

    在使用MySQL中,常常会在表中建立一个自增的ID字段,利用自增ID可以高速建立索引,也是MySQL官方比較推荐的一种方式,可是,这样的方式在大量数据且配置主从时,可能会出现因为自增ID导致同步失败的 ...

  4. HUNNU Contest 区间最值

    区间求最值 Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:32768KB Total submit users: 68, Ac ...

  5. DHCP Option 60 认识

    原文地址: http://blog.163.com/chenqioulin_1983/blog/static/83216232010109104430251/   首先还是看看RFC咋说的吧.DHCP ...

  6. Shuttle ESB 实践

    http://blog.csdn.net/liu765023051/article/category/2482069

  7. 【SEO 决胜网络索引】 课程大纲及第一部分第一课:网络营销战略中的索引

    内容简介 1.课程大纲 2.第一部分第一课: 网络营销战略中的索引 3.第一部分第二课预告: 索引是什么 课程大纲 现在是网络为王的时代,人们越来越离不开互联网: SEO(Search Engine ...

  8. android cocos2dx游戏-加入截图和分享微博功能

    本文介绍怎样在游戏中添加分享功能,截屏后分享到微博及其他社交网络的功能. public class ShareSupport { // when you want to use share(),fir ...

  9. oracle 打开trace,并分析trace

    SQL> oradebug event 10046 trace name context forever,level 8 ORA-00072: process "Unix proces ...

  10. [Unity3D]Unity3D游戏开发《反对》说到游戏(上)——目标跟踪

    朋友,大家好.我是秦培,欢迎关注我的博客.我的博客地址blog.csdn.net/qinyuanpei. 首先博主要自我反省,过了这么久才来更新博客,这段时间主要是在忙着写期末的作业,所以博主基本上没 ...