Here’s my C++ version of the tutorials
Hello everyone.
I’m proud to show off my C++ version of these tutorials.
It’s available free at my GitHub account: GitHub - marcthenarc/NetGameCPP: A C++ version of the Network Bluprint tutorial
As you can see, I added a semi-transparent HUD. I also added more bounciness in the bombs with accurate rotation. But everything works as advertised. It took me a while to get the equivalent calls to work.
I’ve also noticed that in C++, when the server receives the signal OnPropjectileBounce(), it has the authority to set Armed to true but this change won’t reflect on itself, only clients receiving that change to Armed will call OnRep_Armed(). This can be seen as an optimization if whatever is done in OnRep_Armed() is purely cosmetic for a dedicated server - in this case, it merely changes the bomb’s colour - but for a client that also plays the role of server to everyone else, the colour never changed because OnRep_Armed was never called. Maybe there’s a call that I missed or a UPROPERTY() meta parameter to add, somehow.
void ABomb::OnProjectileBounce(const FHitResult& ImpactResult, const FVector& ImpactVelocity)
{
if (Role == ROLE_Authority)
{
Armed = true;
// You must call the rep function yourself for the server or it will never change color.
OnRep_Armed();
GetWorldTimerManager().SetTimer(this, &ABomb::OnFuseExpired, FuseTime, false);
}
}
Enjoy! Let me know what you think and suggestions are always welcome for making better code.