public static void Orbit(Vector3 _creature, Vector3 _center, float _radius, float _degress, float _shift, float _min, float _max, float _level) { float _angle = PositionTools.GetNormalizedVectorAngle(_creature - _center); Vector3 _last_position = Vector3.zero; while ((_shift > 0 && _radius < _max) || (_shift < 0 && _radius > _min)) { _radius += _shift * 0.02f; if (_radius < _min) { _radius = _min; } else if (_max > 0 && _radius > _max) { _radius = _max; } _angle += _degress; if (_angle > 360) { _angle = _angle - 360; } float _a = _angle * Mathf.PI / 180f; Vector3 _new_position = _center + new Vector3(Mathf.Sin(_a) * _radius, 0, Mathf.Cos(_a) * _radius); _new_position.y = _level; if (_last_position != Vector3.zero) { Gizmos.DrawLine(_last_position, _new_position); } _last_position = _new_position; } if (_shift < 0) { Circle(_center, _min, 5, true, "", false); } else if (_shift > 0) { Circle(_center, _max, 5, true, "", false); } else { Circle(_center, _radius, 5, true, "", false); } }
/// <summary> /// Gets the direction angle. /// </summary> /// <returns>The direction angle.</returns> /// <param name="_transform">Transform.</param> /// <param name="_position">Position.</param> public static float GetSignedDirectionAngle(Transform _transform, Vector3 _position) { if (_transform == null) { return(0); } float _angle = MathTools.NormalizeAngle(PositionTools.GetNormalizedVectorAngle(_position - _transform.position) - _transform.eulerAngles.y); if (_angle > 180) { _angle -= 360; } return(_angle); }