switch (sender)
{
case ShootAction shootAction:
Unit shooterUnit = shootAction.GetUnit();
Unit targetUnit = shootAction.GetTargetUnit();
Vector3 unitHeight = new Vector3(0, 1.7f, 0);
Vector3 shootDir = (targetUnit.GetWorldPosition() - shooterUnit.GetWorldPosition()).normalized;
float shoulderOffsetAmount = .5f;
Vector3 shoulderOffset = Quaternion.Euler(0f, 90f, 0f) * shootDir * shoulderOffsetAmount;
Vector3 calcCamPos = shooterUnit.GetWorldPosition() + unitHeight + shoulderOffset + (shootDir * -1);
actionCameraGameObject.transform.position = calcCamPos;
actionCameraGameObject.transform.LookAt(targetUnit.GetWorldPosition() + unitHeight);
ShowActionCam();
break;
}
I’m very confused about the whole quaternion calculation, i think very slightly understand how it works, but i fail to understand why this is done instead of a simple vector calculation.
Initially i thought the lookDir was to look at the target but we do a simple transform.lookAt at the end.
So my question is, why did we opt for this calculation instead of a simple virtualCamGameObject.transform.position = new Vector3(xOffset, characterHeight, 0);
or even just have an empty gameObject in the unit and set the cam to that position.
I must be missing something, thanks in advance!