赞
踩
版本 | 作者 | 参与者 | 完成日期 | 备注 |
UnityAPI_WheelCollider_V01_1.0 | 严立钻 |
| 2018.09.03 |
|
|
|
|
|
|
#《UnityAPI.WheelCollider轮碰撞器》发布说明:
++++“UnityAPI.WheelCollider轮碰撞器”是对UnityAPI中WheelCollider类的剖析和拓展;
#WheelCollider轮碰撞器
++++A、Description描述
++++B、Variables变量
++++C、Public Function共有函数
++++D、Message消息
++A、Description描述
++++立钻哥哥:class in UnityEngine / Inherits from: Collider;
++++用于车轮的特殊碰撞器;
++++轮子碰撞器用于车轮模型;它模拟弹簧和阻尼悬挂装置,并使用一个基于滑动轮胎摩擦力模型计算车轮接触力;
++++车轮的碰撞检测是由从自身y轴中心向下投射射线;车轮有一个半径和可以向下延长的suspensionDistance数;
++++车轮是由motorTorque,brakeTorque和steerAngle属性控制;
++++车轮碰撞器使用不同于物理引擎的一个基于滑动的摩擦力模型计算摩擦力;这允许更加真实的行为;而且使车轮忽略标准的PhysicMaterial设置;通过改变车轮所碰到的forwardFriction和sidewaysFriction来模拟不同的道路材质;
++B、Variables变量
++++B.1、brakeTorque 制动扭矩
++++B.2、center 中心
++++B.3、forceAppPointDistance 着力点距离
++++B.4、forwardFriction 向前摩擦力
++++B.5、isGrounded 是否接地
++++B.6、mass 质量
++++B.7、motorTorque 马达扭矩
++++B.8、radius 半径
++++B.9、rpm 转速
++++B.10、sidewaysFriction 侧向摩擦力
++++B.11、sprungMass 簧载质量
++++B.12、steerAngle 转向角
++++B.13、suspensionDistance 悬挂距离
++++B.14、suspensionSpring 悬挂弹簧
++++B.15、wheelDampingRate 轮阻尼率
++B.1、brakeTorque 制动扭矩
++++立钻哥哥:WheelCollider.brakeTorque 制动扭矩;
public float brakeTorque; |
++Description描述
++++立钻哥哥:制动的扭矩;这个值必须为正;
++B.2、center 中心
++++立钻哥哥:WheelCollider.center 中心;
public Vector3 center; |
++Description描述
++++立钻哥哥:车轮的中心,基于物体的自身坐标空间;
++++车轮的中心描述如果车悬浮在空中车轮取得的坐标;这等于当弹簧处于最大伸长率时的车轮中心的坐标;
++B.3、forceAppPointDistance 着力点距离
++++立钻哥哥:WheelCollider.forceAppPointDistance 着力点距离;
public float forceAppPointDistance; |
++Description描述
++++立钻哥哥:从基本静止车轮测量的悬挂和轮胎的着力点;
++++该属性作为从基本车轮静止坐标,沿车辆刚体Y轴向量的距离(车轮的静止坐标由WheelCollider.spring.targetPosition的值确定);此参数模拟悬挂几何结构的有效辊轴中心;对于一辆标准的家庭轿车forceAppPointDistance的值,应该放在刚体质心下着力点约0.3m处;当转弯时,移动着力点向下引起更多滚动,而移动着力点向上导致更少滚动;着力点通常在刚体质心下方;
++++请注意:该参数等于0是不可取的,会导致在某些配置仿真不稳定;一旦发现当没有用户输入时,车走在平坦的表面失灵了,沿着该表面表现出抖动或漂移的行为,检查forceAppPointDistance的值;在编译器,当轮碰撞器对象被选择,此刻着力点会显示为绿色的辅助球;试着逐渐增加forceAppPointDistance的值,直到有满意的结果;
++B.4、forwardFriction 向前摩擦力
++++立钻哥哥:WheelCollider.forwardFriction 向前摩擦力;
public WheelFrictionCurve forwardFriction; |
++Description描述
++++立钻哥哥:在车轮指向方向上的摩擦力的属性;
++B.5、isGrounded 是否接地
++++立钻哥哥:WheelCollider.isGrounded 是否接地;
public bool isGround; |
++Description描述
++++立钻哥哥:表示车轮当前是否碰到什么(只读);
++B.6、mass 质量
++++立钻哥哥:WheelCollider.mass 质量;
public float mass; |
++Description描述
++++立钻哥哥:车辆的质量,以千克表示;该值必须大于0,通常该值的范围是20~80;
++B.7、motorTorque 马达扭矩
++++立钻哥哥:WheelCollider.motorTorque 马达扭矩;
public float motorTorque; |
++Description描述
++++立钻哥哥:在轮轴上的马达扭矩;根据方向正或负;
++++模拟刹车,不要使用马达扭矩负值,使用brakeTorque替代;
++B.8、radius 半径
++++立钻哥哥:WheelCollider.radius 半径;
public float radius; |
++Description描述
++++立钻哥哥:车轮的半径,基于物体的自身坐标空间;
++++该半径的缩放通过该变换的缩放修改;
++B.9、rpm 转速
++++立钻哥哥:WheelCollider.rpm 转速;
public float rpm; |
++Description描述
++++立钻哥哥:当前轮轴旋转速度,每分钟转速(只读);
++B.10、sidewaysFriction 侧向摩擦力
++++立钻哥哥:WheelCollider.sidewaysFriction 侧向摩擦力;
public WheelFrictionCurve sidewaysFriction; |
++Description描述
++++立钻哥哥:轮胎侧面方向上的摩擦力的属性;
++B.11、sprungMass 簧载质量
++++立钻哥哥:WheelCollider.sprungMass 簧载质量;
public float sprungMass; |
++Description描述
++++立钻哥哥:该车轮碰撞器支撑的质量;
++++车辆模拟使用簧载质量模型,一旦每个独立的车轮设置为簧载质量一组,这会分解车的全部质量到所有的车轮;然后,配合所有悬挂和每个轮胎质量的轮胎力;最后整合所有力应用到车辆主体;最简单是完全对称的四轮车,所有簧载质量等于四分之一汽车的质量;该属性基于车辆的配置自动计算的;
++B.12、steerAngle 转向角
++++立钻哥哥:WheelCollider.steerAngle 转向角;
public float steerAngle; |
++Description描述
++++立钻哥哥:转向角度,总是沿自身Y轴;
++++在高速度只使用小的转向角;很小的角度;
++B.13、suspensionDistance 悬挂距离
++++立钻哥哥:WheelCollider.suspensionDistance 悬挂距离;
public float suspensionDistance; |
++Description描述
++++立钻哥哥:车轮悬挂的最大伸展距离,基于自身坐标空间;
++++悬挂总是沿y轴向下伸展;悬挂的被缩放通过该变换的缩放修改;该suspensionDistance的值是沿该刚体向量的Y轴运动,从车轮中心最大弹簧伸长的坐标到车轮中心最大弹簧压缩的坐标的距离;单位是米;悬挂运动的范围被缩放,是通过该变换的缩放;
++B.14、suspensionSpring 悬挂弹簧
++++立钻哥哥:WheelCollider.suspensionSpring 悬挂弹簧;
public JointSpring suspensionSpring; |
++Description描述
++++立钻哥哥:车轮悬挂的参数;通过应用线性力和阻尼力,悬挂试图达到目标位置;
++++suspensionSpring.spring的值描述弹簧的刚度,单位是牛顿/米;弹簧强度对处理通过调节车辆在路面上的颠簸所需要的时间以及轮胎的负荷量有着深刻的影响;较大的值,使悬挂达到目标位置更快,弹簧反馈更强,越小的值越平衡,更少的弹簧反馈;
++++suspensionSpring.damper的值描述消耗储存在弹簧中能量是速率;单位是牛顿*米/秒,等于每单位速度牛顿;较大的值使悬挂更慢达到目标位置,较小的值使车辆更有弹性;车辆悬架通常已接近临界阻尼响应;
++++该车轮的静止坐标通过suspensionSpring.targetPosition指定;该值描述车轮的静止坐标作为沿suspensionDistance的系数,范围是0~1之间;0值表示完全伸展悬挂运动,1值表示完全压缩悬挂运动;默认为0.5,表示设置悬挂在车轮的静止坐标的最大伸展率和最大压缩率的中间;通常值的范围是0.3~0.7之间;
++B.15、wheelDampingRate 轮阻尼率
++++立钻哥哥:WheelCollider.wheelDampingRate 轮阻尼率;
public float wheelDampingRate; |
++Description描述
++++立钻哥哥:车轮的阻尼率;必须大于0值;
++C、Public Function共有函数
++++C.1、ConfigureVehicleSubsteps() 配置车辆子步参数
++++C.2、GetGroundHit() 获取碰撞
++++C.3、GetWorldPose() 获取世界姿态
++C.1、ConfigureVehicleSubsteps() 配置车辆子步参数
++++立钻哥哥:WheelCollider.ConfigureVehicleSubsteps 配置车辆子步参数;
public void ConfigureVehicleSubsteps(float speedThreshold, int stepsBelowThreshold, int stepsAboveThreshold); |
++++[speddThreshold]:子步算法的速度阀值;
++++[stepsBelowThreshold]:当车辆的速度是在速度阀值之下时,子步的模拟数;
++++[stepsAboveThreshold]:当车辆的速度是在速度阀值之上时,子步的模拟数;
++Description描述
++++立钻哥哥:配置车辆子步参数;
++++每次FixedUpdate更新,该车辆模拟分割固定增量时间到较小的子步并每小增量计算悬挂和轮胎力;然后会综合所有作用的力和扭矩,并应用到车体;
++++使用该函数可以自定义通过多少子步来执行模拟上下速度阀值;
++++每辆车只能调用一次该函数,实际上是设置车辆的参数,而不是车轮;
++C.2、GetGroundHit() 获取碰撞
++++立钻哥哥:WheelCollider.GetGroundHit 获取碰撞;
public bool GetGroundHit(out WheelHit hit); |
++Description描述
++++立钻哥哥:获取车轮的地面碰撞数据;
++++如果车轮碰撞到什么,返回true;如果车轮没有碰撞东西返回false,并且保持碰撞结构不变;
++C.3、GetWorldPose() 获取世界姿态
++++立钻哥哥:WheelCollider.GetWorldPose 获取世界姿态;
public void GetWorldPose(out Vector3 pos, out Quaternion quat); |
++++[pos]:在世界坐标空间,车轮的位置;
++++[quat]:在世界坐标空间,车轮的旋转;
++Description描述
++++立钻哥哥:获取世界坐标空间车轮与地面接触、悬挂限制、转向角以及选择角度的姿态;
++++Unity案例(Vehicle):https://blog.csdn.net/VRunSoftYanlz/article/details/82355876
#立钻哥哥拓展1:Armored Vehicle Kit示例
++++立钻哥哥:Dot_Truck_Controller.cs(\Assets\Armored Vehicles Kit\Scripts\Dot_Truck_Controller.cs)
using UnityEngine; using System.Collections; using System.Collections.Generic;
[System.Serializable] public class Dot_Truck : System.Object{ public WheelCollider leftWheel; public GameObject leftWheelMesh; public WheelCollider rightWheel; public GameObject rightWheelMesh; public bool motor; public bool steering; public bool reverseTurn; } //立钻哥哥:public class Dot_Truck:System.Object{}
public class Dot_Truck_Controller : MonoBehaviour{ public List<Dot_Truck> truck_Infos; public float maxMotorTorque; public float maxSteeringAngle;
public void VisualizeWheel(Dot_Truck wheelPair){ Quaternion rot; Vector3 pos;
wheelPair.leftWheel.GetWordPose(out pos, out rot); wheelPair.leftWheelMesh.transform.position = pos; wheelPair.leftWheelMesh.transform.rotation = rot;
wheelPair.rightWheel.GetWorldPose(out pos, out rot); wheelPair.rightWheelMesh.transform.position = pos; wheelPair.rightWheelMesh.transform.rotation = rot; }
public void Update(){ float motor = maxMotorTorque * Input.GetAxis(“Vertical”); float steering = maxSteeringAngle * Input.GetAxis(“Horizontal”); float brakeTorque = Mathf.Abs(Input.GetAxis(“Jump”));
if(brakeTorque > 0.001){ Debug.Log(“立钻哥哥:brakeTorque ” + brakeTorque); brakeTorque = maxMotorTorque; motor = 0; }else{ brakeTorque = 0; }
foreach(Dot_Truck truck_Info in truck_Infos){ if(truck_Info.steering == true){ truck_Info.leftWheel.steerAngle = truck_Info.rightWheel.steerAngle = ((truck_Info.reverseTurn) ? -1 : 1) *steering; }
if(truck_Info.motor == true){ truck_Info.leftWheel.motorTorque = motor; truck_Info.rightWheel.motorTorque = motor; }
truck_Info.leftWheel.brakeTorque = brakeTorque; truck_Info.rightWheel.brakeTorque = brakeTorque;
VisualizeWheel(truck_Info); } } //立钻哥哥:public void Update(){}
} //立钻哥哥:public class Dot_Truck_Controller:MonoBehaviour{} |
++立钻哥哥推荐的拓展学习链接(Link_Url):
++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/
++++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安卓JNI:https://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
++++U3D小项目参考:https://blog.csdn.net/vrunsoftyanlz/article/details/80141811
++++Unity案例(Vehicle):https://blog.csdn.net/VRunSoftYanlz/article/details/82355876
++++JSON数据结构:https://blog.csdn.net/VRunSoftYanlz/article/details/82026644
++++HTC_VIVE开发基础:https://blog.csdn.net/VRunSoftYanlz/article/details/81989970
++++Unity5.x用户手册:https://blog.csdn.net/VRunSoftYanlz/article/details/81712741
++++Unity面试题ABC:https://blog.csdn.net/vrunsoftyanlz/article/details/78630687
++++Unity面试题D:https://blog.csdn.net/VRunSoftYanlz/article/details/78630838
++++Unity面试题E:https://blog.csdn.net/vrunsoftyanlz/article/details/78630913
++++Unity面试题F:https://blog.csdn.net/VRunSoftYanlz/article/details/78630945
++++Cocos2dx面试题:https://blog.csdn.net/VRunSoftYanlz/article/details/78630967
++++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
++++设计模式简单整理:https://blog.csdn.net/vrunsoftyanlz/article/details/79839641
++++专题:设计模式(精华篇):https://blog.csdn.net/VRunSoftYanlz/article/details/81322678
++++UML类图:https://blog.csdn.net/vrunsoftyanlz/article/details/80289461
++++Unity知识点0001:https://blog.csdn.net/vrunsoftyanlz/article/details/80302012
++++Unity知识点0008:https://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
++++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
++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/
--_--VRunSoft:lovezuanzuan--_--
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。