set character rotation to camera view angle

MarkusKer

Member
Hello, I am trying to create a new ability.
At the start of the ability, the character (adventure movement) should rotate towards the camera viewing direction before executing a root motion animator state.

I am not sure what to put in the red marked section (the target of the camera?):

protected override void AbilityStarted()
{
base.AbilityStarted();
var lookDirection =
m_CharacterLocomotion.LocalTorque.eulerAngles - m_Transform.position;
var rotation = m_Transform.rotation;
var localLookDirection = MathUtility.InverseTransformDirection(lookDirection, rotation);
localLookDirection.y = 0;
lookDirection = MathUtility.TransformDirection(localLookDirection, rotation);
var targetRotation = Quaternion.LookRotation(lookDirection, rotation * Vector3.up);
targetRotation = Quaternion.Slerp(rotation, targetRotation, m_CharacterLocomotion.MotorRotationSpeed * Time.deltaTime);
m_CharacterLocomotion.DesiredRotation = MathUtility.InverseTransformQuaternion(m_Transform.rotation, targetRotation);

Rootmotion = Controller.UseRootMotionPosition;
Controller.UseRootMotionPosition = true;
}


Regards,
Markus
 
Top