Why wouldnt we use C++ to set Actor Offset

In the Attaching Meshes Via Sockets video Sam moves the Gun while in game and then copies the location and pastes that into the Gun BP

What is the benefit of this approach vs using CPP like in the code below:
Gun = GetWorld()->SpawnActor(GunClass);
GetMesh()->HideBoneByName(TEXT(“weapon_r”), EPhysBodyOp::PBO_None);
Gun->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, TEXT(“WeaponSocket”));
FHitResult* hit = new FHitResult();
Gun->AddActorLocalOffset(FVector(0.f, -15.f, -1.f), false, hit, ETeleportType::None);
Gun->SetOwner(this);

Can anyone comment on this code and let me know if there is something wrong with it as well

Should be the same but you don’t have to re-compile. Also please use a code block in the future by surrounding the code with three backticks

```
code
```

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms