《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)

《UnityAPI.Rigidbody刚体》

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第1张图片

版本

作者

参与者

完成日期

备注

UnityAPI_Rigidbody_V01_1.0

严立钻

 

2020.06.11

 

 

 

 

 

 

 

 

#《UnityAPI.Rigidbody刚体》发布说明:

++++“UnityAPI.Rigidbody刚体是对UnityAPIRigidbody刚体类的剖析和拓展

立钻哥哥:Unity是一个入门快、提高难的游戏引擎,想要提升能力,至少需要越过3道坎:API+Shader+综合能力

++1、API的积累:API的合理利用不仅可以减轻自己的编码负担,而且往往可以提高程序的运行效率;这也是钻哥开始“Unity API”独立打造分类的初衷

++2、Shader编程:想要做出一款精品游戏往往需要有高效的Shader的支持;Unity提供了一套改良的“Shader Lab”系统,优化了繁杂的“Open GL”编程

++3、综合能力(技术+业务+管理):一款产品的制作除了功能编程外,往往会涉及很多其他领域,例如产品架构、UI交互设计、模型制作等,作为主要的编程人员,对其他相关领域的了解程序往往会影响到产品制作直至最后的产品体验

++++立钻哥哥一直在推动【VR云游戏=Unity+SteamVR+云技术+5G+AI,这个只是一个引子,抛砖引玉让大家对整个知识体系有一个明确的落地方向,宝宝们可以根据自己的兴趣方向进行拓展:比如Unity这里是指一种“3D游戏引擎”,也可拓展至“UE4Cocos2dx”等游戏引擎;SteamVR是一种跨硬件解决方案,也可拓展至“VRTK”等第三方插件;“云技术+5G”是一种跨平台解决方案的核心技术,同样可拓展至其他平台解决方案;AI也是一种先进技术的举例,也可以拓展至任何一种前沿技术

 

 

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

$$$$博客溯源:

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第2张图片

 

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

 

 

 

 

 

 

 

#Rigidbody刚体

#Rigidbody刚体

#Rigidbody刚体

++A1、Description描述

++B2、Variables变量

++C3、Public Function共有函数

++D4、Message消息

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第3张图片

 

 

 

#A1、Description描述

#A1、Description描述

++A1、Description描述

++++立钻哥哥:Rigidbody(刚体)是通过物理模拟控制一个物体的位置

++++[namespace]:UnityEngine

++++[Inherits from]:Component

++++添加Rigidbody组件到一个对象,这就置于了Unity的物理引擎下使其运动;即使没有添加任何代码,刚体对象也将在重力的影响下下落,如果带有碰撞器的对象与之碰撞,并将做出反应;

++++从脚本添加力到刚体对象上,以真实的物理方法来控制它;例如,轿车的行为可以给轮胎施加力,物理引擎处理运动的其他方面,因此,会有更真实的加速度和正确的碰撞反应;

++++在脚本,FixedUpdate函数中被推荐放置应用力以及修改刚体设置(相对于Update,应用其他大部分更新任务);物理更新的时间间隔与Update是不一致的,在每个物理更新之前,FixedUpdate被立即调用,所以所作的任何更改会直接处理;

++++当刚体运行开始常见的问题是,游戏物理引擎看上去运行像“慢镜头”;这实际上由于模型的大小,默认重力设置假定为每世界单位1米距离;对非物理游戏,模型缩放100单位也没有多大差别,但当使用物理引擎,将被视为非常大的对象;如果应该是小对象使用较大的缩放,将出现下落很慢,物理引擎认为它是非常大的对象,下落较大的距离;确保对象接近真实生活的大小(例如,轿车应该是大约4单位=4米);

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第4张图片

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Transform变换]:https://blog.csdn.net/VRunSoftYanlz/article/details/106607761

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第5张图片

 

 

 

 

 

#B2、Variables变量

#B2、Variables变量

++B2、Variables变量

++++B2.1、angularDrag

++++B2.2、angularVelocity

++++B2.3、centerOfMass

++++B2.4、collisionDetectionMode

++++B2.5、constraints

++++B2.6、detectCollisions

++++B2.7、drag

++++B2.8、freezeRotation

++++B2.9、inertiaTensor

++++B2.10、inertiaTensorRotation

++++B2.11、interpolation

++++B2.12、isKinematic

++++B2.13、mass

++++B2.14、maxAngularVelocity

++++B2.15、maxDepenetrationVelocity

++++B2.16、position

++++B2.17、rotation

++++B2.18、sleepThreshold

++++B2.19、solverIterationCount

++++B2.20、useConeFriction

++++B2.21、useGravity

++++B2.22、velocity

++++B2.23、worldCenterOfMass

++++B2.24、YanlzXREngine.Rigidbody.Variables

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第6张图片

 

 

++B2.1、angularDrag

++B2.1、angularDrag

++B2.1、angularDrag

++++立钻哥哥:角阻力

public float angularDrag;

++++刚体的角阻力

++++角阻力可用来减缓刚体的旋转;阻力越高旋转越慢

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void Update(){

        if(Input.GetKeyDown(space)){

            rb.angularDrag = 0.8F;

        }else{

        rb.angularDrag = 0;

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.2、angularVelocity

++B2.2、angularVelocity

++B2.2、angularVelocity

++++立钻哥哥:角速度

public Vector3 angularVelocity;

++++刚体的角速度向量

++++在大多数情况下,不应该直接修改它,因为这会导致不真实的行为

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Material fastWheelMaterial;

    public Material slowWheelMaterial;

    public Rigidbody rb;

    public MeshRenderer rend;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

        rend = GetComponent<MeshRenderer>();

    }    //立钻哥哥:void Start(){}

 

    void Update(){

        if(rb.angularVelocity.magnitude < 5){

            rend.sharedMaterial = slowWheelMaterial;

        }else{

            rend.sharedMaterial = fastWheelMaterial;

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.3、centerOfMass

++B2.3、centerOfMass

++B2.3、centerOfMass

++++立钻哥哥:质量中心

public Vector3 centerOfMass;

++++相对于变换原点的质心

++++如果不从脚本设置质心,那么会从附加到该刚体的所有碰撞器自动计算;自定义质心之后,它将不再自动重新计算修改,如添加或移除碰撞器、移动、缩放等;要恢复到自动计算质心,使用Rigidbody.ResetCenterOfMass

++++当模拟车辆使其更稳定,设置质心通常很有用;车轮较低的质心更不容易翻车

++++注意:centerOfMass是相对于变换的位置和旋转,但是不会受到缩放的影响

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Vector3 com;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

        rb.centerOfMass = com;

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.4、collisionDetectionMode

++B2.4、collisionDetectionMode

++B2.4、collisionDetectionMode

++++立钻哥哥:碰撞检测模式

public CollisionDetectionMode collisionDetectionMode;

++++刚体的碰撞检测模式

++++使用这个设置刚体的连续碰撞检测,用来防止快速移动的物体,从没有碰撞检测的其他物体穿过,为了获得最佳效果,为快速移动的物体设置该值值为CollisionDetectionMode.ContinuousDynamic,以及为其他需与之碰撞的物体设置这个值为CollisionDetectionMode.Continuous;该值对物理性能有很大影响,假如快速物体的碰撞没有任何问题,那么该值设置为CollisionDetectionMode.Discrete;连续碰撞检测只支持刚体的球体、胶囊或盒碰撞器

 

 

 

 

 

++B2.5、constraints

++B2.5、constraints

++B2.5、constraints

++++立钻哥哥:约束

public RigidbodyConstraints constraints;

++++控制该刚体模拟允许的自由度

++++默认设置是RigidbodyConstraints.None,允许沿所有轴自由旋转和移动;在某些情况下,想约束一个刚体仅沿某个轴移动和旋转,例如2D游戏开发;可以用“逐位”运算符来结合多个约束

++++注意:约束是应用于刚体的局部坐标空间

 

 

 

 

 

++B2.6、detectCollisions

++B2.6、detectCollisions

++B2.6、detectCollisions

++++立钻哥哥:检测碰撞

public bool detectCollisions;

++++碰撞检测应否启用?(默认总是启用的)

++++当有一个布娃娃,它被设置为运动学并且想避免刚体上大量的碰撞检测计算时,禁用碰撞检测是很有用的;detectCollisions是非序列化的,也就是说,它不会显示在检视面板中并且当在场景中实例化或保存它时,它将不被保存

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void MyEnableRagdoll(){

        rb.isKinematic = false;

        rb.detectCollisions = true;

    }    //立钻哥哥:void EnableRagdoll(){}

 

    void MyDisableRagdoll(){

        rb.isKinematic = true;

        rb.detectCollisions = false;

    }    //立钻哥哥:void DisableRagdoll(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.7、drag

++B2.7、drag

++B2.7、drag

++++立钻哥哥:阻力

public float drag;

++++刚体的阻力

++++阻力可用来减缓刚体的速度;阻力越高刚体减缓越快

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void MyOpenParachute(){

        rb.drag = 20;

    }    //立钻哥哥:void OpenParachute(){}

 

    void Update(){

        if(Input.GetButton(Space)){

            MyOpenParachute();

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.8、freezeRotation

++B2.8、freezeRotation

++B2.8、freezeRotation

++++立钻哥哥:冻结旋转

public bool freezeRotation;

++++控制物理是否改变物体的旋转

++++如果freezeRotation被启用,旋转不会被物体模拟修改;这对于创建第一人称射击游戏时很有用的,因为玩家需要使用鼠标完全控制旋转

 

 

 

 

 

++B2.9、inertiaTensor

++B2.9、inertiaTensor

++B2.9、inertiaTensor

++++立钻哥哥:惯性张量

public Vector3 inertiaTensor;

++++相对于重心的质量的惯性张量对角线

++++惯性张量通过inertiaTensorRotation旋转;如果在脚本中没有设置惯性张量,它将从附加到刚体的所有碰撞器自动计算

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Vector3 tensor;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

        rb.inertiaTensor = tensor;

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.10、inertiaTensorRotation

++B2.10、inertiaTensorRotation

++B2.10、inertiaTensorRotation

++++立钻哥哥:惯性张量旋转

public Quaternion inertiaTensorRotation;

++++惯性张量的旋转

++++如果在脚本中没有设置惯性张量的旋转,它将从附加到刚体的所有碰撞器自动计算

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void MyResetTensor(){

        GetComponent<Rigidbody>().inertiaTensorRotation = Quaternion.identity;

    }    //立钻哥哥:void ResetTensor(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.11、interpolation

++B2.11、interpolation

++B2.11、interpolation

++++立钻哥哥:插值

public RigidbodyInterpolation interpolation;

++++插值允许以固定的帧率平滑物理运行效果

++++插值默认是关闭的;通常刚体插值用于玩家角色;物理是不连续(discrete)的时间步运行,而显卡以可变的帧率渲染;这可能导致物体抖动,因为物理和显卡不完全同步;这个效果是细微的但是通常会在玩家角色上看到,尤其是如果相机跟随主角色;建议为主角打开插值,但其他的禁用

 

 

 

 

 

++B2.12、isKinematic

++B2.12、isKinematic

++B2.12、isKinematic

++++立钻哥哥:是否动力学

public bool isKinematic;

++++控制物理是否够影响这个刚体

++++如果isKinematic启用,力、碰撞或关节将不会影响这个刚体;刚体将通过动画或脚本完全控制改变transform.position;动力学刚体也会通过碰撞或关节影响其他刚体的运动;例如:可以使用关节链接动力学刚体到一个普通的刚体,并且这个刚体将受到动力学刚体运动的约束;动力学刚体也被用于制作角色,通常是由动画驱动,但是在某些事件可以通过设置isKinematicfalse,快速转化为一个布娃娃

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void MyEnableRagdoll(){

        rb.isKinematic = false;

        rb.detectCollisions = true;

    }    //立钻哥哥:void EnableRagdoll(){}

 

    void MyDisableRagdoll(){

        rb.isKinematic = true;

        rb.detectCollisions = false;

    }    //立钻哥哥:void DisableRagdoll(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.13、mass

++B2.13、mass

++B2.13、mass

++++立钻哥哥:质量

public float mass;

++++刚体的质量

++++建议保持质量值在0.1~1.0之间;不同的刚体与质量差异较大,可以使物理模拟不稳定

++++当碰撞时较大质量的物体,推开较小质量的物体更多

++++一个常见的错误是重的物体比轻的物体下落的快;这是不正确的,速度依赖于重力和阻力

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float mass;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

        rb.mass = mass;

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.14、maxAngularVelocity

++B2.14、maxAngularVelocity

++B2.14、maxAngularVelocity

++++立钻哥哥:最大角速度

public float maxAngularVelocity;

++++刚体的最大角速度,(默认7)范围{0, 无穷大}

++++刚体的最大角速度限制为maxAngularVelocity,以避免高速旋转刚体的数值不稳定;因为这可能会防止故意快速旋转的物体,例如车轮,可以在每个刚体重写这个值;该值可以在[Edit->Project Settings->Physics]的检视面板中修改

 

 

 

 

 

++B2.15、maxDepenetrationVelocity

++B2.15、maxDepenetrationVelocity

++B2.15、maxDepenetrationVelocity

++++立钻哥哥:最大非穿透速度

public float maxDepenetrationVelocity;

++++当非穿透状态时,刚体的最大速度

++++当想以比默认更平滑的方式使刚体脱离碰撞状态时使用该属性

 

 

 

 

 

++B2.16、position

++B2.16、position

++B2.16、position

++++立钻哥哥:位置

public Vector3 position;

++++该刚体的位置

++++Rigidbody.position允许使用物理引擎获取或设置刚体的位置;如果使用Rigidbody.position更改刚体的位置,该变换将在下次物理模拟时更新;这比更新位置使用Transform.position更快,后者将导致所有附加的碰撞器重新计算相对刚体的位置

++++如果想连续移动刚体使用MovePosition替代,其考虑了内插值

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void Start(){

        GetComponent<Rigidbody>().position = Vector3.zero;

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.17、rotation

++B2.17、rotation

++B2.17、rotation

++++立钻哥哥:旋转角度

public Quaternion rotation;

++++刚体的旋转角度

++++Rigidbody.rotation允许使用物理引擎获取或设置刚体的位置;如果使用Rigidbody.rotation更改刚体的位置,该变换将在下次物理模拟时更新;这比更新位置使用Transform.rotation更快,后者将导致所有附加的碰撞器重新计算相对刚体的位置

++++如果想连续移动刚体使用MoveRotation替代,其考虑了内插值

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void Start(){

        GetComponent<Rigidbody>().rotation = Quaternion.identity;

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.18、sleepThreshold

++B2.18、sleepThreshold

++B2.18、sleepThreshold

++++立钻哥哥:休眠阀值

public float sleepThreshold;

++++哪个对象开始进入休眠状态,质量归一化的能量阀值

 

 

 

 

 

++B2.19、solverIterationCount

++B2.19、solverIterationCount

++B2.19、solverIterationCount

++++立钻哥哥:求解迭代次数

public int solverIterationCount;

++++允许覆盖每个刚体的求解迭代次数

++++solverIterationCount确定关节和接触点如何精确地计算;如果关节刚体有震荡和行为怪异,为solverIterationCount设置一个较高的值将改善他们的稳定性

 

 

 

 

 

++B2.20、useConeFriction

++B2.20、useConeFriction

++B2.20、useConeFriction

++++立钻哥哥:使用锥形摩擦

public bool useConeFriction;

++++用于该刚体的锥形摩擦力

++++这确保所有接触包含的行为将使用锥形摩擦力;不过,这对于性能有负面影响;默认这个是关闭的,使用更快和更好的被称为金字塔摩擦的近似方法;在大多数情况下建议保留这个值为关闭

 

 

 

 

 

++B2.21、useGravity

++B2.21、useGravity

++B2.21、useGravity

++++立钻哥哥:使用重力

public bool useGravity;

++++控制重力是否影响整个刚体

++++如果设置为flase,刚体将不受重力影响

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Collider coll;

 

    void Start(){

        coll = GetComponent<Collider>();

        coll.isTrigger = true;

    }    //立钻哥哥:void Start(){}

 

    void OnTriggerEnter(Collider other){

        if(other.attatchedRigidbody){

            other.attachedRigidbody.useGravity = false;

        }

    }    //立钻哥哥:void OnTriggerEnter(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.22、velocity

++B2.22、velocity

++B2.22、velocity

++++立钻哥哥:速度

public Vector3 velocity;

++++刚体的速度向量

++++在大多数情况下,不应该直接修改速度,因为这会导致不真实的行为;不要设置每对个对象物理步的速度,这将导致不真实的物理模拟;一个典型的例子,当在第一人称射击游戏中当跳跃的时候改变速度,因为想立即改变速度

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        if(Input.GetButtonDown(Jump)){

            rb.velocity = new Vector3(0, 10, 0);

        }

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++B2.23、worldCenterOfMass

++B2.23、worldCenterOfMass

++B2.23、worldCenterOfMass

++++立钻哥哥:世界质量中心

public Vector3 worldCenterOfMass;

++++在世界坐标空间的刚体的质量中心(只读

 

 

 

 

 

 

 

#C3、Public Functions公有变量

#C3、Public Functions公有变量

++C3、Public Functions公有变量

++++C3.1、AddExplosionForce

++++C3.2、AddForce

++++C3.3、AddForceAtPosition

++++C3.4、AddRelativeForce

++++C3.5、AddRelativeTorque

++++C3.6、AddTorque

++++C3.7、ClosestPointOnBounds

++++C3.8、GetPointVelocity

++++C3.9、GetRelativePointVelocity

++++C3.10、IsSleeping

++++C3.11、MovePosition

++++C3.12、MoveRotation

++++C3.13、ResetCenterOfMass

++++C3.14、ResetInertiaTensor

++++C3.15、SetDensity

++++C3.16、Sleep

++++C3.17、SweepTest

++++C3.18、SweepTestAll

++++C3.19、WakeUp

++++C3.20、YanlzXREngine.Rigidbody.PublicFunctions

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第7张图片

 

 

++C3.1、AddExplosionForce

++C3.1、AddExplosionForce

++C3.1、AddExplosionForce

++++立钻哥哥:添加爆炸力

public void AddExplosionForce(float explosionForce, Vector3 explosionPosition, float explosionRadius, float upwardsModifier=0.0F, ForceMode mode=ForceMode.Force);

++++[explosionForce]:爆炸力,可以通过距离来修改

++++[explosionPosition]:球体的中心

++++[explosionRadius]:球体的半径,在半径内才有爆炸效果

++++[upwardsModifier]:调节爆炸出现的位置,使其看起来像掀起对象

++++[mode]:用于应用到目标力的方式

++++应用一个力到刚体来模拟爆炸效果

++++爆炸是一个具有中心点和半径的球体,在世界坐标空间;一般情况下,在球体外的任何东西都不会受到爆炸的影响并且力从中心到外按比例减少;然而,如果半径为0,那么力完全应用到刚体,而不管距离中心有多远

++++默认,从爆炸中心到刚体的质量中心的方向是线性;如果upwardsModifier参数传递非0值,该方向将通过减去中心点Y轴的值修改;例如,如果upwardsModifier的值为2.0,那么该爆炸出现在实际位置中心点2单位下(如,中心和影响的半径不会被修改);使用这个参数,可以很容易地使爆炸似乎把物体扔到空中,这往往比单纯的外力更具戏剧性的效果

++++力仅应用于激活的刚体;如果游戏对象未激活,AddExplosionForce也将无效

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float radius = 5.0F;

    public float power = 10.0F;

 

    void Start(){

        Vector3 explosionPos = transform.position;

        Collider[] colliders = Physics.OverlapSphere(explosionPos, radius);

 

        foreach(rb != null){

            rb.AddExplosionForce(power, explosionPos, radius, 3.0F);

        }

   

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.2、AddForce

++C3.2、AddForce

++C3.2、AddForce

++++立钻哥哥:添加力

public void AddForce(Vector3 force, ForceMode mode=ForceMode.Force);

public void AddForce(float x, float y, float z, ForceMode mode=ForceMode.Force);

++++[force]:世界坐标空间里的向量

++++[x]:在世界坐标空间x轴力的大小

++++[y]:在世界坐标空间y轴力的大小

++++[z]:在世界坐标空间z轴力的大小

++++添加到刚体的力

++++力仅应用于激活的刚体;如果游戏对象未激活,添加力无效果

++++默认刚体是唤醒的;如果力的大小为0,那么刚体不被唤醒

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float thrust;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        rb.AddForce(transform.forward * thrust);

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.3、AddForceAtPosition

++C3.3、AddForceAtPosition

++C3.3、AddForceAtPosition

++++立钻哥哥:所在位置添加力

public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode mode=ForceMode.Force);

++++[force]:在世界坐标空间,力的向量

++++[position]:在世界坐标空间的位置

++++position位置应用force力;作为结果这个将在这个物体上应用一个扭矩和力

++++对于真实的效果,应大约在刚体表面的范围内的位置;这个最常用于爆炸,当应用于爆炸时,最好应用力到多帧而不是一帧中;注意:当position远离刚体的中心时,所应用的力矩会不切实际地大

++++力仅应用于激活的刚体;如果游戏对象未激活,AddForceAtPosition无效果

++++默认刚体是唤醒的;如果力的大小为0,那么刚体不被唤醒

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void MyApplyForce(Rigidbody body){

        Vector3 direction = body.transform.position - transform.position;

        body.AddForceAtPosition(direction.normalized, transform.position);

    }    //立钻哥哥:void MyApplyForce(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.4、AddRelativeForce

++C3.4、AddRelativeForce

++C3.4、AddRelativeForce

++++立钻哥哥:添加相对力

public void AddRelativeForce(Vector3 force, ForceMode mode=ForceMode.Force);

public void AddRelativeForce(float x, float y, float z, ForceMode mode=ForceMode.Force);

++++[force]:在局部坐标空间,力的向量

++++[x]:在局部坐标空间x轴力的大小

++++[y]:在局部坐标空间y轴力的大小

++++[z]:在局部坐标空间z轴力的大小

++++添加力到刚体;相对于它的系统坐标

++++力仅应用于激活的刚体;如果游戏对象未激活,添加相对力无效果

++++默认刚体是唤醒的;如果力的大小为0,那么刚体不被唤醒

//Add a thrust force to push an object in its current forward direction(to simulate a rocket motor, say).

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float thrust;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        rb.AddRelativeForce(Vector3.forward * thrust);

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.5、AddRelativeTorque

++C3.5、AddRelativeTorque

++C3.5、AddRelativeTorque

++++立钻哥哥:添加相对扭矩

public void AddRelativeTorque(Vector3 torque, ForceMode mode=ForceModel.Force);

public void AddRelativeTorque(float x, float y, float z, ForceMode mode=ForceModel.Force);

++++[torque]:在局部坐标空间,扭矩的向量

++++[x]:在局部坐标空间绕x轴的扭矩大小

++++[y]:在局部坐标空间绕y轴的扭矩大小

++++[z]:在局部坐标空间绕z轴的扭矩大小

++++相对于它的局部坐标系统添加扭矩到刚体

++++力仅应用于激活的刚体;如果游戏对象未激活,添加相对扭矩无效果

++++默认刚体是唤醒的;如果力的大小为0,那么刚体不被唤醒

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float torque;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        float turn = Input.GetAxis(Horizontal);

        rb.AddRelativeTorque(Vector3.up * torque * turn);

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.6、AddTorque

++C3.6、AddTorque

++C3.6、AddTorque

++++立钻哥哥:添加扭矩

public void AddTorque(Vector3 torque, ForceMode mode=ForceMode.Force);

public void AddTorque(float x, float y, float z, ForceMode mode=ForceMode.Force);

++++[torque]:在世界坐标空间扭矩的向量

++++[x]:在世界坐标绕x轴的扭矩大小

++++[y]:在世界坐标绕y轴的扭矩大小

++++[z]:在世界坐标绕z轴的扭矩大小

++++添加扭矩到刚体

++++力仅应用于激活的刚体;如果游戏对象未激活,添加扭矩无效果

++++默认刚体是唤醒的;如果力的大小为0,那么刚体不被唤醒

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

     public float torque;

     public Rigidbody rb;

 

     void Start(){

         rb = GetComponent<Rigidbody>();

     }    //立钻哥哥:void Start(){}

 

     void FixedUpdate(){

         float turn = Input.GetAxis(Horizontal);

 

         //rb.AddRelativeTorque(Vector3.up * torque * turn);

         rb.AddTorque(transform.up * torque * turn);

     }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.7、ClosestPointOnBounds

++C3.7、ClosestPointOnBounds

++C3.7、ClosestPointOnBounds

++++立钻哥哥:在边界框上最近点

public Vector3 ClosestPointOnBounds(Vector3 position);

++++指定位置到该刚体附加的碰撞器的最近点

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float hitPoints = 10.0F;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void MyApplyDamage(Vector3 explosionPos, float radius){

        Vector3 closestPoint = rb.ClosestPointOnBounds(explosionPos);

        float distance = Vector3.Distance(closestPoint, explosionPos);

 

        float damage = 1.0F - Mathf.Clamp01(distance / radius);

        damage *= 10;

        hitPoints -= damge;

 

    }    //立钻哥哥:void MyApplyDamage(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.8、GetPointVelocity

++C3.8、GetPointVelocity

++C3.8、GetPointVelocity

++++立钻哥哥:获取点速度

public Vector3 GetPointVelocity(Vector3 worldPoint);

++++刚体在世界坐标空间,worldPoint点的速度

++++GetPointVelocity在计算速度的时候将考虑刚体的角速度angularVelocity

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    Vector3 MyCalcWheelVelocity(Vector3 localWheelPos){

        return rb.GetPointVelocity(transform.TransformPoint(localWheelPos));

    }    //立钻哥哥:Vector3 CalcWheelVelocity(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.9、GetRelativePointVelocity

++C3.9、GetRelativePointVelocity

++C3.9、GetRelativePointVelocity

++++立钻哥哥:获取相对点速度

public Vector3 GetRelativePointVelocity(Vector3 relativePoint);

++++相对于刚体在relativePoint点的速度

++++GetRelativePointVelocity在计算速度的时候将考虑刚体的角速度angularVelociy

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    Vector3 MyCalcWheelVelocity(Vector3 localWheelPos){

        //return rb.GetPointVelocity(transform.TransformPoint(localWheelPos));

        return rb.GetRelativePointVelocity(localWheelPos);

    }    //立钻哥哥:Vector3 CalcWheelVelocity(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.10、IsSleeping

++C3.10、IsSleeping

++C3.10、IsSleeping

++++立钻哥哥:是否正休眠

public bool IsSleeping();

++++刚体在休眠么?

 

 

 

 

 

++C3.11、MovePosition

++C3.11、MovePosition

++C3.11、MovePosition

++++立钻哥哥:移动位置

public void MovePosition(Vector3 position);

++++[position]:用于刚体对象的新位置

++++移动刚体到新位置

++++使用Rigidbody.MovePosition来移动刚体,带有刚体插值设置

++++如果刚体插值启用,调用Rigidbody.MovePosition导致在任意两帧之间平滑过滤;如果想在每固定更新连续移动刚体使用这个

++++如果想瞬移刚体从一个位置到另一个位置使用Rigidbody.position替代,中间位置不被渲染

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Vector3 teleportPoint;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        rb.MovePosition(transform.position + transform.forward * Time.deltaTime);

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.12、MoveRotation

++C3.12、MoveRotation

++C3.12、MoveRotation

++++立钻哥哥:移动旋转

public void MoveRotation(Quaternion rot);

++++[rot]:用于刚体的新旋转

++++旋转刚体到新角度

++++使用Rigidbody.MoveRotation来旋转刚体,带有刚体的插值设置

++++如果刚体插值启用,调用Rigidbody.MoveRotation导致在任意两帧之间平滑过渡;如果想在每固定更新连续旋转刚体使用这个

++++如果想瞬移刚体从一个旋转到另一个旋转使用Rigidbody.rotation替代,中间位置不被渲染

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Vector3 eulerAngleVelocity;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void FixedUpdate(){

        Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);

        rb.MoveRotation(rb.rotation * deltaRotation);

    }    //立钻哥哥:void FixedUpdate(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.13、ResetCenterOfMass

++C3.13、ResetCenterOfMass

++C3.13、ResetCenterOfMass

++++立钻哥哥:重置质心

public void ResetCenterOfMass();

++++重置刚体的质心

++++从所有附加的碰撞器重新计算刚体的质心并储存;调用该函数之后,在刚体任何修改之后,质心将自动被更新

 

 

 

 

 

++C3.14、ResetInertiaTensor

++C3.14、ResetInertiaTensor

++C3.14、ResetInertiaTensor

++++立钻哥哥:重置惯性张量

public void ResetInertiaTensor();

++++重置惯性张量值和旋转

++++从刚体附加的碰撞器计算惯性张量以及惯性张量旋转角度并储存;调用该函数之后,刚体任何修改之后,该惯性张量和张量旋转角度将被自动更新

 

 

 

 

 

++C3.15、SetDensity

++C3.15、SetDensity

++C3.15、SetDensity

++++立钻哥哥:设置密度

public void SetDensity(float density);

++++设置基于附加的碰撞器假设一个固定的密度质量

 

 

 

 

 

++C3.16、Sleep

++C3.16、Sleep

++C3.16、Sleep

++++立钻哥哥:休眠

public void Sleep();

++++强制刚体休眠

++++常见的用途是从Awake中调用它以便使刚体在启用的时候休眠

 

 

 

 

 

++C3.17、SweepTest

++C3.17、SweepTest

++C3.17、SweepTest

++++立钻哥哥:扫描测试

public bool SweepTest(Vector3 direction, out RaycastHit hitInfo, float maxDistance=Mathf.Infinity, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal);

++++[direction]:扫描该刚体的方向

++++[hitInfo]:hitInfo包含更多碰到的信息

++++[maxDistance]:扫描的长度

++++[queryTriggerInteraction]:指定是否查询碰到触发器

++++[返回值]:返回bool类型,当为true时,刚体扫描相交的任意碰撞器,否则为false

++++如果一个刚体碰到任何东西触发测试

++++这类似于为任何一个刚体的碰撞器包含的所有点做一个Physics.Raycast,并返回最接近的所有碰撞(如果有)报告;这对于AI代码非常有用,当需要知道如果一个物体想要适配不与任何东西碰撞的地方

++++注意:该函数仅工作与原始碰撞器类型(球体、立方体或胶囊)或凸网格碰撞器,凹网格碰撞器不工作,尽管它在场景能扫描检测

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public float collisionCheckDistance;

    public bool aboutToCollide;

    public float distanceToCollision;

    public Rigidbody rb;

 

    void Start(){

        rb = GetComponent<Rigidbody>();

    }    //立钻哥哥:void Start(){}

 

    void Update(){

        RaycastHit hit;

 

        if(rb.SweepTest(transform.forward, out hit, collisionCheckDistance)){

            aboutToCollide = true;

            distanceToCollision = hit.distance;

        }

    }    //立钻哥哥:void Update(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++C3.18、SweepTestAll

++C3.18、SweepTestAll

++C3.18、SweepTestAll

++++立钻哥哥:扫描测试全部

public RaycastHit[] SweepTestAll(Vector3 direction, float maxDistance=Mathf.Infinity, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal);

++++[direction]:扫描该刚体的方向

++++[maxDistance]:扫描的长度

++++[queryTriggerInteraction]:指定是否查询碰到触发器

++++[返回值]:返回扫描碰到的所有碰撞器RaycastHit数组

++++就像Rigidbody.SweepTest,当返回的是所有碰撞信息

++++如果该刚体附加的碰撞器不只一个,针对同样碰撞器扫描可能返回多个碰撞信息

++++注意:该函数仅工作与原始碰撞器类型(球体、立方体或胶囊)或凸网格碰撞器,凹网格碰撞器不工作,尽管它在场景能扫描检测

++++该函数仅最多返回128碰撞信息

 

 

 

 

 

++C3.19、WakeUp

++C3.19、WakeUp

++C3.19、WakeUp

++++立钻哥哥:唤醒

public void WakeUp();

++++强制一个刚体唤醒

 

 

 

 

 

 

 

#D4、Message消息

#D4、Message消息

++D4、Messgae消息

++++D4.1、OnCollisionEnter

++++D4.2、OnCollisionExit

++++D4.3、OnCollisionStay

++++D4.4、YanlzXREngine.Rigidbody.Message

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第8张图片

 

 

++D4.1、OnCollisionEnter

++D4.1、OnCollisionEnter

++D4.1、OnCollisionEnter

++++立钻哥哥:当碰撞进入

Rigidbody.OnCollisionEnter(Collision collision);

++++collider/rigidbody接触到另一个rigidbody/collider时,OnCollisionEnter被调用

++++OnTriggerEnter相比,OnCollisionEnter传递的是Collision类;Collision类包含有关接触点、碰撞速度等的信息;如果在函数中不使用collisionInfo,省略collisionInfo参数以避免不必要的计算;注意:当其中至少一个碰撞器附加非动力学刚体时碰撞事件才会发送;碰撞事件也发送给禁用的MonoBehaviours,允许启用Behaviour来相应碰撞

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    AudioSource audio;

 

    void Start(){

        audio = GetComponent<AudioSource>();

    }    //立钻哥哥:void Start(){}

 

    void OnCollisionEnter(Collision collision){

        //Debug-draw all contact points and normals

        foreach(ContactPoint contact in collision.contacts){

            Debug.DrawRay(contact.point, contact.normal, Color.white);

        }    //立钻哥哥:foreach(){}

 

        //Play a sound if the colliding objects had a big impact.

        if(collision.relativeVelocity.magnitude > 2){

            audio.Play();

        }    //立钻哥哥:if(){}

    

    }    //立钻哥哥:void OnCollisionEnter(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

//A grenade instantiates a explosion prefab when hitting a surface then destroys itself.

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

    public Transform explosionPrefab;

 

    void OnCollisionEnter(Collision collision){

        ContactPoint contact = conllision.contacts[0];

 

        //Rotate the object so that the y-axis faces along the normal of the surface

        Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);

        Vector3 pos = contact.point;

 

        Instantiate(explosionPrefab, pos, rot);

        Destroy(gameObject);

    }    //立钻哥哥:void OnCollisionEnter(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++D4.2、OnCollisionExit

++D4.2、OnCollisionExit

++D4.2、OnCollisionExit

++++立钻哥哥:当碰撞退出

Rigidbody.OnCollisionExit(Collision collisionInfo);

++++collider/rigidbody停止接触到另一个rigidbody/collider时,OnCollisionExit被调用

++++OnTriggerExit相比,OnCollisionExit传递的是Collision类;Collision类包含有关接触点、碰撞速度等的信息;如果在函数中不使用collisionInfo,省略collisionInfo参数以避免不必要的计算;注意:当其中至少一个碰撞器附加非动力学刚体时碰撞事件才会发送;碰撞事件也发送给禁用的MonoBehaviours,允许启用Behaviour来相应碰撞

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void OnCollisionExit(Collision collisionInfo){

        Debug.Log(立钻哥哥:No longer in contact with  + collisionInfo.transform.name);

    }    //立钻哥哥:void OnCollisionExit(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

++D4.3、OnCollisionStay

++D4.3、OnCollisionStay

++D4.3、OnCollisionStay

++++立钻哥哥:当碰撞停留

Rigidbody.OnCollisionStay(Collision collisionInfo);

++++collider/rigidbody一旦接触另一个rigidbody/collider时,OnCollisionStay每帧被调用

++++OnTriggerStay相比,OnCollisionEnter传递的是Collision类;Collision类包含有关接触点、碰撞速度等的信息;如果在函数中不使用collisionInfo,省略collisonInfo参数以避免不必要的计算;注意:当其中至少一个碰撞器附加非动力学刚体时碰撞事件才会发送;碰撞事件也发送给禁用的MonoBehaviours,允许启用Behaviour来相应碰撞

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRigidbody : MonoBehaviour{

 

    void OnCollisionStay(Collision collisionInfo){

        foreach(ContactPoint contact in collisionInfo.contacts){

            Debug.DrawRay(contact.point, contact.normal, Color.white);

        }

    }    //立钻哥哥:void OnCollisionStay(){}

 

}    //立钻哥哥:public class YanlzRigidbody{}

 

 

 

 

 

 

 

 

#E5、立钻哥哥对Rigidbody类的拓展

#E5、立钻哥哥对Rigidbody类的拓展

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第9张图片

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Transform变换]:https://blog.csdn.net/VRunSoftYanlz/article/details/106607761

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

++++[Renerer渲染器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106481994

++++[AudioSource]:https://blog.csdn.net/VRunSoftYanlz/article/details/106462679

++++[AudioClip]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448955

++++[Texture纹理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448589

++++[AssetBundle]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412190

++++[ScriptableObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106392769

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第10张图片

 

 

 

 

 

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

 

 

《UnityAPI.Rigidbody刚体》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Rigidbody+isKinematic+AddForce+立钻哥哥++OK+)_第11张图片

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

 

 

 

 

 

【XR游戏开发QQ群:784477094

++立钻哥哥推荐的拓展学习链接(Link_Url)

立钻哥哥推荐的拓展学习链接(Link_Url)

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/

++++虚拟现实VR资讯: https://blog.csdn.net/VRunSoftYanlz/article/details/89165846

++++HTC_VIVE开发基础https://blog.csdn.net/VRunSoftYanlz/article/details/81989970

++++Oculus杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82469850

++++Oculus安装使用https://blog.csdn.net/VRunSoftYanlz/article/details/82718982

++++Unity+SteamVR=>VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88809370

++++Unity减少VR晕眩症https://blog.csdn.net/VRunSoftYanlz/article/details/89115518

++++SteamVR简介https://blog.csdn.net/VRunSoftYanlz/article/details/86484254

++++SteamVR脚本功能分析https://blog.csdn.net/VRunSoftYanlz/article/details/86531480

++++SteamVR2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/86618187

++++SteamVR2.2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/88784527

++++SteamVR2.2.0快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/88833579

++++SteamVR2.2.0交互系统https://blog.csdn.net/VRunSoftYanlz/article/details/89199778

++++SteamVR2.2.0传送机制https://blog.csdn.net/VRunSoftYanlz/article/details/89390866

++++SteamVR2.2.0教程(一)https://blog.csdn.net/VRunSoftYanlz/article/details/89324067

++++SteamVR2.2.0教程(二)https://blog.csdn.net/VRunSoftYanlz/article/details/89894097

++++SteamVR_Skeleton_Poserhttps://blog.csdn.net/VRunSoftYanlz/article/details/89931725

++++SteamVR实战之PMCorehttps://blog.csdn.net/VRunSoftYanlz/article/details/89463658

++++SteamVR/Extrashttps://blog.csdn.net/VRunSoftYanlz/article/details/86584108

++++SteamVR/Inputhttps://blog.csdn.net/VRunSoftYanlz/article/details/86601950

++++OpenXR简介https://blog.csdn.net/VRunSoftYanlz/article/details/85726365

++++VRTK杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82562993

++++VRTK快速入门(杂谈)https://blog.csdn.net/VRunSoftYanlz/article/details/82955267

++++VRTK官方示例(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82955410

++++VRTK代码结构(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82780085

++++VRTK(SceneResources)https://blog.csdn.net/VRunSoftYanlz/article/details/82795400

++++VRTK_ControllerEventshttps://blog.csdn.net/VRunSoftYanlz/article/details/83099512

++++VRTK_InteractTouchhttps://blog.csdn.net/VRunSoftYanlz/article/details/83120220

++++虚拟现实行业应用https://blog.csdn.net/VRunSoftYanlz/article/details/88360157

++++Steam平台上的VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88960085

++++Steam平台热销VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/89007741

++++VR实验:以太网帧的构成https://blog.csdn.net/VRunSoftYanlz/article/details/82598140

++++实验四:存储器扩展实验https://blog.csdn.net/VRunSoftYanlz/article/details/87834434

++++FrameVR示例V0913https://blog.csdn.net/VRunSoftYanlz/article/details/82808498

++++FrameVR示例V1003https://blog.csdn.net/VRunSoftYanlz/article/details/83066516

++++SwitchMachineV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++PlaySceneManagerV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++Unity5.x用户手册https://blog.csdn.net/VRunSoftYanlz/article/details/81712741

++++Unity面试题ABChttps://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++Unity面试题Dhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630838

++++Unity面试题Ehttps://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity面试题Fhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630945

++++Cocos2dx面试题https://blog.csdn.net/VRunSoftYanlz/article/details/78630967

++++禅道[zentao]https://blog.csdn.net/VRunSoftYanlz/article/details/83964057

++++Lua快速入门篇(Xlua拓展):https://blog.csdn.net/VRunSoftYanlz/article/details/81173818

++++Lua快速入门篇(XLua教程):https://blog.csdn.net/VRunSoftYanlz/article/details/81141502

++++Lua快速入门篇(基础概述)https://blog.csdn.net/VRunSoftYanlz/article/details/81041359

++++框架知识点https://blog.csdn.net/VRunSoftYanlz/article/details/80862879

++++游戏框架(UI框架夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80781140

++++游戏框架(初探篇)https://blog.csdn.net/VRunSoftYanlz/article/details/80630325

++++.Net框架设计https://blog.csdn.net/VRunSoftYanlz/article/details/87401225

++++从零开始学架构https://blog.csdn.net/VRunSoftYanlz/article/details/88095895

++++设计模式简单整理https://blog.csdn.net/vrunsoftyanlz/article/details/79839641

++++专题:设计模式(精华篇)https://blog.csdn.net/VRunSoftYanlz/article/details/81322678

++++U3D小项目参考https://blog.csdn.net/vrunsoftyanlz/article/details/80141811

++++Unity小游戏算法分析https://blog.csdn.net/VRunSoftYanlz/article/details/87908365

++++Unity案例(Vehicle)https://blog.csdn.net/VRunSoftYanlz/article/details/82355876

++++UML类图https://blog.csdn.net/vrunsoftyanlz/article/details/80289461

++++PowerDesigner简介https://blog.csdn.net/VRunSoftYanlz/article/details/86500084

++++Unity知识点0001https://blog.csdn.net/vrunsoftyanlz/article/details/80302012

++++Unity知识点0008https://blog.csdn.net/VRunSoftYanlz/article/details/81153606

++++U3D_Shader编程(第一篇:快速入门篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372071

++++U3D_Shader编程(第二篇:基础夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372628

++++Unity引擎基础https://blog.csdn.net/vrunsoftyanlz/article/details/78881685

++++Unity面向组件开发https://blog.csdn.net/vrunsoftyanlz/article/details/78881752

++++Unity物理系统https://blog.csdn.net/vrunsoftyanlz/article/details/78881879

++++Unity2D平台开发https://blog.csdn.net/vrunsoftyanlz/article/details/78882034

++++UGUI基础https://blog.csdn.net/vrunsoftyanlz/article/details/78884693

++++UGUI进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78884882

++++UGUI综合https://blog.csdn.net/vrunsoftyanlz/article/details/78885013

++++Unity动画系统基础https://blog.csdn.net/vrunsoftyanlz/article/details/78886068

++++Unity动画系统进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78886198

++++Navigation导航系统https://blog.csdn.net/vrunsoftyanlz/article/details/78886281

++++Unity特效渲染https://blog.csdn.net/vrunsoftyanlz/article/details/78886403

++++Unity数据存储https://blog.csdn.net/vrunsoftyanlz/article/details/79251273

++++Unity中Sqlite数据库https://blog.csdn.net/vrunsoftyanlz/article/details/79254162

++++WWW类和协程https://blog.csdn.net/vrunsoftyanlz/article/details/79254559

++++Unity网络https://blog.csdn.net/vrunsoftyanlz/article/details/79254902

++++Unity资源加密https://blog.csdn.net/VRunSoftYanlz/article/details/87644514

++++PhotonServer简介https://blog.csdn.net/VRunSoftYanlz/article/details/86652770

++++编写Photon游戏服务器https://blog.csdn.net/VRunSoftYanlz/article/details/86682935

++++C#事件https://blog.csdn.net/vrunsoftyanlz/article/details/78631267

++++C#委托https://blog.csdn.net/vrunsoftyanlz/article/details/78631183

++++C#集合https://blog.csdn.net/vrunsoftyanlz/article/details/78631175

++++C#泛型https://blog.csdn.net/vrunsoftyanlz/article/details/78631141

++++C#接口https://blog.csdn.net/vrunsoftyanlz/article/details/78631122

++++C#静态类https://blog.csdn.net/vrunsoftyanlz/article/details/78630979

++++C#中System.String类https://blog.csdn.net/vrunsoftyanlz/article/details/78630945

++++C#数据类型https://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity3D默认的快捷键https://blog.csdn.net/vrunsoftyanlz/article/details/78630838

++++游戏相关缩写https://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++UnityAPI.Rigidbody刚体https://blog.csdn.net/VRunSoftYanlz/article/details/81784053

++++UnityAPI.Material材质https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++UnityAPI.Android安卓https://blog.csdn.net/VRunSoftYanlz/article/details/81843193

++++UnityAPI.AndroidJNI安卓JNIhttps://blog.csdn.net/VRunSoftYanlz/article/details/81879345

++++UnityAPI.Transform变换https://blog.csdn.net/VRunSoftYanlz/article/details/81916293

++++UnityAPI.WheelCollider轮碰撞器https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++UnityAPI.Resources资源https://blog.csdn.net/VRunSoftYanlz/article/details/83155518

++++JSON数据结构https://blog.csdn.net/VRunSoftYanlz/article/details/82026644

++++CocosStudio快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/82356839

++++Unity企业内训(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82634668

++++Unity企业内训(第1讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82634733

++++Unity企业内训(第2讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82861180

++++Unity企业内训(第3讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82927699

++++Unity企业内训(第4讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83479776

++++Unity企业内训(第5讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83963811

++++Unity企业内训(第6讲)https://blog.csdn.net/VRunSoftYanlz/article/details/84207696

++++钻哥带您了解产品原型https://blog.csdn.net/VRunSoftYanlz/article/details/87303828

++++插件https://blog.csdn.net/VRunSoftYanlz/article/details/83963905

++++计算机组成原理(教材篇)https://blog.csdn.net/VRunSoftYanlz/article/details/82719129

++++5G接入:云计算和雾计算https://blog.csdn.net/VRunSoftYanlz/article/details/88372718

++++云计算通俗讲义https://blog.csdn.net/VRunSoftYanlz/article/details/88652803

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz

--_--VRunSoft:lovezuanzuan--_--

你可能感兴趣的:(VR云游戏实战零碎技术点,Unity开发基础,UnityAPI)