I'm trying to implement a form of aim assist for my FPS and I'm currently working on getting the camera to snap to a target for testing.
My camera system is the one used in Catlike Coding's character controller tutorial meaning that the orientation is controlled by a local vector3 rotation with the X value controlling the pitch and the Y value controlling the Yaw. The vector3 variable is called orbitAngles for context.
So far, I can get the camera to snap to a target with the following line.
Vector3 AngleDifference = Quaternion.LookRotation((_currentTarget.position - transform.position),transform.up).eulerAngles;
float DebugAngleY = AngleDifference.y-orbitAngles.y;
float DebugAngleX = AngleDifference.x-orbitAngles.x;
//Testing. Force snap view to target
if (Input.GetKeyDown(KeyCode.Y))
{
orbitAngles += new Vector3(DebugAngleX,DebugAngleY, 0);
//Corrects the values so they are within angle restraints
ConvertToDegrees();
}
This works when the player controller is using standard gravity directions however my game has gravity planes that change the gravity direction + player's orientation. If I try to snap to the target while on a gravity plane, the player will be looking in a different direction to the target. Sometimes it's close to it but never at the exact position of the target.
What can I do to get the camera to always look at the target object? Quaternions tend to do my head in so it could be something simples I'm overlooking.