// 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
SetOwner(NewOwner);
}
}
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)
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
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.