hi. used this function to spawn and attach my weapon to an arrow.
void AHeroCharacter::SpawnGun()
{
if (WhatToSpawn)
{
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters sp;
sp.Owner = this;
sp.Instigator = Instigator;
FVector SpawnLocation =GunTemp->GetComponentLocation() ;
FRotator SpawnRotation = GunTemp->GetComponentRotation();
AWeapon* Weapon=World->SpawnActor<AWeapon>(WhatToSpawn, SpawnLocation, SpawnRotation, sp);
Weapon->AttachRootComponentTo(GunTemp);
}
}
}
and i called this function in begin play but it appears far away from arrow component after spawning, how to fix it?