I am trying to use the position of a CorgiEngine reticle (aim target) to set the position of a Spine 'aiming' bone.
The problem is that the CorgiEngine reticle is placed via a combination of position & rotation, whereas the function to translate worldPosition to localPosition doesn't take the rotation into account.
The reticle.position keeps a value for X only and tells Unity how far away from the weapon to place the reticle.
The reticle.rotation keeps a value for Z only and tells Unity at what rotation to place the reticle based on the player's aim.
Is there a way to take transform.Rotation into account when converting to localPosition with InverseTransformPoint?
At the moment (just using InverseTransformPoint) the Spine bone is placed at a localPostion of (reticleDistance, 0) and doesn't take into account the reticle.rotation.Z changes when manipulating aim.
void WeaponAim_UpdateBone(ISkeletonAnimation animated)
{
var localPosition = transform.InverseTransformPoint(_reticle.transform.position);
if (!_weapon.Owner.IsFacingRight)
{
localPosition.x = -localPosition.x;
}
_skeletonAnimator.Skeleton.FindBone("crosshair").SetPosition(localPosition);
}
I've tried a few things with multiplying Quaternions but haven't been able to figure it out yet.