public override void MoveTowards(Vector3 velocity, AxisIgnore ignore) { if (!_isForced) { base.MoveTowards(velocity, ignore); } }
/// <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}"); }
public override void MoveTowards(Vector3 direction, float speed, AxisIgnore ignore) { if (!_isForced) { base.MoveTowards(direction, speed, ignore); } }
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); }
public void OverrideMoveTowards(Vector3 velocity, AxisIgnore ignore) { _isForced.Deactivate(); base.MoveTowards(velocity, ignore); }
public void OverrideMoveTowards(Vector3 direction, float speed, AxisIgnore ignore) { _isForced.Deactivate(); base.MoveTowards(direction, speed, ignore); }
// 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); }
public void Move(Vector3 dir, AxisIgnore ignore) { mover.MoveTowards(dir, speed, ignore); }