/// <summary> /// Look at target /// </summary> /// <param name="target">Target</param> /// <param name="up">Up vector</param> /// <param name="yAxisOnly">Rotate Y axis only</param> /// <param name="interpolationAmount">Interpolation amount for linear interpolation</param> /// <param name="updateState">Update internal state</param> public void LookAt(Vector3 target, Vector3 up, bool yAxisOnly = true, float interpolationAmount = 0, bool updateState = false) { if (this.Parent != null) { //Set parameters to local space var parentTransform = Matrix.Invert(this.Parent.FinalTransform); target = Vector3.TransformCoordinate(target, parentTransform); } if (!Vector3.NearEqual(this.position, target, new Vector3(MathUtil.ZeroTolerance))) { var newRotation = Helper.LookAt(this.position, target, up, yAxisOnly); if (interpolationAmount > 0) { newRotation = Quaternion.Lerp(this.rotation, newRotation, interpolationAmount); } this.SetRotation(newRotation, updateState); } }