How to position an avatar slightly behind a first person controller?

I have developed my own first person controller (with affiliated camera views). I would like to have the third person character follow slightly behind the headset’s camera view so that the user has a shadow and can see his/her limbs moving with the controllers (using inverse kinematics).

Here’s how I’m approaching it now:

  • I first rotate the character, and then try to update the transform’s position.
  • The rotation follows the camera well (the avatar always faces the same direction as the eye camera), but the position does not. The avatar is always located at the desired position in the WORLD’s reference frame, rather than in its own reference frame.

I include my Update function below, and screenshots of my hierarchy and inspector.



void Update () {

	//These two lines set the IK targets - not relevant to my question...
	leftHandIKTarget.position = leftController.transform.position;
	rightHandIKTarget.position = rightController.transform.position;

	// Make sure the avatar is rotated appropriately
	turning = eyeCamera.transform.rotation.eulerAngles; //Get rotation of headset
	turning.x = human.transform.eulerAngles.x;
	turning.z = human.transform.eulerAngles.z;
	human.transform.eulerAngles = turning; //Keep x and z rotations the same, but update avatar Y rotation

	// Set the avatar position slightly behind the first person camera
	location = eyeCamera.transform.position;
	location.z = location.z + zAdjust;
	location.x = location.x + zAdjust;
	location.y = location.y - yAdjust;
	human.transform.position = location;


I also tried some sines and cosines in the Update function, but that isn’t working either…

	worldAngle = toolkitCam.transform.eulerAngles;
	humanAngle = human.transform.eulerAngles;

	location = human.transform.position;
	anglesCurr = humanAngle - worldAngle;
	angleZ = anglesCurr.z;
	shiftX = zAdjust * Mathf.Sin (angleZ*Mathf.Deg2Rad);
	shiftZ = zAdjust * Mathf.Cos (angleZ*Mathf.Deg2Rad);
	location.x = location.x + shiftX;
	location.z = location.z + shiftZ;
	human.transform.position = location;


human.transform.localPosition = location;