目的:胶囊碰撞检测、处理在各种运动状态中,人物移动速度问题及动画机的中断处理
希望在空中一直播放fall,落地立即切换到idle
方法:添加组件OnGroundSensor作为yBot的兄弟物体
具体:
采用胶囊碰撞体 physics.overlapcapsule
public CapsuleCollider capcol;//胶囊碰撞体
public float offset = 0.1f;
private Vector3 point1;//胶囊体球心1 低
private Vector3 point2;//胶囊体球心2 高
private float radius;
// Start is called before the first frame update
void Awake()
{
radius = capcol.radius;//沉降碰撞胶囊
}
// Update is called once per frame
void FixedUpdate()
{
point1 = transform.position + transform.up * (radius - offset);//因为sensor是在脚下
point2 = transform.position + transform.up * (capcol.height - radius - offset);//高点球心
Collider[