コード例 #1
0
 public override void MoveTowards(Vector3 velocity, AxisIgnore ignore)
 {
     if (!_isForced)
     {
         base.MoveTowards(velocity, ignore);
     }
 }
コード例 #2
0
        /// <summary>
        /// 将一个Vector3向量的XY分量旋转角度制degree
        /// </summary>
        /// <param name="self"></param>
        /// <param name="degree"></param>
        /// <returns></returns>
        public static Vector3 RotateDegree(this Vector3 self, float degree, AxisIgnore axisIgnore)
        {
            var sin = Mathf.Sin(degree * Mathf.Deg2Rad);
            var cos = Mathf.Cos(degree * Mathf.Deg2Rad);

            if (axisIgnore == AxisIgnore.X)
            {
                return(new Vector3(
                           self.x,
                           self.z * cos - self.y * sin,
                           self.z * sin + self.y * cos));
            }

            if (axisIgnore == AxisIgnore.Y)
            {
                return(new Vector3(
                           self.x * cos - self.z * sin,
                           self.y,
                           self.x * sin + self.z * cos));
            }

            if (axisIgnore == AxisIgnore.Z)
            {
                return(new Vector3(
                           self.x * cos - self.y * sin,
                           self.x * sin + self.y * cos,
                           self.z));
            }

            throw new Exception($"Unexpected AxisIgnore:{axisIgnore}");
        }
コード例 #3
0
 public override void MoveTowards(Vector3 direction, float speed, AxisIgnore ignore)
 {
     if (!_isForced)
     {
         base.MoveTowards(direction, speed, ignore);
     }
 }
コード例 #4
0
 public virtual void MoveTowards(Vector3 velocity, AxisIgnore ignore)
 {
     if (ignore.xIgnore)
     {
         velocity.x = _rb.velocity.x;
     }
     if (ignore.yIgnore)
     {
         velocity.y = _rb.velocity.y;
     }
     if (ignore.zIgnore)
     {
         velocity.z = _rb.velocity.z;
     }
     MoveTowards(velocity);
 }
コード例 #5
0
 public void OverrideMoveTowards(Vector3 velocity, AxisIgnore ignore)
 {
     _isForced.Deactivate();
     base.MoveTowards(velocity, ignore);
 }
コード例 #6
0
 public void OverrideMoveTowards(Vector3 direction, float speed, AxisIgnore ignore)
 {
     _isForced.Deactivate();
     base.MoveTowards(direction, speed, ignore);
 }
コード例 #7
0
 // Move in the given direction, but leave the given axes unaffected
 public virtual void MoveTowards(Vector3 direction, float speed, AxisIgnore ignore)
 {
     MoveTowards(direction.ScaledVector(speed), ignore);
 }
コード例 #8
0
 public void Move(Vector3 dir, AxisIgnore ignore)
 {
     mover.MoveTowards(dir, speed, ignore);
 }