GetSocketLocation returning local position

Hello,
I have my character, who is the owner of the weapon item which has a socket callled Fire_Position. This is where the projectile is supposed to be launched from. From what I understand GetSocketLocation() should return the position of that socket in world space where i can then spawn the projectile. But what has happened is it is giving me the location of the socket relative to the skeletal mesh bone of the weapon. I have no idea why it is happening. Here is my code:

FActorSpawnParameters params;
params.Owner = this;
params.Instigator = Instigator;
 AAmmunitionItem* projectile =  GetWorld()->SpawnActor<AAmmunitionItem>(item->projectile, item->Mesh->GetSocketLocation(FName("Fire_Position")), item->GetActorRotation(), params);

EDIT:

After additional testing, it turns out I can get world location of the socket from other places within the code. I cannot however get it within my firing function, which is where i specifically spawn the projectile. I do not know whether this is a bug, or maybe there is something that is keeping it from giving me the correct coordinates.

EDIT 2:

So set a FVector in the tick function and it would continually update with the correct coordinates. But as soon as I checked that Vectore from the Fire() function it would return at the wrong coordinates.

I will post the whole code so maybe it will give some insight:

void APlayerCharacter::OnLeftMouse() {

	if (Inventory->Equipped[0] != NULL) {

		AItemBase* i = Inventory->Equipped[0]->Base;

		if (i->tag == EItemTag::Usable) {
			if (i->IsA(AUsableItem::StaticClass())) {
				AUsableItem* j = Cast<AUsableItem>(i);
				if (j->uTag == EUsableTag::Ranged) {
					if (j->IsA(ARangedWeapon::StaticClass())) {
						ARangedWeapon* k = Cast<ARangedWeapon>(j);
						Fire(k);
					}
				}
			}

		}
	}
}


void APlayerCharacter::Fire(ARangedWeapon* item) {
	if (item->projectile->IsChildOf(AAmmunitionItem::StaticClass())) {
		FActorSpawnParameters params;
		params.Owner = this;
		params.Instigator = Instigator;
		AAmmunitionItem* projectile =  GetWorld()->SpawnActor<AAmmunitionItem>(item->projectile, ActorToWorld().TransformPosition(item->firePosition), item->GetActorRotation(), params);
	}
}

Any help is appreciated,

GetSocketLocation() returns the ComponentLocation when you try to access an invalid socket. Make sure your socket exists and that your name is correct.
Also you can just enter a string when FName is expected.

Instead of Mesh->GetSocketLocation(FName("Fire_Position"))

Try Mesh->GetSocketLocation("Fire_Position")

Thank you for the response, but I have already checked that the socket exists. Currently the socket relative to the bone it is on is 0,0,114. When I print item->Mesh->GetSocketLocation(“Fire_Position”).ToString(); it returns 0,0,114.

Hey, after reading your edit of your initial post, I came to think that this is indeed some kind of bug. Not sure if I can reproduce this though.

This unfortunately does not work.

Inventory->Equipped is an array of UInventorySlot* which contain a reference to AItemBase* called Base.

Well… This actually had a simple solution but of course I was just looking in the wrong spot. The problem was that when I added an item to the the Equipped array, I added the reference to an AItemBase called base. Because it was never spawned, its location was always at 0, and therefore GetSocketLocation() looked like it was returning local position. What I did was is just spawn the AItemBase, then add it to the array. It now works like a charm.