喵的Unity游戏开发之路 - 互动环境(有影响的运动

修正

 

我改进了轨道摄像机的1.4节“使焦点居中”,以便更好地实现焦点居中和焦点半径限制的相互作用。调整OrbitCamera.UpdateFocusPoint如下:

 

  void UpdateFocusPoint () {    previousFocusPoint = focusPoint;    Vector3 targetPoint = focus.position;    if (focusRadius > 0f) {      float distance = Vector3.Distance(targetPoint, focusPoint);      float t = 1f;      if (distance > 0.01f && focusCentering > 0f) {        t = Mathf.Pow(1f - focusCentering, Time.unscaledDeltaTime);      }      if (distance > focusRadius) {        t = Mathf.Min€(t, focusRadius / distance);      }      focusPoint = Vector3.Lerp(targetPoint, focusPoint, t);    }    else {      focusPoint = targetPoint;    }  }

我还更改了“移动地面”部分2.3确定运动,因此忽略了质量较轻的连接物体。这样可以防止球体自动跟随其推开的轻物体。如下调整MovingSphere.UpdateState结尾:

 

    if (connectedBody) {      if (connectedBody.isKinematic || connectedBody.mass >= body.mass) {        UpdateConnectionState();      }    } 
 

 

最后,更改了“攀爬”第2.5节的“可选攀登”,以防止自动粘在动画的可攀爬表面上。这是通过在EvaluateCollision中调节desiresClimbing而不是在Climbing属性中完成的:

 

  bool Climbing =>climbContactCount > 0 && stepsSinceLastJump > 2;
    void EvaluateCollision (Collision collision) {        if (          desiresClimbing &&upDot >= minClimbDotProduct &&          (climbMask & (1 << layer)) != 0        ) {          climbContactCount += 1;          climbNormal += normal;          lastClimbNormal = normal;          connectedBody = collision.rigidbody;        }  } 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值