public IEnumerator RushOnTarget() { yield return(new WaitForSeconds(_timeBeforeRush)); var direction = _target.transform.position - transform.position; var angle = MathHelper.DirectionToAngle(direction); Rotation = angle; Direction = -MathHelper.AngleToDirection(angle); _rushing = true; while (Acceleration.x < _maxAcceleration && Acceleration.y < _maxAcceleration) { Acceleration += Vector2.one * _accelerationOverTime; yield return(null); } }
/// <summary> /// Set bullet direction from angle in degrees /// </summary> /// <param name="angle">Angle value in degrees</param> public void SetDirectionFromAngle(float angle) { SetDirection(MathHelper.AngleToDirection(angle)); }