AttachTo Refusing to attach to a Socket Correctly

What Happens in the editor

Also heres a Gyazo MP4 of it in action…

The Actual code. Why does this happen? Even the gun gets bigger? Those items in the back are the same referenced objects just pickup actors

Weapon base File Logic CPP

// Called when the game starts or when spawned
void AWeaponBase::AttachMeshToPawn(AdarkstormCharacter* NewOwner)
	WeaponMesh->AttachTo(NewOwner->GetMesh(), "WeaponPoint", EAttachLocation::SnapToTarget);
	//WeaponMesh->AttachTo(NewOwner->GetMesh() ,(TEXT("WeaponPoint")));
void AWeaponBase::SetOwningPawn(AdarkstormCharacter* NewOwner)
	if (MyPawn != NewOwner)
		Instigator = NewOwner;
		MyPawn = NewOwner;
		// net owner for RPC calls

Weapon Logic to Spawn Weapon in Character

//	NewWeapon = WeaponPickup_AR20->WeaponClassToGive;
			UE_LOG(LogTemp, Warning, TEXT("Found Object I think"));
			UWorld* const World = GetWorld();
			if (World)
			FActorSpawnParameters SpawnInfo;
			SpawnInfo.Owner = this;
			SpawnInfo.Instigator = this;
			SpawnInfo.bNoCollisionFail = true;

			NewWeapon = World->SpawnActor<AWeaponBase>(WeaponClassToGive, GetMesh()->GetSocketLocation(TEXT("WeaponPoint")), GetMesh()->GetSocketRotation(TEXT("WeaponPoint")), SpawnInfo);

Try doing NewWeapon->SetRelativeLocationAndRotation and use FVector::ZeroVector and FRotator::ZeroRotator as the arguments.

You are attaching it correctly by the looks of it, but if you don’t set the relative location and rotation it’ll keep it’s offsets.

It might be inheriting the Socket Scale too. Make sure the scale for everything in that character is set to 1, 1, 1. You can check out how Cameras are attached to SpringArm sockets too if you like, check out ShooterGame (don’t have the sample available atm)

Update: Now it just purely does this after adjusting the code like this: Ends up I just needed to recompile and clean on visual

So about the scale? I notice if i set the socket scale in the Skeleton it fixes it. Is it because the character model im using wasn’t scaled for the engine shes using the old measurements from UDK so we scaled her here and what would you recommend?

If you look at the bottom right you’ll see we scaled her X,Y and Z in the editor

What happens if i scale the socket in the skeleton

1.0 Scaling in Skeleton for Socket

It’s because your mesh has a scale of 2.12354 - So whatever you attach to it will also inherit that scale. There’s only two ways you can get around this.

The first (and most preferred way) - Is to scale up the mesh in your modelling program and re-import it, making sure it’s at a Scale of 1.0. That’s generally good practice and really you should consider doing that anyway. Really, all of your meshes should work as intended at a scale of 1.0. Scaling doesn’t often work very well in Multiplayer and can cause lots of unforseen issues.

The second way which should just be a temporary workaround, is setting bAbsoluteScale to true in the Weapon Mesh. That way it’ll use it’s own world-based scale and won’t also add relative scale from the mesh.