So i have a AWeapon, it is replicated so everyone can see it in game and wear the weapon.
Right now only the servers wearing for the sword is seen on clients. If i wear the sword on clients, it happens only at client and no one else sees it because of it right?
Question is: What is the way of doing it so that the clients can wear it and the server and other clients see it?
I now have this on the header:
void Equip(class AOnlineGameCharacter* character);
// Required network scaffolding
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
and on cpp:
void AWeapon::Equip(class AOnlineGameCharacter* character)
{
if (character)
{
SetInstigator(character->GetController());
SkeletalMesh>SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera,ECollisionResponse::ECR_Ignore);
SkeletalMesh>SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);
SkeletalMesh->SetSimulatePhysics(false);
const USkeletalMeshSocket* RightHandSocket = character>GetMesh()>GetSocketByName("RightHandItemSocket");
if (RightHandSocket)
{
RightHandSocket->AttachActor(this, character->GetMesh());
bRotate = false;
//character->GetEquippedWeapon()->Destroy();
character->SetEquippedWeapon(this);
character->SetActiveOverlappingItem(nullptr);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("righthandsocket null"));
}
}
}
// INTERNET STUFF?
void AWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
}
(Sorry it looks like that) I quess the equip function needs to to be played on the server but i dont know much about this networking stuff. I have tried to watch some guides and clone what they do but i still have hard time to get this to my head when i try to implement it my own.
Other thing is: this actor is just replicated and spaws emiter on collide, why other clients see the emitter if other client collides.
What about if i have a sword and mouseclick1 to swing it, how the attack will happen? Does it happen on the server too somehow or? If someone would give me a helping hand, how to implement this kind of multiplayer functionality and understand little more about networking, i would really be thankful.
Thanks for your time