public virtual void SyncSpeed(float value) { Vector3 v = m_velocity; if (!CMathUtil.ZeroVector3(v)) { SetVelicity(value * v.normalized); } }
/// <summary> /// 在xz平面方向上的矢量 /// </summary> /// <param name="value">value的值是基于NDC空间的.0度旋转是vect3.right</param> public void SetDirection(Vector3 value) { value.y = 0; if (CMathUtil.ZeroVector3(value)) { return; } SetRotationByVelocity(value); m_trans.localEulerAngles = new Vector3(0, m_rotationDegree, 0); }
/// <summary> /// 开始奔跑, 传入单位速度矢量 /// 但记住如果之前开始了不受控制, 那请关闭它 /// </summary> /// <param name="value">方向矢量</param> /// <param name="changeDirection">是否更新朝向</param> public void Move(Vector3 value, bool changeDirection = true) { if (CMathUtil.ZeroVector3(value)) { Stop(); return; } m_currState.SetVelicity(MaxSpeed * value); if (changeDirection) { m_spacial.SetDirection(value); } }