#multiplayer
1 messages · Page 94 of 1
void AWeapon::AddAmmo(int32 Amount)
{
if (GetWorld()->GetNetMode() == NM_Client)
{
UE_LOG(LogTemp, Warning, TEXT("Fired on Client"))
}
if (GetWorld()->GetNetMode() == NM_ListenServer)
{
UE_LOG(LogTemp, Warning, TEXT("Fired on Server"))
}
Ammo = FMath::Clamp(Ammo - Amount, 0 , MagCapacity);
}
``` prints Fire On Server and only if there is a Server Player
this is what I put in my DefaulEngine.ini ```
[URL]
GameName=FiveNightsAtIvans
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/ThirdPersonBP/Maps/Menu.Menu
GameDefaultMap=/Game/ThirdPersonBP/Maps/Menu.Menu
TransitionMap=
bUseSplitscreen=True
TwoPlayerSplitscreenLayout=Horizontal
ThreePlayerSplitscreenLayout=FavorTop
GlobalDefaultGameMode=/Game/ThirdPersonBP/Blueprints/ThirdPersonGameMode.ThirdPersonGameMode_C
GlobalDefaultServerGameMode=None
GameInstanceClass=/Game/ThirdPersonBP/Blueprints/Game_Inst.Game_Inst_C
[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
MinimumiOSVersion=IOS_12
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_ThirdPersonBP",NewGameName="/Script/FiveNightsAtIvans")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_ThirdPersonBP",NewGameName="/Script/FiveNightsAtIvans")
[/Script/Engine.RendererSettings]
r.CustomDepth=3
[/Script/Engine.PhysicsSettings]
PhysicErrorCorrection=(PingExtrapolation=0.100000,PingLimit=100.000000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,MaxLinearHardSnapDistance=400.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000)
DefaultDegreesOfFreedom=Full3D
bSuppressFaceRemapTable=False
bSupportUVFromHitResults=False
bDisableActiveActors=False
bDisableKinematicStaticPairs=False
bDisableKinematicKinematicPairs=False
bDisableCCD=False
bEnableEnhancedDeterminism=False
AnimPhysicsMinDeltaTime=0.000000
bSimulateAnimPhysicsAfterReset=False
MaxPhysicsDeltaTime=0.033333
bSubstepping=False
bSubsteppingAsync=False
MaxSubstepDeltaTime=0.016667
MaxSubsteps=6
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
+PhysicalSurfaces=(Type=SurfaceType1,Name="Grass")
+PhysicalSurfaces=(Type=SurfaceType2,Name="Solid")
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,bUseMBPOuterBounds=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPOuterBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
MinDeltaVelocityForHitEvents=0.000000
ChaosSettings=(DefaultThreadingModel=TaskGraph,DedicatedThreadTickMode=VariableCappedWithTarget,DedicatedThreadBufferMode=Double)
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
bInitServerOnClient=true
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
Sorry for long message, but I have no idea where I might have messed this up
That's because listen server is a server with a client, not a dedicated server. You want != nm_client (or just else {})
Is that the only place ammo is changed?
that and a function that decreases it
Well check that function too.
// decrease Ammo
void AWeapon::SpendRound()
{
if (GetWorld()->GetNetMode() != NM_Client)
{
UE_LOG(LogTemp, Warning, TEXT("Spend Ammo Print on Server!"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Spend Ammo Print on Client!"));
}
if (GetWorld()->GetNetMode() != NM_Client)
{
UE_LOG(LogTemp, Warning, TEXT(" Spend Ammo Should run on Server!"));
Ammo = FMath::Clamp(Ammo - 1, 0, MagCapacity);
SetHUDAmmo();
}
}
// increase Ammo
void AWeapon::AddAmmo(int32 Amount)
{
if (GetWorld()->GetNetMode() != NM_Client)
{
UE_LOG(LogTemp, Warning, TEXT("Add Ammo Print on Server!"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Add Ammo Print on Client!"));
}
if (GetWorld()->GetNetMode() != NM_Client)
{
UE_LOG(LogTemp, Warning, TEXT(" Add Ammo Should run on Server!"));
Ammo = FMath::Clamp(Ammo - Amount, 0 , MagCapacity);
SetHUDAmmo();
}
}
``` Result: LogTemp: Warning: Add Ammo Print on Server!
LogTemp: Warning: Add Ammo Should run on Server!
wtf does this mean
UATHelper: Packaging (Windows (64-bit)): LogAssetRegistry: Error: Package ../../../../../../Users/Holografic/Documents/Unreal Projects/FiveNightsAtIvans/Content/InfinityBladeWarriors/Character/CompleteCharacters/Textures_Materials/CharM_Robo/M_Char_Robo1.uasset is too old
on build
The error message "Package is too old" typically occurs when you are trying to package or build your project with outdated or incompatible asset files. It indicates that one or more assets in your project are using an older file format that is not compatible with the current version of the Unreal Engine.
To resolve this issue, you can try the following steps:
Update Unreal Engine: Ensure that you are using the latest version of Unreal Engine. Update your engine version to match the version used when creating the project or the version compatible with the asset files.
Reimport Assets: Open your project in the Unreal Editor and locate the problematic asset(s) mentioned in the error message. Right-click on each asset and choose "Reimport" to force the engine to update and convert the asset files to the current format.
Verify Asset Compatibility: If the asset(s) causing the error are from a marketplace or external source, ensure that they are compatible with your current version of Unreal Engine. Check the documentation or contact the asset's creator for any specific compatibility information.
Clear Intermediate and Saved Folders: Sometimes, outdated intermediate or saved files can cause issues. Try deleting the contents of the "Intermediate" and "Saved" folders in your project's directory. These folders will be regenerated when you reopen the project.
Clean and Rebuild: Use the "Clean" and "Build" options in the Unreal Editor to perform a clean build of your project. This process helps ensure that all assets are properly recompiled and synchronized.
By following these steps, you should be able to resolve the "Package is too old" error and successfully package your project.
``` i asked ChatGPT :D
If anyone has any idea on how to fix it. please ping me
Hello dudes can someone help me? im trying to replicate my aim offset but it stutters whenever i replicate is for both ends. Can someone help pls?
how is this related to Multiplayer?
aim should be automatically replicated
use Character->GetBaseAimRotation().Yaw/Pitch
for the yaw and pitch
My project using steam sessions does not work in the editor, so I am trying to build it and see if it works like that, because that is what people making the tutorials do
I do not really see the issue
i am not familar with advanced sessions
but i do know steam dev id 480 is super bugged with session finding
and you should use SteamSockets
not SteamNetDriver
bEnabled=true
SteamDevAppId=480
bAllowP2PPacketRelay=true
P2PConnectionTimeout=90
P2PCleanupTimeout=1.5
[/Script/SteamSockets.SteamSocketsNetDriver]
NetConnectionClassName=/Script/SteamSockets.SteamSocketsNetConnection
ConnectionTimeout=80.0
bNeverApplyNetworkEmulationSettings=true
InitialConnectTimeout=120.0
NetServerMaxTickRate=60
bClampListenServerTickRate=true
MaxNetTickRate=60
KeepAliveTime=0.2
MaxClientRate=120000
MaxInternetClientRate=120000
RelevantTimeout=5.0
SpawnPrioritySeconds=2.0
ServerTravelPause=4.0
[/Script/Engine.Player]
ConfiguredInternetSpeed=60000
ConfiguredLanSpeed=60000
[OnlineSubsystem]
DefaultPlatformService=Steam
[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/SteamSockets.SteamSocketsNetDriver",DriverClassNameFallback="/Script/SteamSockets.SteamNetSocketsNetDriver")
@pure elm
and you cant test 2 copies of the game on the same computer
so if your hosting, you would need to load your game on another pc to find sessions
with another steam account
Can i show you on discord stream or explain in private
Ive been watching this right here https://www.youtube.com/watch?v=K1Pm6MPSXoI
Join my discord server to get help from me or other members
https://discord.gg/GwXkaE4
TRIMERA social accounts
- Patreon: https://www.patreon.com/trimeraint
- Instagram: https://www.instagram.com/trimera.dev/
- Twitch: https://www.twitch.tv/trimeradev
- Facebook: https://www.facebook.com/trimerainteractive
- Twitter: https://twitter.com...
you don't need to do any of that
i am in lounge if u have a minute
make sure your using control rotation also
what you mean jitters
check your dm
@soft flare
<@&213101288538374145>
Is it enough to write the level name in the URL of Seamless Travel? (Lobby to Next map). Btw I think Seamless Travel is healthier than other methods, do you agree with me on this?
Okay, thank you for this, it all makes sense to me. What doesn’t make sense to me is why the client is running the code when it’s the host’s Inventory variable that’s changing and therefore should be the host calling the OnRep, not the client. If it’s the host calling the OnRep, I would expect the host to be able to get their own player controller and run the code the way the client is able to when it’s the client’s playerstate running the OnRep
Onrep runs EVERYWHERE
Everyone that has that variable runs that onrep
I thought it only ran for the people who receive a change to their version of that variable
Furthermore, if it runs everywhere, why is it not being successfully run by the host and updating his UI 🤦♂️
this shit is so confusing lol
No?
oh ok , so im play a day/night cycle on the level Bp but its not being replicated i suppose
is that why ?
cuz on levle bp
Actually I don't know for sure. I've always assumed it runs on server and client.
This is a good reason not to use the level bp!
hm true
if I set the hold gun to null ptr on server, why the weapon is still sttached to the character?
because you only changed the weapon variable you didnt detach it
I spawned the copy of the weapon in the level needs to be dropped
I set the attached weapon to nullptr and destroy the actor
it still need to detach?
i hope you destroyed the actor first and then set it to nullptr
yes,
CurrentWeapon = NULL;
CurrentWeapon->Destroy();
wrong way mate
if you set CurrentWeapon to Null and then try destroy it, theres nothing to destroy
you cant destroy "nothing"
you basically deleted the Reference to your weapon and then try destroy it but you dont know your weapon anymore
Tell that to Albert Einstein. He invented space!
if this is nothing, I can still see it is connected to plyer
You want CurrentWEapon->Destroy(); CurrentWeapon = nullptr;
yeah you only deleted the Value
not the actor
I can now try it
ah, all right
Imagine you got your Friendslist on your phone and set your Moms Name to Null, its still there though just you dont know who that is
bad example but cant make a better one rn
myMom is not in my friendlist
she is in my family list
ok
you got Moms name in your friendlist?
It'd be better to say that if you removed her number from your phone, she still has a phone. It hasn't been destroyed! 😂
or like that
btw i changed the Ammo Stuff to Client RPCs but that shit still only gets the right Value on Server, i feel bullied :D
I still think you're overriding it on the client somehow.
Do you have any replication condition set on your inventory variable by chance (it's near the same field that you set the variable as Replicated/RepNotify)? Normally any variable you change that is marked with OnRep will trigger the OnRep on all who have a copy of that actor.
When I say overriding, I mean you're changing the value on the client so it doesn't match the server.
this solved my issue: CurrentWeapon->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
If you destroy the weapon, you don't need to detach it!
its mean destroy is not working for some reason
void UCombatComponent::FinishReloading()
{
if (Character == nullptr) return;
bLocallyReloading = false;
if(HasAuthority())
{
bCanFire = true;
CombatState = ECombatState::ECS_Unoccupied;
Character->EnableMovement();
UpdateAmmoValues();
EquippedWeapon->SetHUDAmmo();
}
}
void UCombatComponent::UpdateAmmoValues()
{
if (Character == nullptr || EquippedWeapon == nullptr) return;
EquippedWeapon->AddAmmo(1);
}
void AWeapon::AddAmmo(int32 Amount)
{
Ammo = FMath::Clamp(Ammo + Amount, 0, MagCapacity);
SetHUDAmmo();
ClientAddAmmo(Amount);
//MulticastAddAmmo(Amount);
}
// UFUNCTION(Client, Reliable)
void AWeapon::ClientAddAmmo_Implementation(int32 AmmoToAdd)
{
if (HasAuthority()) return;
Ammo = FMath::Clamp(Ammo + AmmoToAdd, 0, MagCapacity);
UE_LOG(LogTemp, Warning, TEXT("Add Ammo Client Amount: %d"), Ammo);
SetHUDAmmo();
}
``` here you got the called functions in their order
What i just thought about: FinishReloading gets called by a AnimNotify, could that be the Problem why its not setting Ammo correctly?
And that's every place the the Ammo variable is touched by any class?
Why are you adding ammo via an rpc instead of relying on replication?
I followed a Udemy Tutorial
You should probably "predict" that that's going to happen (I assume there is a reload animation?)
well the first time i had set up replication but that didnt work either
And just let the client assume the reload worked and still fire. If it didn't work, the server won't let them shoot anyway.
yeah and at the end i call AnimNotify->FinishReloading
Put a log into AddAmmo. Make sure you output the value of Amount as well. In the other method too.
Just outputting the final result doesn't account for erroneous input.
UE_LOG(LogTemp, Warning, TEXT("Add Ammo Client Amount: %d"), Ammo); this prints "1" for me but afterwards its back to 0
Do you have an onrep? Add logs in that too.
Plus I don't see anywhere you actualyl change the ammo when firing your gun.
well i before firing i should have ammo
Maybe you're somehow firing again ?
How do you know what your code is doing?
More logs. Log everything and everywhere.
i have a check that if i press fire, it checks for ammo and if i dont have any it does nothing
Include an "Is server?" option (GetWorld()->GetNetMode() == NM_Client ? 0 : 1) part.
Everywhere any part of it is changed by anything for any reason.
Not just "this is where it should be changed".
well it tells me it gets set on NM_Client
The issue lies here. The "add" to the inventory doesn't trigger the OnRep on the server.
which one do I pick
None.
Set to what? When? By What?
You need to change the logic a bit in your set up. Promote your "inventory" to a local variable. Add the new 2DWordArray value to the local variable. Set the Inventory to the local variable.
Something like this.
Alternatively, you could've called the event dispatcher on the particular playerstate after this bit (as well as in the OnRep)
I could just call the custom event with the playerstate reference here, yeah?
I can just call the custom event in the playerstate here, no?
and then for stealing I can do the same for the stolen players inventory earlier on in the logic when stealing happens
that works for the host but not remote clients
:/
You must use the OnRep too if you're not.
So call it from the gamestate and do onrep which calls the same function?
No...
Your Inventory OnRep in your playerstate... You need to use that.
The problem with having your UI being forced updated by the playerstate is that you'd have to constantly keep updating what is updating in the playerstate which doesn't make a lot of sense.
If you use event dispatchers, then the UI that is being displayed can hook into when the change happens so it can update it when it needs to.
So having the event dispatcher be bound to an event on the UI?
The UI binds to the event dispatcher that you call in the playerstate.
The bind would execute a function/event in the UI and the UI can then do what it needs to do based on when that event dispatcher is called.
so have this in the UI
and then call it here?
LOL
so OnRep is mostly for having the clients act on changes to replicated variables
for the host, you call it from the server?
It's supposed to handle server stuff too (in blueprint) but "Add" in the inventory is one of those quirky things where it's not really setting the variable so it doesn't processes it as an OnRep.
It goes under the radar with Dedicated Servers as usually you don't need to care much about OnReps on server in that case. With listen servers you do since they may need to do similar things as clients.
Right, that makes sense
In C++, OnReps aren't called on servers at all, so you have to manually call it if you need it 😛
ahh yeah
C++ game dev not super in my repertoire, maybe some day
but anyway for the umpteenth time, thank you for your patience and knowledge
Glad I could help and that we got it figured out 😄
me too! everything is not quit bugless yet but the UI is now updating so I can use that to help me figure out what game logic is messed up lol
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_MainGameState_C_0. Function AddCrystal will not be processed.
I'm calling the function add crystal in main game state from an actor blueprint when it overlaps to add one to a variable in gamestate, it appears to be doing everything correctly but i keep getting this warning
nevermind i see what i've done, the function is being called from a multicast
The actual reason is because you call a server RPC in the GameState
Servers RPCs require the calling client to own the actor which isn't true for the GameState
Hi guys, how I could show/hide a widget inside an actor in multiplayer listen server model only for the player that entered a zone inside that actor.
I tried several things but cant get it working.
For instance: As the host player when I enter the zone it shows for all player (which i dont want)
In the OnOverlap, you get the other actor, cast it to pawn, check if it's locally controlled, and then show the widget if yes. You make the same check on EndOverlap to hide the widget.
@kindred widget Well I did already and yes it works. But I found one case where it does not work.
My actor have the ability to be "upgraded" which is basically asking the server to destroy the current actor then spawn a new upgraded one, and then since this upgraded actor is an instance of the old actor BP class, the logic for handling the overlap and hide/show the widget is the same.
Now when I upgrade this actor as a Client, the player is still in the zone, so the overlap logic triggers, and there the visibility for some reason is showing for the host as well which should not
You're using an IsLocallyControlled check?
@kindred widget Here is my BP, the 'Update Interactio Widget' is basically setting the visibility to true + formatting text.
Is there any cost difference in bandwidth/processor for having a delegate fired that remote clients would bind to - instead of an interation of GameState::PlayerArray & RPCing a client-side funct?
well that sums that up! got it
how to refresh character bones where the weapon was attached?
the problem is the skeletal mesh remains in the character hands after destroying the weapon actor
the actor is 100% destroyed, it has no issue
Im using a lot of FMath::RandRange to calculate who kills and who dies during combat.
Like i have units that are stronger with higher probability of killing enemies.
A friend of mine told me this will be a mess when making it multiplayer.
Because then one machine will have a different random value than the other
Is this true?
If you're using replicated variables to represent the values and are setting them on the server then it doesn't really matter.
If you're doing calculations on clients, then you're probably going to have a bad time anyway.
Why 'armor' doesn't work? What's wrong?
What doesn't work about it?
It doesn't take damage for the armor. But if i change in 'take dmg hp' the 'cur hp' and 'max hp' to the armor ones that are in the secs pics then it works
Only the first event works
If I replace them in the "TakeDamage" event then it works, TakeDamageArmor doesn't
Are you sure that you're even calling the event? Like did you try putting print strings in and see if there's values coming out or that it indeed is executing?
How?
If i set it like this, with cur hp and max hp, then it works
the same event
How do you know the Armor values don't work? What are you doing to check that they are not working?
Thanks. Yeah but these are calculation that happen quite often. So they need to be sent to the clients.
I dont have yet much experience in multiplayer. But from what i can tell from other projects. Sending a lot of stuff over is not good.
One my friends told me that i can use randomizations for combat. But they need to be deterministic so that they happen the same way in every machine. That way i dont have to send the randomizations everytime
If you're having the client run the calculations then yes, you would need to have something deterministic. If the server is doing the calculation, then there shouldn't be a problem as then you're just sending the calculated number.
I have a hud bar
And you're calling the "On HP Updated" event dispatcher in your OnReps of Armor and MaxArmor?
but like if im having 100.000 units fighting and im randomizing the kills between squads, then thats an issue because it needs to send these randomizations. i think i will go the deterministic rout maybe. so all machines do the same thing and dont need to receive data from the server
Yes
You shouldn't need to if your calculations are run on the server. The server executes whatever logic it has, and dictates what dies and how much damage is done etc. That then gets sent to the clients.
Is it just that the values are not being received or the event dispatcher bind in your HUD isn't firing?
It doesn't even change the value in the database
Do you mean this?
What is in those functions?
ok got it thanks
Ok and what are your default values for Armor Class and Max Armor Class (or are you setting them anywhere else before they're being used?)
Do you populate any values into Armor Class and Max Armor Class anywhere, including in the variable defaults?
What I'm getting at, is if they're both at 0 to begin with when you're triggering the TakeDamageArmor event, you're clamping the value to be 0, so that means your ArmorClass remains at 0 which means there would be no change so no dispatch is fired as the OnRep wouldn't trigger.
But why if i use the other event and i replace cur hp with armor it does work with armor too?
Your events are functionally the same, just the variable being changed is different. There should be nothing different about how they funciton except for initial values.
If I take the first event, and i replace 'cur hp' to armor class and max hp to max armor class, it works for armor
:///
but i need both hp and armor
Then that again leads me to believe that you're not appropriately calling TakeDamageArmor - put some print strings into it, see if you get them to print something.
At the other side, if I take takedamagearmor event and i replace armor to hp, it does work with hp xDD
Do you have any replication settings on the variables themselves? Should be in the same spot where you define the replication type for the variables themselves.
Can you show how you are calling TakeDamage and TakeDamageArmor?
You're probably overriding the timer handles.
How can I avoid it?
These two events are in the same actor/component, yea?
Yes
So when you're setting the timer handles and calling to clear them, you're using the same handle variable for both damage and armordamage. They would need their own variables in order to be handled separately
A little more clearly here... Both events are clearing The "Regen Tick Timer".
So either they both should be executing on the same timer, or if you want to use separate timers, then you need to create and use new timer handle variables for the damagearmor timers.
I just want that the armor decrease with time. What is the best way to do it?
A timer is a good way to do that.
I did create new variables Timer Handle for the armor, but it still doesn't work
How about trying to call it separately and see what happens - forget all this timer stuff. What happens when you just call it?
Hello everyone. I have manager objects (derived from AInfo). I want these manager objects to be spawned by my custom GameMode and for them to be replicated to the clients. What's the proper setup in order to achieve this? I tried copying what the folks at Epic did with the GameState, but it seems my manager objects are missing on the clients. In other words, what is the proper way to create an Actor on the server and replicate it on the clients?
well it should be replicated by default if your managers are replicateing,
but maybe untick netload on client, if it is something you already setup in the level before hand
that bool spawns the managers both sides
you want it only on to be server side
Hello, thanks for answering. My question is a bit vague. I will summarize what I need to achieve.
You simply need to set the replicates bool to true in your actor constructor, I believe.
And potentially bAlwaysRelevant.
anyone else just setting bAlwaysRelevant on literally everything? 😄
God no
If it's true for you, go for it.
i am guilty
though ive yet to see a problem surface
just going to ignore the yellowstone-tier technical debt explosion waiting to happen for now 😄
when we need to use DestroyNetworkActorHandled();
Unless you have an actual reason, probably never
I have this issue, The item weapon is generated and attached to the character in the first image, and destroyed in the destroyed on server and spawned in level.
Logically when destroyed, its mean deleted from Character, but the ghost instance is still remain attach to the character
Attachment is done on server->multicast and drop/destroyed is done on server only
I have only one option to setvisibility(false); but this make no sense, if the actor is destroyed , it should go away
You'd need to show the code. Also Attachment of Actors doesn't need a Multicast. Attachment by default is replicated.
Just has to e done on the server
Okay, so, I've stumbled on a century old issue
I need to replicate my weapon inventory to the client on BeginPlay, but, because weapons are still not created on clients, it just ends up replicating a bunch of nullptrs
What do I do?
Any code? Because if you use an OnRep you should get a call when the nullptr actually becomes valid.
No, I use RPCs to tell the client which weapon was added to the inventory
Using OnRep_ would mean I have to check what weapon was added/removed, which I consider a lot of overhead
I mean, I could use both RPCs and OnRep_s, but that's just a bandwidth waste
I have question I know game instance is persistent and if I am in offline part of my game means menu lobby login, and then from lobby I am joining dedicated game server with its own map my game instance still persist, but I wanna use player state and I know player state being deleted after joining dedicated server, so I got idea when I join dedicated server does PlayerState run again begin play or not ? or it will just get erased
I wanna use Begin play of player state but I am not sure if it will be called again after joining server
Yes, if it's your first time joiningactually, it's called always on join
so things after begin play after joining in player state should load
as name , team etc
right?
ItemWeapon.cpp
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh"));
WeaponMesh->SetupAttachment(NewScene);
MyCharacter.cpp "" Event generate and attach weapon to character pressing 1
MyCharacter::GenerateAttachWeapon()
{
AItemWeapon* NewWeaponItem = GetWorld()->SpawnActor<AItemWeapon>(ItemWeaponClass, Transform, SpawnParams);
if (MyPlayerStateRef && NewWeaponItem)
{
WeaponItem->WeaponMesh->SetSkeletalMesh(WeaponDatas.SkeletalMesh);
NewWeaponItem->FinishSpawning(Transform);
}
WeaponItem->SetActorTransform(PlayerMesh->GetSocketTransform(WeaponSocket, ERelativeTransformSpace::RTS_World), false, false);
WeaponItem->AttachToComponent(PlayerMesh, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepRelative, true), WeaponSocket);
}
MyCharacter.cpp "" Event Destroy the attached actor from character pressing 2
MyCharacter::DestroyWeaponActor()
{
WeaponItem->WeaponMesh->SetSkeletalMesh(nullptr);
WeaponItem->Destroy(true, true);
}
okay I will try it only way how to try it is package client and server and run them ah shame I cant properly test it in editor
@steady cape The OnRep would solve your issue though :p
It's meant for this kind of problem
Anything about who calls this code ? You have no HasAuthority checks in those functions.
Both spawning and destroying should only happen on the Server if the actor is replicated
Well, considering the most of it's capacity is 2 weapons, I guess looping over entirety of it to figure out what is added and what is removed isn't going to be much of a burden on CPU
To be fair, that's what FastArraySerialization is for
There you get a callback per item
Does it keep the order of the items?
server is doing both calls
Because it's crutial
Alright, I'll try to use all this info tomorrow
It's a wrapper for a TArray
But it allows for delta serialization
C++ only of course
(the implementation of it)
And you are sure client is not?
It does trigger OnRep_ correctly, doesn't it?
yeah, I have hasauthority check
What exactly?
Just, in general
I would suggest adding some logging and checking what is being called
Afraid it'd trigger in chunks
This is def a code issue on your end
You mean the FastArray stuff?
Ye
It has callbacks on the FastArray Items
Per Item
Which you can then route back to your owning object
The FastArraySerialization Header has a lot of info in it
with example implementations
I figured. I'll give it a read
KeyPressEvent()
{
if(!HasAuthority())
{
ServerKeyPress();
}
if(HasAuthority())
{
//do something
}
}
Put logging in
And check what calls when
already did, when I call to destroy again, it says the weapon is not valid to be destroyed... it was deleted on first destroy attempt
by logging everything is working fine
So you get only 2 calls?
One for Create, one for Destroy?
Cause that's all you should get
yes One for Create, one for Destroy by different keys
guys what is loaded earlier player controller or player state?
1 and 2
Theoretically PlayerController
if I have in begin play of player state setting of TEAM AND NAME can I already in begin play of his controller load it ?
or it will be not successful
Not sure the order of BeginPlay is fixed
as you can see in here, the actor is destroyed and deleted from the this list
or I Will just call that function from player state and done
but still the mesh ghost is attached to the character
when I generate actor, it attached correctly to the character
weird on client it was first state on server controller
but theoreticaly its fine for me as my server is dedicated
I just need clients to work
Replication can mix things up
And the order of BeginPlay is probably not guaranteed in any way
okay
then rather will use game instance
bcs I have spawn logic in player controller
so I need know his team there
wanted use player state here
but okay
😄
@nocturne quail So if I get you right, the Actor is destroyed on server and client, but the SkeletalMesh is still visible (on everyone?)?
yes
Are you doing anything special with that MeshComp? can you show the whole Constructor, without editing things out?
just quick question I see you have good talk here, is fine to spawn actor via controller?
😄
I am using own spawn points etc
Sure. Only requirement is the server spawns it really. (At least for the most part)
yea it works fine
just asking if I should refactor or not
sure, I can post it, but I am not doing anything special with it
only thing I dont like I am using game instance 😦 I wanna use player state but I have no idea if it will be loaded before this
On the Server it is valid when you need to spawn
If you are coming from a Lobby, so you are already connected, then you can also put the stuff on the PlayerController
The GameMode should have a function that allows you to move the data between previous and new PlayerController.
it is case only if lobby and game are already on server but our lobby is handled via websockets and from lobby I am joining server
😄 so
its bit complicated
I just dont want have 3 same variables in 200 files
max game state and instance for team and nick
Hm okay
this is how I am trying to store name and team in game state
as my server is dedicated I except i dont need authority node
I hope it will be stored for everyone so everyone can check team and nick based on player state
You write GameState
#include "Items/ItemWeapon.h"
#include "Components/SkeletalMeshComponent.h"
#include "Engine/SkeletalMeshSocket.h"
AItemWeapon::AItemWeapon() {
SkeletalMesh = CreateDefaultSubobject<USkeletalMeshComponent>("SkeletalMesh");
SkeletalMesh->SetupAttachment(Scene);
ItemWeaponTablePath = TEXT("/Game/Datas/DT_ItemWeapon");
ItemWeaponTableObject = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *ItemWeaponTablePath));
}
void AItemWeapon::OnConstruction(const FTransform& Transform) {
FSTR_ItemWeapon* ItemWeaponRow = nullptr;
ItemWeaponRow = ItemWeaponTableObject->FindRow<FSTR_ItemWeapon>(ID, TEXT(""));
if (ItemWeaponRow) {
Datas = ItemWeaponRow;
Datas1.Name = Datas->Name;
Datas1.Thumbnail = Datas->Thumbnail;
Datas1.UseAmmoID = Datas->UseAmmoID;
Init(EItemType::EIT_Weapon,ItemWeaponRow->Name);
SkeletalMesh->SetSkeletalMesh(ItemWeaponRow->SkeletalMesh);
}
But this code is in the PlayerState
Do you have the same issue if you move the OnConsturction code to BeginPlay?
didn't tried
Cause I can't say that I ever used OnConstruction in C++, outside of maybe trying to mimic ConstructionScript stuff
Just sanity check would probably be good
I can move the code to BeginPlay now to check if it solve it
nope, where
this is how I am trying to store name and team in game state
Ah okay
is this way of storing fine? or I cant read this as client ?
Yeah the issue is also that you call the RPC on everyone anyway
So every other player will drop this
Does the RPC not work at all?
u talk to missty?
No, to you
it is working fine I am just asking if it is good approach 😄
Its stored but it seems I cant read values as client just server
its on begin play because everyone who join need to load name and team
Despite the fact that you call the RPC without checking if it's local
Sure
I should after or before authority?
nothing changed, the same behavior exists
You can do "HasAuthority" and on the "Remote" pin check "GetOwner IsValid"
Cause the other clients don't have a valid PlayerController of that player
Thing is, the Actor should properly destroy its components when it's destroyed
There is no reason for it keep "ghost meshes" around
Unless you are somewhere doing something funky
so like this
Yeah
totally agree and this is logical, I saw on TomLooman site, he destroyed the actor and then sets the ghost components to invisible...
I think this is a bug in the engine
but when I wanted to print team on client I had to add dealy otherwise
it was empty heh
I have never encountered that tbh
😄 idk if these delays are good to use
Buddy
I need execute some events after TEST function F
tell me why
And you set a Replicated Variable
can I know where these ghost insances exists in the memory?
And then you wonder why the variable is still not set and you need a delay
Have you ever heard the word "ping"?
yea I DID :DDDD
If you need it to be valid locally instantly, then set it locally too
SHould I use is valid?
Team can't be instantyl valid if all you do is ServerRPC and set it on the Server
Cause the client would need to wait on the replication
yea but I dont want make it accessible by anyone from outside
Yeah but then it's normal that it takes time
And you can't use a delay for this
If you need a function to call from that Team replicated, make Team OnRep/Repnotify
Hm, if you have a pointer to it, sure
What happens if you remove the whole SkeletalMeshComponent?
Like, completely, for testing
Cause, like, it should not remain in anyway
The only times that could happen is if attachment would be wrong or buggy, or if someone spawned the Actor locally too
Or stuff like that
I can test it now to remove the SkeletalMeshComponent in runtime
so just like this and it is fine its on server and locally too, right?
If you still call the RPC, yes
is there anyway to get free game server hosting in ue5?
Well no, I only see the Red event. not the Blue one where you call it
sorry its behind last print
Last question when I do respawn of player so he dies and I take his controller etc and respawn him, does his player state execute begin play again or not?
or I should call it somehow so it will set his name, team again?
I know steam servers are sort of an option , iunno if Unreal/Epic has a similar thing
No
Dedicated Servers hosting is paid
Everywhere
Unless shady
If you can't pay for whatever reason, make a ListenServer game or let user host the Servers
Stick it to the man. Make your own server. Just get a computer and open it up to the world wide web. Now you're off to the races!
If you need Servers to be hosted due to whatever competitive online play, think about a different game or pay
with steam from what ive heard you just pay 100usd to use their servers ? but thats also if you really want your game on steam.
You pay $100 to get an app token. You can use that app token to upload a game, a piece of software, etc...
That is right and wrong.
You can use their Servers in terms of the data they provide
Session Info, User Data.
Achievments and crap like that
Game Server hosting is not part of it
The actual physical or cloud Server that a Dedicated Server runs on is not provided by Steam
neither be Epic/EOS
Or anyone else for free :D
thats interesting , i havent heard anything about needing to find a new server provider when watching/reading tutorials on steam networking , they just say you need to make a new app number and not use the dev one , and networking will work as it does on the dev id , just specifically for your game.
guys pls 😄 how I can cast to my player which is owner of this playerstate my cast is failing
its connected to Remote
I should get another object?
If you're already in the player state, get the controller, then get the pawn.
To be fair
The Pawn could just be invalid
If this is right after starting/spawning
Replication says hi
its after I set name and team in state then I wanna call function dirrectly inside my pawn
and set its ui
calling this
oh i think i confused what you meant in the context for game server hosting. I follow now , indepth information on networking is really hard to come by
if you meant it like this , its failing too 😄
Then the pawn is invalid, like Cedric said.
@real ridge The stuff you are trying to do requires a lot of OnRep stuff
And a lot of that is C++ only
i will simplify it
If you can't use OnRep, then you have to do it from both ways
🤨
Sure, this whole init stuff is a pain in UE
OnRep helps here but Epic doesn't expose the native ones
I know, I see 😦
And the only other way is to kinda ask from both sides
So Character tries to get it from PlayerState and other way round, idk
Still not ideal
i just wanted to get rid of game instance because I was scared people can easily "hack" it
They can 100%
If you don't want hacking you can't do it like that at all
Then you need to ensure only the server has that info
Does anyone here know any resource anywhere that would be good for networking a racing game, where vehicles are moving on average 5k-9k forward velocity ? its a major block ive been kind of avoiding , ive been using Smooth sync for my project so far but the results are either very inacuracy , tho i know positions will always be inaccurate to a degree in a racing game and most of it is smoke and mirrors ,
but exactly how to set something like that up goes way beyond my comprehension. id likely Commission someone to either teach me or set it up for me when i take the time to focus on it
Racing games I would just make the car client auth
F1 for example is also Client Auth
Just too much trouble otherwise
yea I know but then It must goes only via player state and then I am again at 0%
ahhhh
right thats what im doing , but the position that other players see has the issues mentioned
i havent really figured out what i need to do , i think in general from what ive researched you need client side prediction? but i have no real clue , like Hotwheels unleashed and KartRider:Drift were both made in unreal and have decently synced up vehicles so i know its possible to do , but iunno if its outside of the realm of possiblity for a solo dev
Guys when I am setting something and I can see it fine but every new joined player cant see it because it was already loaded before he joined?
How I can load it also for him?
its in RPC
I found the weapon actor is not replicated properly
everything works fine if I test the same logic in my other project with standalone mode
Does APlayerController's OnPossess not get called on the client?
No. Should tell you that on the comment for it.
In C++, they have a function (I think it's called like AcknowledgePossession) that does get called on the client though.
I didnt check the source yet when i asked that question. immediatly after posting i realized i probably should have, but then got distracted 😅
thanks though, ill look for it!
altough one more question, once the client Acknowledges possession, can i guarantee that Gamestate is valid on client, or do i need to account for it possibly not having replicated yet?
I wouldn't trust it personally. Only time I know GS is valid is when BeginPlay is called, as it needs to be present in order to even start calling BeginPlay on all actors.
Where is unreal/epic thing+
?
Ive only heard of UE having a listen server option thing similar to Steams. but i havent looked into myself , youll have to do some researching broski
UE supports Listen Server setup out of the box.
I can't picture any situation where this would make sense
You're basically rate limiting mouse movement
Nobody will l ike that.
What do you do if some XxXNoScope gamer has his dpi turned up to 9000 and flicks his wrist, just not rotate very much?
hmm intredasting
1st or 3rd person?
I'd have Input -> camera always be a direct mapping
never ever breaking that
but you can of course have limits on camera -> character mapping
You'd probably have to incorporate some rotation data into the CMC to have it play perfectly nice, not sure how hard that'd be to do
basically have orientation be part of a move
That's where I'd go with it anyway if it was me
oh idk
I've never dove into the guts of CMC before
if it is then you can presumably make it predicted + corrected
I'd also ask the GMC guys if they can do it
It's expensive but if it can deliver, it's probably worth it
https://www.unrealengine.com/marketplace/en-US/product/general-movement-component
arbitrary collision shapes I suppose
other improvements
I am so happy, finally replicates that actor correctly
it was a pain , +133 variables were needed to be replicated
thank You for help
now it is working fine to destroy and regenerate
Is there a PDF version of the new network compendium (to make it read offline)? Or just the website now?
you can download the website as PDF
guys why when I am setting name via repnotify its not nevwly joined dont see my name?
also how I can cast to my playerpawn from player state this is not working
For now, just the website. Whenever I find the time in the future, I will update the css for printing so one can "print" a PDF. You can already do that but it might look bad.
It doesn't work, cause there is probably no PlayerPawn at that point.
All good. I’m jumping on a plane (to the Unreal fest), so wanted some light reading. I’ve saved each page offline I think, see how it goes..
okay, is there any problem why repnotify should not update for newcomers? in game ?
I call it on begin play and setting it like this
The first page I downloaded as pdf, we can still download as pdf, we just need to give it some time... Thank You for all this work )
If you are setting it on the Server, similar to how you do it in the PlayerState, then it should be fine
But you might not be able to do that in BeginPlay, as the Pawn isn't possessed at that point
Yeah I'm aware
so repnotify should be on server call?
custom event called on server
yea but if not at begin play then where 😦
OnControllerChanged for example
Limited to IsLocallyControlled
Cause it calls for server and client
you meant like this?
Yeah I mean
That's basics of networking right?
Replicated variables have to be set on the Server
Pretty sure you should know this by now :D
yea but I was confused when I used this approach because I Had to also set variables immediately localy because then it was not updated till first change of name
and I had empty nametag
Yeah, cause that's what Ping is about. If you tell the Server to set something it will take the full round trip time
If you need it instantly on the local client then you have to also set it locally
but now Its not about ping I dont see name of each other until I press keyboard to set it, might be because name and team is not loaded on that call on begin play
idk
Well I also said that you can't RPC on BeginPlay cause the pawn is not possessed most likely
yea I am watching it and it seems like first one who was spawned has not set name for second one
but as its repnotify it should
Just moev the call to OnControllerChanged
I moved , but its still same first joined has like not working repnotify
strange
but as soon I kill player and he respawns I see correct names and healthbars
wtf I tried to just on every login reload names of all and its same wtf
changing bools should be enough playing on serverside right ?
dont have to multicast those :/?
what is state sync
is it sending inputs and correcting every now and then with state
or is it sending both at the same time
Hey, i am facing the following problem. Anim Montage seem to play with a much faster play rate on clients than on the listen server, even though they are 100% played both with a playrate of 1.0
Hi, is it possible to re-use the currently loaded map when joining server?
The client discards the map, then travels to server map, which is likely the same one. That takes a while, and seems unnessecary.
It's generally more effort to cleanup than it is to re-travel to the same map tbh.
understandable. but i'm running into connection timeouts, because the lobby map is pretty big
Have you considered cutting your lobby map into streaming levels, so the client only has to load a small persistent level first?
Not yet. Is that how it goes? Client sends life signals between streaming levels?
Streaming Levels are generally used to solve performance and load time issues
Not sure what you mean with life signals
The persitent level would need everything crucial
And other stuff that just takes time to load goes into sub levels that you can load post travel
It's that the client just time-outs after 120 seconds. When loading the mainmenu/lobby map locally, it's there in a fraction of the time
All concerns about map size and streaming levels aside, I'm confused about why there isn't a second thread on the client, giving a 'yep, still here, but still loading' every now and then
If I were to set the capsule component of my character blueprint as ComponentReplicates and change the collision response channel on the server, the change isn't replicated to the clients. That means collision preset isn't a replicated variable (if it's a variable), right?
And if so, is multicasting the collision response change only way to do this?
do variables in player controller ever need to be replicated?
If you would like the variable to be replicated to the owning client only, why not
I will never do it then
Thank You for help )
Well according to my possibly-wrong opinion, that could maybe be a way to indicate things to the client by using OnRep functions rather than RPCs, don't know if or what we would save though
Nothing wrong with having replicated vars in player controller
You are absolutely right, variables replicated on PC can't travel from client to client
yes in a packaged game
Yeah it can be considered as replication condition to owner only by default
Exactly
but while in development, the second client even don't have controller, can't even call a function from pc class on the second client, becasue the controller is always null
Put it in whatever place makes the most sense
If you need information about a player to be available to other players, it belongs in the player state
Controller relevancy doesn't change in packaged vs development
I mean if I play with two clients, want to test the pickup weapon logic on both clients, the second client will fail to access the logic located in the pc class
in editor mode
No reason it should. Two players means two controllers.
key action is binded in the character class
an event in character class is calling an event from controller class
the ref will always fail on second client
Are you trying to get the controller of the other client through the simulated proxy of the character maybe?
what I did is on character tick
if (this->GetController() == nullptr)
{
MyPlayerControllerRef = Cast<AARMAPlayerControllerBase>(GetController());
UE_LOG(LogTemp, Warning, TEXT("GetController - Nullptr "));
return;
}
this print always fail on the client-2
nope, I will build dedicated
No I mean in the editor
Hmm, then I would expect you to get nullptr from the first client as well
Clients will only have their own PlayerController in their process/machine, unless it's a listen server
So if you have 2 clients and 1 server, each client should have 2 characters (one for themselves and one for the other player) but only a single PlayerController (only theirs). So it's normal that you're getting null from trying to getting player controller from all characters
What's not normal for me is you should get nullptr from client 1 as well
Because client 1 also have the character of client2, but not their player controller, so that should also say GetController - Nullptr
Okay wait, how do you know which client prints the log?
I am checking if the controller is null before calling the function with red color log
when I call from client one, it works and no red log
if called form client 2, it says controller is null
beside it the tick is also logging null controller in cyan color
Yeah but you said this was on character tick, which means all clients will print simultaneously
yes
How do you know from which client it does come from?
Can you open the log timestamps and send a section of the log like that?
I temporary disabled it from tick, and checked on call function
now the editor is closed, I move all the needed logics to character class
My guess is you're mixing the logs, otherwise I'm not sure what's going on or if my knowledge is enough to answer
I can check in the log file which is saved in the disc
hope I will find it
searched alot, but didn't find those lines, maybe the log file is was not saved or so
or maybe old
.h(67): Error: Unable to find 'class', 'delegate', 'enum', or 'struct' with name 'EOnJoinSessionCompleteResult::Type'
I keep getting this error even though I have included the library and the module for it, at least according to this page:
anyone got any clue ?
yes ty, it was the ufunction macro
When you run your game with Net Mode "Play As Client", it basically creates a hidden dedicated server process right?
absolutely
Thanks
why do I have one controller when running two clients?
for something like a flashlight, wouldn't it make sense to replicate it only to the non owning clients to save a little bandwidth
Because you're only looking at the world through that one client.
Hi guys, I have a bug. When the 'armor class' reach 0, it does 'die', but it keeps decrease. How can I fix it?
Once the player die, it should stays 0/200
how to look through 2 clients?
this created two instances of players with two new windows
You can't look through both at the same time. You can switch the world outliner to the server though. I forget how.
But it is some button in that area of the editor when playing the game.
hmm, I will now look for this button , will update if I found or !found
It should be under the gear icon there but looks like you're on ue4, I guess? Which should be around the bottom of the outliner tab iirc
Well, no.
Ignore what I said earlier about clamp, use max instead.
That will work with just a 0.
For clamp you also need to specify the upper bound and you haven't.
yes found it
yeah, Thanks
It's b etter now?
It does work
It's good?
However
You character will now die every 1s repeatedly.
Unless you have some way of stopping that in the die method.
Add in a bool or something that checks whether Die has already been called.
"IsDead"
if it's false, you can call die. If it's not true, you can't.
Make it the first thing you check in Die
So you can call Die from anywhere and it will never happen more than once.
I have 'isAlive'
Use that then!
but how?
why the second client is not doing LineTraceSingleByChannel ?
I found the reason, the array of spawned Items is null for second client
and the second client raycast is not detecting the valid items
I didn't understand the last 'Set is alive false'
how do you deal with simulated objects? im testing a ball that you can push around, on the client thats pushing around the ball, its very laggy with them jumping towards and away from the ball, while on any client watching it looks normal...
this is with average pings and no packet loss
Probably because the client pushing the ball around is updating the server and then the server is updating the client back and they are getting desynced because of the ping.
Physics is very hard over networks. You've seen that in other games, right? Where things flip out and shoot off into the sky, etc.
what is state sync
is it sending inputs and correcting every now and then with state or is it something else
Why is this on event tick o.O
hi, where should I put player skills/attributes? (Variables)
Player Controller or Character Pawn?
I don't know I just follow a youtube tutorial
Do they belong do teh player or the pawn ?
hey guys im currently develop a dodge ball game 1v1 (server vs client)
i want to spawn a ball on each near character (server and client).
i called this on BP_ThirdPersonCharacter at Event Begin Play.
the ball actor already replicates turn on.
but on the client side, the client didnt see his ball, only the server's character ball.
My house
actor ball
Hi, I am trying to add a multiple player controlled character in Lyra Sample Game. To better explain it imagine a three-headed Cerberus where each player controls a head and can use the respective different ability. Only one player can move the Cerberus. So far I have tried:
-
Creating a Master character with 3 child actor characters. On trying to possess assigning each player to a different child actor. The problem is, because as a client I do not directly possess the Master character, when I try to activate the ability as a client it fails, because it has the NetRole=ROLE_SimulatedProxy.
-
Principle the same as the solution above, but the players activate abilities on their own pawn, and the Abilities/montages play on the master character. Problem is when trying to move the Master character as a Client I found no way to do it.
-
Tried going around the engine’s Pawn<->Controller 1To1 relationship, adding multiple controllers possessing one pawn, but it looks like a bad solution.
-
Thought about using fully different characters without a master one, but I can’t think of a way to attach the meshes with blending them so they don’t look like separate parts
I want to keep GAS prediction, so I am trying to find a solution without sending input RPC’s to the server. I do not have any more ideas how to approach this , so maybe someone could give me ideas or any help on how to solve this?
So just answer the question I asked. There's a distinction between the player and the pawn they control.
Which one owns the skills?
I want the player not to lose these statistics, so the best place for it would be PlayerController, but I don't think it should even be stored there, but somewhere in GameMode, so that after loading the game, the server has all the information about the player.
the pawn will have skills
Not the PC, maybe the PS.
You can transfer PSs between levels.
Or you can mirror the information on the server's GI.
and where would YOU put information about what player has how much strength, dexterity, etc.?
@latent heart
It depends on who owns them. If they are properties of the player, on their PS.
You might have both - properties of the player which then inform properties about the pawn, so you can have different stats in both places.
In general, put variables on the things which actually own the data.
By this do you mean that assuming a roguelike game (say dead cells) the player would hold thinks like permanent upgrades, but the character would hold things like - their temporary (run specific) upgrades/weapons/etc?
Correct
The answer is not "here is the best", it's "it depends" and that's a very good example of that.
You might run into murky ground where they both have the same sort of stat, let's say your permanent upgrade is a stat like strength, but your character also has a strength value - it's fine to have that in both places.
Your character may just be "here's my base strength, now I'll add on my permanent bonus"
Hmm, yeah - that's interested too when you talk about things like resources/post mission rewards.
You might even have it stored on the character until the end of the mission - in which case it gets added to the player (since they win) or modifed somehow (50% is lost, or whateves) if they fail.
(If that's the type of game at least)
Yeah, exactly.
And you can see the same logic about per-server and global account information.
Question then, is the engine assumption that the Pawn is not perpetual storage?
You might have some bonuses that accumulate on your player based on what their character does and then, when they complete whatever they're doing, that information goes up to their global account.
And so on.
I assume so right? Since the pawn is built per-world/etc?
Apologies, I meant more of 'When the world disappears, so do all pawns on it'.
I would say player state and controller are your "per world" stuff because they reset every map change, even though you can copy things over.
(Not that they were per-world storage)
Yeah, exactly.
I'm sure you could carry over a pawn or whatever between levels, it'd just be silly.
It's not how it's meant to work.
Well, seamless travel does that inherently right?
But is seamless travel really a map change in that instance? Or a continuation of the same "map".
Fairly sure its described as an actual map change
Well, you know what I mean. The conceptualisation of a single level.
Ah, yeah. From a gameplay/play perspective, yes.
Everything just falls back to "it depends".
Look at how your game works/will work and decide. 🙂
so im not entirely sure how to explain my 'issue' but basically while working on my inventory system ive noticed that unless the player controller takes ownership of the loot container(actor that has the inventory component) the inventory component of the loot actor acts strangely when i try to create new uobjects within it using its inventory component(when working with stacking items overflowing in particular)
how could i circumvent that? i use my player controller as a PRC to manage the inventory components of my player and anything he might interact with that also has a lootable inventory component
Make sure any interaction you're doing is only on the server
- Client interacts with chest -> Send a server RPC that you want to interact with this chest
- Show UI of the inventory on the client
- Client clicks a slot in the UI to grab an item -> Send a server RPC that you want to interact with this item
Which one should I use then?
if this is for your death logic, it should just be run whenever you need it to run, not every tick
It's not death logic
what is it?
Can someone help me figure out why my Add Impulse node doesn't work in multiplayer? To clarify... If I just add an impulse with a click, it works. My issue is its not working when I add the impulse in the camera direction
in blueprints can check what player has what Ping?
PlayerState has the ping
Not sure if they still pack it. You would need to hover the variable/node to check and if so multiply it by 4 to get the correct one.
But maybe they have a function for that already.
Been a while
I'd have a question regarding replication. I face the problem that even when using complete blank characters the animation speed on the client is almost twice as fast as it should be. Does anyone know why?
https://streamable.com/v4pfjr
It seems when I add an impulse in the camera direction it only uses the server's camera direction not the remote clients. There must be some way around this I don't know about
Send the client's camera direction in your RPC.
I thought I was but it seems I don't know how to
looking for a good overview of the right way to set up a multiplayer match (timers, scoring, spawning, etc) and what to put where (gamestate, playerstate, gamemode, etc)
anyone have any recommendations?
OR -- are there any assets you recommend buying and studying the architecture of?
Lyra is always free. 😄
https://streamable.com/fwovrz If i enabl "bOnlyAllowAutonomousTickPose = true" i fix the animation speed issue but the client is played with a 15 refresh rate on the listen server
oh i always forget about lyra, ill check it out
Maybe in price - but certainly not time 😅
Blah. Just start at the data assets. Really easy to pull apart if you just follow the data.
Can someone help get the impulse working... if I set it up like this when clicking it adds impulse to remote client in the servers camera direction not the remote clients
The print string sees the correct camera direction but it doesn't apply impulse
Because you're getting the local player camera manager for the shot direction on all machines
pass the direction in the first RPC
That's a goofy ass setup tho, why do you have so many rpcs
Maybe they're making Remote Procedure Call of Duty?!
Well because I don't know what I'm doing, even with what you said still unsure
I'd start with doing the bare minimum
Client tells server which way they want the ball yeeted
Server yeets it
You presumably have physics replication turned on so it should just work
Hell I'd start by testing something like this:
Ball:
Begin Play -> delay -> has authority? -> some impulse
Test that the ball is moving on all screens the same
whats the code look like
without Advanced Session, can I somehow remember a player who left the game?
and when he returns, I will restore his stats
Well there is literally no code except that I have set in this example the bOnlyAllowAutonomousTickPose to false
It is just the default implementation of Epic for listen server setups as it seems.
If I set it to true (default) the anim refresh rate of the client character in the listen server view is very low
whats the delta array net serializer called again ?
fast array serializer
ah yes, its as ugly as i remember, thanks epic
hi, can i communicate with gamemode using player controller on client?
with Event RunOnServer
?
this is correct?
No.
Well - it depends on what you mean
You need to do a RunOnServer on the PlayerController, and then in there, you would communicate with the GameMode
(I initially read it as trying to get a reference to the GameMode on the client and then trying to do a server rpc)
does anyone here ever work with multiplayer replicating hand tracking VR?
Hi everyone. Any tips for replicating (Or not) inventories? I currently use an Actor Component on the player character that stores the relevant data. Is there any point the AC being on the client side? From my understanding the server would hold the data and perform any modifications?
I know this is very very stupid question but How to replicate names above players... I am failing in this they are replicated but sometimes when new player join he has not loaded names of already joined
I treid everything
Names should be stored in playerstate if is this approach right
Client can't know what it's inventory is unless it's replicated
Thank you. I'll need to replicate the clients inventory to use when displaying the data on the UI. I think my brain is still waking up this morning.
Is there any tricks to replicate a map var? The options to replicate the variable is greyed out but wondering if theres anyway I could still send the data from the server to the clients?
You can't replicate maps, well you can, but you gotta write your own which is not ideal
That's unfortunate. I guess I'll have to change how I store the data. Thankfully I've only just started so is currently only used in 2 places. Thank you.
is it right to do this stuff in multicast node?
getting variable etc?
or I need pass variable via server call node
because I am not sure
@rancid scarab Post in Job Board, not here
Is it really even a job? He needs to get banned, not have his post change location.
What are the correct settings for "you are a player with ~200ms latency to the server"? Should I have the latency on client only/server only? Incoming only/outgoing only?
When talking about ping you are generally speaking about roundtrip so in + out
Why the condition doesn't work? What did I do wrong?
wrong order
It hasn't been executed before you use the output.
Which order should I use?
Seems so
The condition still doesn't work :/
what would be the best way to make an object thats picked up show a UI for the person holding it? The pickup is handled accordingly on the server.
Then your "guild id" isn't returning 3.
Whatever 3 is meant to be.
Or your servertravel command isn't working.
I mean, even if the guild id is not 3, the command will be executed anyway
and I want the guild id to be 3 to execute the command
If it's always executed then your guild id is always 3.
Or it's being execute somewhere else.
Or you just didn't compile your bp.
If i change the condition to 2 it works anyway
I mean it does execute the command
Then it's being called in some other place?
replace the comamnd with a debug string node.
can I use EOS voice chat if I'm not using subsystems and "sessions" but am connecting to dedicated servers through a 3rd party matchmaking service?
How can I know what its calling as guild id?
I meant your server travel.
does anyone know why is this rep notify never being called?
This is my swimming logic and problem is that when one client goes to swim all other clients also start swimming
how to replicate the IK?
is this related to animation replication or how? I don't know where is the IK variable.... 🤔
solved, this is no more issue 🥳
i want to create and get playername from PlayerState, how should i do it correctly?
in GameMode i should create new structure with PlayerController and Name?
Doesn't it already have a player name variable?
the user, when joining the game, assigns himself a character name
by widget
then the name goes to GameMode
and with GameMode it seems to me that I should create a new variable (Sting) that will hold the replicated player name
and whenever a player joins or leaves a game I update this variable from GameMode to PlayerState
yest?
it will be ok?
Sounds good.
in PlayerState
but i want custom name
not komputer name 😄
or Steam or something....
just a custom name, what the user writes
ok, so it sounds good, so i will do that ;p
@latent heart unless you have any other tips?
are you sleeping? because you are available quite often? 😄
What about SetPlayerName?
I don't know
but SetPlayerName doesn't exist
i need create this
Are you expecting it to be called on the server or client, RomiZ?
It's existed at least as far back as 4.26
it's not in the context menu, see for yourself
wait, because each player has their own PlayerState?
so I don't need to create an array
just single string variable?
You mean node "Change Name"
I don't know what it's called in BP.
Yes
What's the best course of action if I want to send some data from a client to the server, but there is no 'one actor' that is right for the job to declare/implement the RTPCs in?
To be more specific, I have a world subsystem both on the client and the server. The one on the client wants to get stuff over to the one on the server
If I'm right, it means there needs to be a middleman actor to do the networking through, net-owned by the client
Use the player controller as an intermediary.
I agree that it's probably the cleanest way to go
Perhaps preferably a component on the player controller, having to do just with that system
There's literally nothing else you can really do without delving into unreal networking code to hook up some other stream.
A component would also work.
But it has to be replicated with the PC.
@latent heart you are the best
guys where I Am making problem when I am trying to replicate name always newly joined player doesnt see names of others
I am lost
but all names are stored in player state I am able to print them .... 😄
print them in a newly joined player as well?
Just because a player has joined doesn't mean that the player states of every other person has been replicated yet.
And are you checking that they exist on the server or on the newly joined client?
but I am using repnotfy
it should be updated for newly joined too 😦
How are you using repnotify?
should I show?
Also I'm not sure exactly, but repnotify may not trigger for the initial replicated state of an object.
E.g. new player joins -> other players' player states are replicated -> no repnotify is triggered until a change is made after this.
You could also add in a BeginPlay for each player state to trigger a ui update.
So I am going from begin play I get name I need and send it to server RPC and then set repnotify
inside repnotify I just set his name
Yes. The RepNotify is probably not triggering because it's just the initial object state.
sorry first photo should be like this
Add a BeginPlay to the PlayerState and trigger the repnotify function there.
then I have this function for TESTING when I press it it will print me all players connected it works fine so they are stored in good way
I will try
but I cant get on my widget inside playerstate ,how
its on player
here
Has anyone here messed with SnapNet (https://snapnet.dev/) before? Or any alternatives that I'm unaware of?
do I even need GameState to display the list of players?
I think PlayerState is enough
Get Pawn on the player state? Idk
GameState holds the list of players.
heh will try
its retarded to try set names via game mode ? on postlogin call function which set its name
on pawn?
so every time someone joined all get refreshed names
Game mode is only on the server, so it'll only be called on teh server.
but I can call in controller and from controller to pawns or not
bcs I can call from controller to server game mode
opposite I cant ?
OK
XD
but I am storing names and teams in playerstate on server can I use it as repnotify even its server?
How difficult is Multiplayer in UE?
Online* on PC
I've been working with Godot & Facepunch steamworks in VERY early prototyping & I'm wondering if I should skip the hassle & go to UE, but idk how UE is for multiplayer.
Depends what you want to do.
it looks easy but its FKIng.... complicated
😄
A lot of networking is built in if you want to do things that most games do.
Networking, all networking, requires asynchronous programming in some fashion. You can't escape it.
I want have it stored very safely so on server side and now in player nick variable set name of player in his widget
so everyone can see it
If I wanted to make a Call of Duty Clone, would that be "fast?" to get something working?
If I wanted to sync certain other netcode things for a custom very different "non-standard" game, how easy is that?