How determine local location of spawned actor

So I’m spawning in an arrow and attaching it to my character. I’ve set up WeaponBase and WeaponTip scene components hoping that when the arrow attaches to my character, it will do so at the base scene component but I can only find answers on how to set the components location in the world rather than what the arrow location is. Does anyone have any ideas? Using C++ but I can adapt blueprint answers too.

In BP, you can use an [Inverse Transform Location] node.
In C++, I’m not sure; for some reason InverseTransformLocation() is in KismetMathLibrary.h, but not in KismetMathLibrary.cpp, so I can’t figure out the math =)
If you do, please let me know.

1 Like

Searching for InverseTransformLocation eventually leads to

FORCEINLINE FVector FTransform::InverseTransformPosition(const FVector &V) const
{
	DiagnosticCheckNaN_All();

	const VectorRegister InputVector = VectorLoadFloat3_W0(&V);

	// (V-Translation)
	const VectorRegister TranslatedVec = VectorSet_W0(VectorSubtract(InputVector, Translation));

	// ( Rotation.Inverse() * (V-Translation) )
	const VectorRegister VR = VectorQuaternionInverseRotateVector(Rotation, TranslatedVec);

	// GetSafeScaleReciprocal(Scale3D);
	const VectorRegister SafeReciprocal = GetSafeScaleReciprocal(Scale3D);	

	// ( Rotation.Inverse() * (V-Translation) ) * GetSafeScaleReciprocal(Scale3D);
	const VectorRegister VResult = VectorMultiply(VR, SafeReciprocal);

	FVector Result;
	VectorStoreFloat3(VResult, &Result);
	return Result;
}