diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index 669945e7e..c3b13bece 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -317,6 +317,23 @@ namespace FlaxEngine } } + /// + /// Rotates the actor around axis passing through point in world-space by angle (in degrees). + /// + /// Modifies both the position and the rotation of the actor (scale remains the same). + /// The point (world-space). + /// The axis (normalized). + /// The angle (in degrees). + public void RotateAround(Vector3 point, Vector3 axis, float angle) + { + var transform = Transform; + var q = Quaternion.RotationAxis(axis, angle * Mathf.DegreesToRadians); + var dif = (transform.Translation - point) * q; + transform.Translation = point + dif; + transform.Orientation = q; + Transform = transform; + } + /// public override string ToString() {