Hello I am working on a game and I am trying to add a wire to connect a powersource and drainer. In order to do this I thought it would be best to have sockets on both the powersource and drainer mesh and then corresponding sockets on the wire. Then attach the sockets. The code in the wire looks like this
void ABaseWire::ConnectPowerSource(FVector DrainerConnection, FVector SourceConnection, AItem* PowerSource, AItem* Drainer)
{
SetSize((UKismetMathLibrary::Vector_Distance(DrainerConnection, SourceConnection)) / 100);
SetActorLocation(DrainerConnection);
Drainer->AttachWireToSelf(this, "DrainerSocket");
SetActorRotation(UKismetMathLibrary::FindLookAtRotation(DrainerConnection, SourceConnection));
PowerSource->AttachWireToSelf(this, "PowerSourceSocket");
SetActorHiddenInGame(false);
}
And the attach to self function is called by the item here
void AItem::AttachWireToSelf(AItem* Wire, FName SocketName)
{
const FTransform orientation_socket = Mesh->GetSocketTransform(SocketName, ERelativeTransformSpace::RTS_World);
Wire->AttachToComponent(Mesh, FAttachmentTransformRules::SnapToTargetIncludingScale, SocketName);
}```
This code does not appear to work it will not show in game and obly be attached to the powersource when I look at the global actors. How can I attach it to both sockets?