Head rotation using blend tree and script

I have a blend tree that controls the head rotation, and I want it to look wherever the camera is pointing relative to the player. It has 2 parameters(LookX, LookY), and I’m not sure how I can do this. I know you can use IK for this but doing it like this gives me more control and IK can look really weird at times.
You can see the setup here.


I have a video that kinda shows how it should look here - https://drive.google.com/file/d/13RUh-7JuqLPGND4zshqExSBBmYiNqeI0/view?usp=sharing

What part isn’t working exactly? I watched the video and it seems to be blending between the animations. Do you mean you’re not sure how to script the actual calculation to set lookX and lookY to?

  1. Find max degrees for the turn relative to forward, lets say its 90.
  2. Find the degrees from character-forward direction to the camera-forward direction. (Vector3.SignedAngle())
  3. Normalize the degrees you have now to be 0-1.
  4. Push the normalized value into the animator parameter. (Animator.SetFloat())

it’s the calculations that I am having troubles with.

I’m not really sure how to do steps 2 and 3, I tried this bit of code here
float headDirX = Vector3.SignedAngle(headLook.forward, transform.forward, Vector3.forward);
and when I go to debug log it it works when the camera is positioned behind, but it kinds combines the x and y axis so from the front(when x is closer to 0 and y is closer to 180) it doesn’t work. This kind of math isn’t my strongsuit so I don’t really know what this function is doing so I’m probably using it horribly wrong though.