#multiplayer
1 messages · Page 669 of 1
You're not doing an RPC or anything asking to kill on both server and client, right?
Hey so I'm working on a little replicated combat system to advance my knowledge. Anytime the player attacks an enemy I want them to automatically slide closer to the target they're attacking.
My take on this is to use a Vinterp to smoothly suck the player closer to his target, however since this is multiplayer I'd need the server to do this. I don't really want the server setting the actors location every world delta seconds unless that is the preferable method (I don't think it is). Does anyone have any ideas worth trying? I'm not sure if UE has some sort of method in place for what I'm looking for
Hey peeps. Need to know the details for Port Forwarding. Can't find it online. Spent about 5 hours looking so far
- look up the manual for your router
- find port forwarding instructions
- ???
- profit
don't explain this to your parents it will freak them out
Missing number 3
I need to know what "service type" means and what I should set it too.
It has Pop3 and Http and DNS etc as choices
Oh so type the word "Custom"?
no
I don't know what you type
or what you're looking at
that's why I said to look up the manual for your router
there is no standard here, it depends on your router.
some manufacturers put some common services in there so you don't need to know the ports yourself, but you're not using those.
you're ostensibly using some custom port
I see So UE doesn't have a type?
I don't know what "service type" means because again, that's something specific to your router.
The only "standardized" parts of this are port numbers and the ip address to route to.
Yeah it seems to be the type of server
Like FTP server or Mail server
Or DNS server
I can't find what a Listen Server is anywhere
It shouldn't matter right? If it's a Pop3 mail server, the port should open and an external service should be able to connect
If you're able to set the port and that it's UDP, then it probably doesn't matter what you select for the service.
So it's definitely UDP?
does anyone know how I can replicate an animnotify event differently amongst clients?
im trying to do this in an actor component, is this correct?
I have a feeling that im doing something wrong here, it works but i dont think it is the ideal solution
I mean it's kinda basic, but would a move-to not work?
Wow you got a server working? I've spent a week trying to get any server working. I'm thinking I'm maybe not supposed to make a game at all. Spent months working it all out, learning about what I needed and how everything should be set up. Done the tutorials exactly. All for naught. Can't even work out if I should Port forward TCP or UDP or both. Sending me insane.
I'm doing the manually insane bang my head against the wall job of trying to open port 7777 LOL It's easier to make an entire game than open a port LOL
u dont know how to open a port?
Racking my brain over it. 6 hour in so far
Tried pretty much every combination
u found the settings in router?
if not then afaik its not possible if ur router doesnt support it
Yep. It's Nat Server
I remember port forwarding when I was like 10 for a minecraft server, it can't be that hard
theres probably something simple ur leaving out
idk tho its been quite a while
I just shut down all the firewalls. I'll check again
I actually don't know how to make a dedicated server for ue4 btw
im quite new myself
LOL
Yeah first person in 6 hours to lead to a break through
as I said, port forwarding isnt meant to be hard
had to be something simple
back to basics 😛
Yeah just thought I added an exception already
I did but it was the wrong exception
Wrong UE4 editor
LOL
Well now I can get back to work! THANK YOU!!!!
No I don't want the server to do the lightest work possible. I ended up figuring out a very good method using minimal traffic. I appreciate it though
ReplicatedUsing runs on server or client?
Clients only. Since you can only replicated values from Server->Client
Have someone the time to help me? , My Move To nodes constantly fails
my mob have to move to my player character , both mob and player character have sphere collision around them but i setted it to can't affect navigation
the navmeshbounds is correct when i press P
the move to is executed server side
but always fail
Whats a good place to store player inventory. Listen server. What about making an actor component with the inventory struct and attach to each character or no>?
This depends on your game style and the inventory in question.
I figured as much
Server type doesn't matter.
Well the inventory saving doesnt matter
I mean whjiole playing ya
but if you reconnected to same host it is not persistent
I am woried to make some huge mistake while deep into it
lol
Ive done this so many times when doing something because I am naieve and dont ask enougfh for help
Generally speaking, I'd say to place it on the Playerstate if you're unsure. It has the least drawbacks. It's easily seen from all players for UI if you want a squad screen sort of thing. It can persist for a short time for disconnects.
Hm okay
There are some arguments to put it on the character if you want deathboxes, but this only really works if you have a saved game state for d/c handling. For a persistant online style, you'd likely want it on the character. Easier deathbox creation in the end.
Does anyone know if this is always true https://answers.unrealengine.com/questions/42213/is-it-possible-to-choose-order-of-call-of-replicat.html
That the variables always replicate in the order setup in GetLifetimeReplicatedProperties or can it be random if there is packet loss etc?
I generally would not trust the order. Just rely on state in your onreps. Your OnReps can be set up to check each other's state and handle the logic accordingly.
Took me a second to realize what you meant by deathbox XD. Well there is no killing or looting of others. You can die thougfh
Appreciate your help thank you
anyone has any advice on how to implement sprinting, sliding and wall running as efficiently as possible?
for it to be smooth in multiplayer
I know of MOVE_Custom but when using it for sprinting it broke everything (even though max speed was high)
I assume I need to rewrite more than that to make it work
For Multiplayer AI what Should I use ?
BT with BB or Just AI Blueprint?
You can use the entire package, nothing wrong with that. AI and BT with BB.
multiplayer doesn't really matter when it comes to AI design
it all runs on server, controlers are not replicated, BTs don't run on clients
Hey guys, I am having an issues changing my players Mesh material for clients. I am using a function that is ran through the server and calls SetMaterial() this updates the materials for the server but not the clients. Any ideas why
You need to tell those clients via either multicast or rep notify property. You want the later one as its a state change.
Thank you!
Not sure I follow.
When you're talking about Unreal Engine, there is only two options for types of servers: Listen Server or Dedicated Server, and Listen Server is really only for when you have a player that wants to play and their computer can act as the server for the game. There would be no point in running a Listen Server on something like AWS or Google Cloud as there would be no player on the server end, so you would always deploy a dedicated server on something like AWS, or any other hardware where there wouldn't be a player playing on that hardware.
The only thing I can think of is maybe you're thinking "dedicated" means always on which you may not necessarily want?
How can i mix two conditions for replication of my property . for example COND_Initial && COND_OwnerOnly ?
Something like this :
DOREPLIFETIME_CONDITION( AMyPlayerController, PlayerActivePerks, COND_InitialOnly && COND_OwnerOnly );
Also checked PreReplication functuon to use DOREPLIFETIME_ACTIVE_OVERRIDE but i dont know how can i mix these conditions for condition parameter
it's actually better to use push model I guess, but I don't believe you can, it's not a bitfield by the quick google result I found
plus if it was a bitfield, then you wouldn't use it like that either
Hello, what would you guys recommend as project to practice multiplayer? Something that would definitely be doable and isn’t as complicated as say an MMORPG 🙂
i have a question but not sure where to post it
Practice Among Us, it helps a lot
Colors, chat system, and game state etc. very generic and easy to implement
While trying to solve the problems related with Among Us development its very likely you will ask what every developer should know about UE's replication system and this way you'll learn a lot
Like 'should I use an RPC or OnRep for color changes, how can I determine the winner of the game' etc.
chat system
"should I pass Text or String as parameter" another nice question 😄
yes . i checked source . i dont know the best way . im gonna use a reliable client rpc for this i think . i found another way but its so tricky to do . using a boolean and timer after setting the property on server . and use that flag in ACTIVE_Override
why not use push model then?
What is that ?
you can read what's in PushModel.h, but it allows you to explicitly invalidate variables as changed rather than comparisons being run every replication update
Thanks . I will check that .
PushModels are so cool didnt know about that . thanks i think this helps.
Oh thats not cool 🤣 . Push models just support static arrays not TArrays .
Am I Right ?
no
yes
show the member
Did you add the right #includes?
UnrealNetwork.h?
Oh the structure type is wrong here :d
You also need to add NetCore to your Build.cs
After changing proprty type i got linker error and this helped .
Thanks for helping me 🙏
👍
im working on a server and for some reason the server stops here [2021.10.07-19.19.27:159][706]LogNet: AddClientConnection: Added client connection: [UNetConnection] RemoteAddr: 127.0.0.1:55649, Name: IpConnection_0, Driver: IpNetDriver_2 IpNetDriver_2, IsServer: YES, PC: NULL, Owner: NULL, UniqueId: INVALID
does anyone know
Hey quick question, if I wanted to spawn an actor based on someones save, am I able to use the game instance or should I call the save?
if you want to save a players location when they sign out or something along those lines you would want to use a USaveGame then you can get the location from that players save game slot when they sign back in
You can't no
On client, is there any way of knowing inside ::EndPlay() if an actor has been Destroyed by server vs Destroyed thru relevancy?
I want to play a deathfx on client but it's also triggering when the actor is no longer relevant...
is there some other pattern that is useful in this case? e.g. I want to do something on client when an actor is killed. RPC is no good because the server has destroyed the actor. I suppose I could delay an arbitrary amount then destroy on server but seems a bit hacky.
Could also send RPC via the player controller or pawn, but then there's potentially a mismatch of the RPC comes at a different time to the actor being destroyed...
You can send a reliable multicast RPC. Probably one of the few cases where it actually makes sense.
The RPC will come through before the actor is destroyed, that's guaranteed (so long as you call it before destroy ofc)
But otherwise there's no way to know whether it was destroyed via relevancy or gameplay on the client.
should it actually matter tho?
i have projectiles that do stuff via EndPlay, BUT i have a replicated property which lets me know if its been detonated on the server (think RPG rocket)
i can check this bool for stuff like that. Most of the time though, your End Play logic should not care if its relevancy or it being removed from the world by DestroyActor.
simple question, but what should I do to make things like PlayerController's Input Pitch Scale persistent between levels?
or if I use a game instance for this, what event should I use to trigger my Player Controller grabbing those values?
it should be the same if you are using the same player controller on your levels
it might be that you are not
how are you setting it?
through an event in the ui
that doesn't seem to be the problem, as it prints the value I set it to, until the new level loads
I don't know, ideally it would not matter, but if it's playing a loud sound effect it might!
I did think about a replicated bool, but is there any guarantee a replicated var will be sent before the actor is destroyed?
There's not
Usually you hide the actor then give it a lifetime so that it has time to replicate
But it's a "lossy" method so to speak, i.e. not garaunteed
New player controller is spawned so your old value doesn't really matter. You have to save it for example in your settings object and apply them again on a new map load
You could look at "TearOff". Which calls "TornOff" on Clients and will stop the replication, so Clients can do whatever they need with the Actor and then destroy it themselves.
You usually do this in cases where the Actor still needs to do stuff but shouldn't replicate anymore, like a killed Character that should play a Death Ragdoll or so.
yeah I was looking at that but it's a bit tricky for this usecase. In my tests the replicated bool approach seems to be pretty reliable, especially given I'm also introducing a delay, and if some of the fx don't spawn sometimes then I don't think it's a big deal.
Right, yeah you can just do a 10s delay and destroy then and deactivate everything in an OnRep in the meantime (e.g. Collision and Visuals)
There are lots of ways I gues
Hi guys. Does anyone have some good tutorial links to unreal multiplayer for mobile? Thanks
Hi everyone. I'm messing around with networking profiling and just wanted to check what I'm looking at. I thought I'd try some stress-testing (such as replicating an array of 2000 constantly-changing FVectors) to see what kind of numbers I get. I tried running a standalone game with separate server and ran stat net on the client, and saw this:
https://gyazo.com/0d30c7d4bbd8004849bef69fdb84c185
Does the "in rate" refer to how many bytes the client is having to download from the server per second? i.e. the client is having to download just under 100kb/s of data?
I also ran the net profiler for a simple PIE session with 3 clients and a listen server. The generated file notes around 362kb/s bandwidth:
https://gyazo.com/5fc1d4dc6f004dcabe43af9e42353a3e
Is this only from the server's perspective (i.e. the server is having to push 362kb/s of data across all 3 clients), or is this including data inbound to each client as well? Just want to make sure I understand these numbers correctly
Is it possible to change replication conditions in runtime?
@woeful ferry As in when a variable should be replicated? You can do this with a DOREPLIFETIME_CONDITION macro with COND_Custom. In simpler cases you can also do it with DOREPLIFETIME_ACTIVE_OVERRIDE where you can toggle replication of a variable on and off with a boolean
If you mean change the logic for replicating a variable completely, I don't think so. You would have to define one set of logic to cover it
Yes, I meant from like having no replication condition to only replicating to the owner for example
I noticed there is a function called ResetReplicatedLifetimeProperty
In C++
There's no documentation on it though so I don't know if it works in the way you're looking for
Ah, it's just a minor thing I was thinking of 😛 I was just curious rather than needing it
I changed our health component to use owner only on its health, which is logical for our player character, but not for other stuff that uses the same component
that's why I was curious
Is there a way to see the "reliable buffer" ?
Like that you can see how filled the buffer is
Might be able to pull the information from the actors' actorchannel
IIRC max number of unacked reliable packets is 256
Apparently the internet is divided on this - if you have an array of structs, does the entire struct get replicated when a value in the struct changes or just that value?
Should be just that value, unless the struct has a custom NetSerialize implementation
Arrays do their best attempt at delta serialization IIRC
I'm pretty sure just the value of the array gets replicated, at least that's what I've found on the interwebs. But when it came to structs, there were a bunch of mixed responses. Some saying the entire array gets replicated, the entire struct gets replicated, or just the changed value.
Taking an educated guess at this point but IIRC, so long as the property can be identified by index + property offset it'll be just that property that gets sent, but the header that identifies the property gets longer and longer ofc as you get deeper and deeper recursion
Might test that theory tbh..
Hi. I have a replicated object that is showing a widget when player is looking at it. How do show this widget only to player that is pointing at it?
@quasi tide Actually, I might be wrong - it may indeed be the full item
Want to know myself now so going to dig through
The division continues
If you're using FFastArraySerializer, it's definitely the full item, I know that much
FastArray sends the entire array?
i thought it just sent that element
(that was marked dirty)
is there a way to make a fortnite random matchmaking for an fps game?
Digging through source.. it looks like with regular TArray it actually might send the individual property of the struct. Quite hard to work it out. It seems to be recursively looking at property handles
FRepLayout::SendProperties_r() that is
Yes but the question is so general that no one would really be able to help u
I seem to remember a golden rule was that:
- If you are adding/removing items a lot but the items themselves don't change, use FFastArraySerializer.
- If you are not changing array count often, but the items themselves are changing often, use regular TArray
well im looking for any help I can get any methods or blueprints
Ah ok so if u have a static number of elements basically?
I did discover a nasty bug recently which is that FFastArraySerializer's wrapped with a regular USTRUCT do not use delta serialization when they are actor properties, even though they should.
static or at least infrequently changing count
Because it's wasteful to use FFastArraySerializer if the item count is static, and each item changes slightly
Because you're always going to be sending the full item which might have many members
So it's a trade-off
Good to know!
This was the bug I was talking about
Actor
{
Struct StructMember;
}
struct
{
uint8 SomeByte;
FFastArraySerializer SomeArray; // <- Doesn't use delta serialization :(
}```
It looks like when the engine "unwraps" the struct member properties, it doesn't preserve the network traits for them
Seems like an oversight
There's also another annoying bug with FFastArraySerializer which is that PostReplicateChange() doesn't get called on the array when GUID's are resolved
Had to implement an annoying workaround for that
...incase anybody wants it
Then you just do this instead:
{
return HT_NetSerializationUtils::FastArrayDeltaSerialize_WithRemapCallback<FHT_DivisionMember, FHT_DivisionMemberList>(Members, DeltaParms, *this);
}```
They should make a save message thing for individuals
Like pins but for anyone
And only u see it
Yeah.. need bookmarks
i thought fast array runs postchanged when the GUID is resolved
i am sure i experienced that..
but that is interesting to note
It does on the individual element, but not on the array
Wierdly...
Rep notifies will fire ofc
i mean i only use the per item Post/Pre
ahh kk
Does steam have its own multiplayer platform, where u can have multiplayer in your game using steam?\
hmm intresting.
@chrome bay Are you familiar, with multiplayer and steam at all? If so i just had a question, and sorry if im disturbing you.
Ask your question here anyway... Someone may be able to help you.
So i have multiplayer set up, it works in engine, and it works after packaging, but after its uploaded to steam, it dosnt work. Its something with steam and im not sure what it is.
When testing MP on a single computer, all the network clients still return true to "Is Locally Controlled". Makes sense since they are all technically "local" on the same computer. Anyone know a way to differentiate them from being pure clients vs. clients on the same PC as the listen server? This is PIE testing. Works normally w/ multiple Standalone instances.
@dawn deltaIsLocallyControlled will return true for any actor that is controlled by the local controller.
This is regardless of testing type, or server type.
ya. I guess when PIE testing multiple clients those "PIE clients" don't really behave as seperate clients because of this behavior of IsLocallyControlled
since the "server" plus 2 "PIE clients" are all the same local controller
IsLocallyControlled is correctly true on network clients
yep
They all have their own controllers though, it's not the same controller.
Calling IsLocalController() on the Server, on a Clients' player controller, would return false.
ok, that's a way I could handle this case for PIE testing. Persist the server's controller and treat the others as seperate
PIE and non-editor would be the same, even on different machines
"Local" means local to that instance of the game, not the actual hardware machine
right, but in PIE arent all the "clients" sharing the same instance?
ok, thank you. My error must be elsewhere then. The "server" is returning true for IsLocallyControlled for all clients controllers, which is what led me down this path.
Likely being called on the wrong controller
It would return true calling HasAuthority() on them, but not IsLocalController()
thank you
anyone know if there is a way to get the current bound port [as unreal will just keep trying to find one beyond 7777] within blueprints?
nevermind i just did it in c
When working with Root Motion Sources, do i need to apply them on remote clients? Right now I'm predictively applying them on owning client, then applying them on the server, and it works correctly, and looks okay even with a lot of lag. If i also apply on other clients, i don't see a difference, so i was wondering if this even does anything
Hey guys, Where can I find all the blueprint nodes listed along with what they do and how they work?
well there are a lot of nodes, so you either just start following guides or check if there's a node for what you need every time you need to do something new. There's documentation for all of it online
Hey guys, I have a quick question, in order to interact with object in a game, which way to find object is better line trace from camera center or sphere collision detection?
There isn't a better one, they're just different tools
One is a line of sight check, so colliding objects would interfere and you'd have to see the object
The other one is just a distance check
Could try both and see which one feels best
Got it thanks. Do you know compare to performance which one is better?
It's irrelevant really
Depends on the game quite a lot, too, so hard to say
Get the game right, worry about performance later
Got it. Thx!
Hello , i move characters AI to location , It works when running under one process but not with Separate server.
I'm stuck.
This is exactly the same script not working on separate server.
Has anyone successfully done the offline -> manual connect to server flow in the Play In Editor mode?
using Launch Separate Server = true with Standalone mode
I am trying to test my main menu -> get in game flow.
current issue is that the PIE server seems to be launching my main menu level also.
what is the magic incantation to make the PIE server start up with my game map?
In the Project Settings -> Maps and Modes I have the Server Default Map set to my game map, that didn't work
I also tried setting the PIE preferences -> Server -> Server Map Name Override to my map name but it doesn't seem to do anything either.
LogPlayLevel: PlayLevel: No blueprints needed recompiling
PIE: New page: PIE session: MenuEntry (Oct 18, 2021, 5:52:24 PM)
LogPlayLevel: Creating play world package: /Game/MOBATest/Maps/UEDPIE_0_MenuEntry```
The edit output log on the 4th line shows UEDPIE_0 (the server) being set up with my menu entry level even though I set all these things
what is diffrence between DOREPLIFETIME WITH PARAMS FAST and DOREPLIFETIME WITH PARAMS ?
Right Click -> Peek Definition
nothing here
DOREPLIFETIME is wrapper on DOREPLIFETIME WITH PARAMS . but what is the diffrence between reqular and the DOREPLIFETIME WITH PARAMS FAST ?
Well, you're looking at it. By the looks if it the _FAST version caches some static variables at startup time. Doubt it makes any real-world difference
I've gotten it to work but it's just as fast to just launch clients separately, and closer to the real thing.
For first person I'd do a line trace. For 3rd I do a sphere trace then filter by distance and direction to select what to interact with.
New World interaction would be a sphere trace, Skyrim interaction would be a line trace.
Thanks .
with advanced sessions plugin how can I join my steam friend's session?
yeah but I want to join my specific friend's session
like create a list of session held by friends and let user choose which one to join
don't know if advanced sessions knows how to do that
you normally do that by using steam client API
click on friend ingame, join game
then game needs to handle
FOnSessionUserInviteAcceptedDelegate
to actually join that session
is it c++ only or can I access it in BP?
hello guys iam using ue 4.27 source version so when i call bReplicates its saying "bReplicates is inaccessible"
so how to access that
SetReplicatedByDefault
Use SetReplicatedByDefault() instead
SetIsReplicatedByDefault()
Sets the value of bReplicates without causing other side effects to this instance.
Hi everyone. If I am replicating a TArray and I want to utilise RepNotify, is there an efficient way to only see the items that have changed, or do I need to iterate through the whole array to figure out which elements have been modified?
so @bitter oriole its working but now my health bar is not full and my health is 0 even i after i set my to 100
and damage is not applying to clients
its applying only to sever
@twin juniper Is the parent actor also set to replicate?
@hybrid zodiac in line 23 i did but still my clients health is not updating
can check here right is sever and rest are clients
you can see print string in left that damage is happening in server only not in client
@twin juniperWhere are you printing the health? If it's in the TakeDamage function then you're probably printing the number out before it's replicated to the client. Try printing the health in Tick instead
iam just printing current health and also iam using PainCausingVolume from unreal assets
when ever player steps on that he will take damage
I think with push models you can . with push models you can replicate just changed index with value but i dont know if it works on dynamic sized arrays .
You have to figure it out yourself. You can pass the "last" value of the array in as a const-ref parameter and compare
Alternatively if you're using FFastArraySerializer, it has internal callbacks for items
@rocky stag @chrome bay Thanks both! Not heard of a push model before. I'll take a look into both suggestions. The array will be a fixed length array of structs in which items will have values changed fairly frequently
Ooh definitely keep me updated then. The array will be around 200 items in length max, so it wouldn't be too demanding to just loop through looking for changes
It seems that as far as actual size-of-packets is concerned, a static array has identical cost to a member
Which makes sense, as they can statically determine property offsets by just unfolding it
Hmm. I mean, my findings so far are showing TArray being considerably cheaper than FastArraySerializer :/
If I wrap a Tarray into a struct, would it still efficiently replicate deltas? Thinking of having an "index" containing an array of bytes with values pointing to which indexes have changed in the array
Should do, so long as the struct is a member var. Will test that as well
Cheers :-) will try as well when at my computer next
Results are pretty interesting to be honest. FFastArraySerializer uses nearly 4x the bandwidth doing the same operations
So I'm trying to re-organize my code for firing weapons so that my Server functions are inside the gun object and not just being called inside a Server function inside my character. Would this work if my weapons were actors or would I need to make them components or something else?
They can and probably should be actors, just need to be be actors owned by the character they belong to
Components have additional RPC/Property handle overhead
yeah it would also be easier to make it an actor for other purposes
It's the most common approach. See ShooterGame
So a few stats from my little test... testing a struct with two int32 properties
Property Change: 6 Bytes
C-Array Change: 6 Bytes
TArray Add: 13 Bytes
TArray Change: 8 Bytes
TArray Remove: 4 Bytes (Index 0) 3 Bytes (Other Index)
FastArray Add: 34 Bytes
FastArray Change: 29 Bytes
FastArray Remove: 23 Bytes```
BRB deleting all my FastArray's
Need to do more testing but right now starting to think FastArray is really only designed for large arrays of large structs, rather than many small items.
As otherwise, the built in TArray delta serialization is way cheaper.
so now it works from the listen server but nothing happens when it is fired from the client
Make sure the character is the "owner" of the weapon when you spawn it
You can only call RPC's on actors you "own"
I've set the owner in the spawn params. When I set it from the actor itself it throws an error
And there's an ownership chain which eventually leads back to the player controller
Also make sure you only set it server side, and spawn the weapon server side ofc
oh that would be why
iirc beginplay bets called on both sides and I can just check which side I'm on right?
BeginPlay will fire on both yeah
Should only spawn the weapon if you're the authority
Then the weapon actor itself would be replicated
if I do
if (WeaponClass && HasAuthority())
{
FActorSpawnParameters spawnParams;
spawnParams.bNoFail = true;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
spawnParams.Owner = this;
FTransform weaponTransform;
weaponTransform.SetLocation(FVector::ZeroVector);
weaponTransform.SetRotation(FQuat(FRotator::ZeroRotator));
Weapon = GetWorld()->SpawnActor<AWeaponBase>(WeaponClass, weaponTransform, spawnParams);
Weapon->SetOwner(this);
}```
it throws an error saying weapon is null only when I fire on the client
firing from the server works fine
and when I remove HasAuthority() nothing happens
Yea I thought that is what it is intended for. For large amount of data.
@oblique inlet both the Weapon property and the actor need to be replicated
And there's no guarantee the weapon will have replicated when you go to fire it, so you need to handle it being nullptr safely
ah ok
what do I need to include for DOREPLIFETIME? I forgot and I can't find it anywhere
Net/UnrealNetwork.h probably
that's it thanks
I'm getting this error
1> C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Engine\Classes\GameFramework/Actor.h(149): note: see previous definition of 'GetLifetimeReplicatedProps'
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2039: 'Weapon': is not a member of 'AWeaponBase'
1> C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\WeaponBase.h(10): note: see declaration of 'AWeaponBase'
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2672: 'UE4Asserts_Private::GetMemberNameCheckedJunk': no matching overloaded function found
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2660: 'GetReplicatedProperty': function does not take 2 arguments
1> C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(185): note: see declaration of 'GetReplicatedProperty'```
show declaration and implementation of your GetLifetimeReplicatedProps
I just forgot to declare it
I get the same errors though
void AActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
DOREPLIFETIME(AWeaponBase, Weapon);
}```
protected:
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(Replicated)
class AWeaponBase* Weapon;```
that was an old error message I updated the message above
copypasted the wrong code
it's actually cpp void ATestFPSCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { DOREPLIFETIME(AWeaponBase, Weapon); } in the file
sorry for the confusion
Anyone ever tried to implement FRootMotionSource to their custom movement component? I made a replicated pawn movement component a couple months ago and now I want to implement root motion replication, guess there isn't any guide unless source code?
This time unlike many other class/struct, header file looks well commented though
Working on creating a container, like a chest pretty much. I am currently doing all of my interactions on the server. How can I tell the client to display the UI for the container? Because everything runs on the server, it will activate the UI on the server. I've tried setting the owner to the interacting actor and then running a Run on Owning Client event, but that does not work.
Your flow should probably be:
From Player Controller or Character > Interact Key Press > Check Target Actor is in range / can currently be interacted with > Run On Server, passing reference actor the player wants to interact with > Server validates distance / interaction state and if valid > Triggers required interaction event on the required actor OR if it's to display something to the player do a "Run on Owning Client" event to display the appropirate UI.
Yeah - that IS my flow
But when the client interacts with the chest, I can't get it to tell the client to show the chest UI
But you said you're doing it from the chest right? My flow suggests running it only on the Character/Controller.
Ok, so then you should be able to pass back to the "interacting player"
Then, w/e object has the interface implemented, will handle the reaction.
Okay - so have a Run on Owning Client on the player, and in the chest, call that event?
Yep
You can use interfaces back to the player too if you want, then have that interface call the event, however you wanna do it.
Alright - sweet. Thanks. Now to work on the transferring logic.
Just missed that last step. Was off with the Run on Owning Client
Asking 1 more time here, has anyone successfully used the PIE play mode with Play Standalone and Launch Separate Server to simulate a main menu -> connect to dedicated server flow locally?
I launch the client from my main menu entry level and my server is launching the menu level. I can't seem to get the server to start up on the game level instead. I tried Server Map Name Override in the play settings and also changing the Default Server Map in the Project Settings, but the Launch Separate Server in PIE does not appear to respect them.
I've actually been working on Root Motion Sources and replication the last few days. With CMC its fairly straightforward (you just run the source predictively on the client then again on the server, and it seems to work). Not sure about with a pawn movement component.
speaking of which, what would you guys recommend doing for something like a knockback. no prediction, just server-authority applying a push to players in an area, or a player hit by something. Using Launch Character on the server with latency causes clients to "jump" on their screens. Would a root motion source also be the answer here, and just replicate it down? or is there some way to have the client launch not jump
hello guys do you think that you could "replicate" locations with Firebase for Micro instanciation on 2D game Or simple 3D topdown ?
how to handle joining a steam friend's session? Currently I can click on join game when my friend plays it but nothing happens
is there some delegate that fires or sth?
using advanced steam sessions?
and how would I go about that?
When clicking join there should be an online susbsytem callback, that your game can subscribe to, and that will provide the session id, you can then join from that through online susbystem
Look at advanced sessions (no need for anything steam specific)
Shootergame might support it too so you have two examples with code
Only works outside editor, two Steam accounts on different machines required
thanks, will look into it
When exactly an COND_InitialOnly variables become not replicated?
first PostReplication()?
after first replication of the actor
so initial only, those properties get sent in that initial actor bunch
It should be available to change in PostInitializeComponents() then
yes
Thanks
ummm, no
PostInitComponent comes first
it will be available in PostNetInit / BeginPlay
Yes
as long as its synchronous after spawning the actor
it will be in initial replication
net driver doesn't replicate actors as soon as they are spawned
net broadcast tick is on the end of the tick
anything in the same frame as (Finish Spawning is called), is safe.
deferred construction comes in handy, as the replicated variable then gets set on both server and clients before beingplay ius called
which allows you to not branch the beginplay logic based on authority
Yeah, I was surprised when deferred spawning actually syncs the changes
Thanks for the informations
as soon as you spawn actor, server calls BeginPlay
if you assign stuff after, its after BeginPlay, except for deferred spawn and stuff assigned prior to FinishSpawning call
on clients, initial replication comes in same packet as instructions to spawn the Actor
Wasn't beginplay totally local? Do server replicate it to clients?
I thought its being determined by clients
and client runs all OnReps, then PostNetInit, then BeginPlay
I see
in that order
there are few more discrepancies, because its unreal
like server won't call construction script before it finishes spawning
while clients won't wait for replication to call it 😄
hey guys.. I'm trying to force the movement of a Player character while using the navigation system, so I thought of using UAIBlueprintHelperLibrary::SimpleMoveToLocation and InEditor seems to work great but when using game builds, sometimes the Player character moves mega slow.. no obstacles or anything in the way.. any ideas? thanks 💙
I made a full menu system for changing characters and stuff so the player can change between the different characters I made only I realized after testing in multiplayer that the game no longer possesses the newly spawned characters. I was using the possess node in the menu widget which I now know doesnt work but I am struggling to fix it. I tried moving the logic around so possessing the character was in the player controller but that wont work either, everything works except actually taking over the character. So what am I missing, the possess node is for the server only but can anyone explain more cause it does not want to cooperate with me.
Widgets are local/client-only. If the call to possess is in the widget then it's not happening on the Server.
yeah so I tried moving it to the player controller and it still wont do anything, I am trying to get it to work on in the game mode currently but I cant get it to possess no matter what I do
@hallow acorn best way to move it imo, is with MoveToActor node, with GoalTracking enabled, spawn a MoveTargetActor, and have the player just chase it around all the time
you need to move somewhere, you teleport MoveTarget, you need to follow, you attach your MoveTarget to whatever you're following, you need to stop, you teleport it to yourself
No stupid questions time. If I'm a listen server, can I still send an RPC to me as a Client?
Or rather, will ClientMyRPC still be called on Listen Server?
I would expect it to work
Client RPC gets the owner actor and sends the packet to it, so it should work i assume
oh sounds great, but MoveToActor works with PlayerController? or only with AIController?
PC doesn't have a PathFollowingComponent
you either need to make it work with PC in c+
or put a replicated AIController between PC and Pawn
and getting predicted movement to work is another bag of nails
epic kinda hardcoded some stuff with CMC to work only when directly possessed by PC
Kaos had some messages .. somewhere around 2 or 3 years ago explaining how he did predicted movement for this situation
that's why I used SimpleMoveToLocation haha, cuz it received any Controller.. but true, I'll have to check on that, thanks a lot! 💙
it ran okay without prediction
but was short of production level
it took us one afternoon to switch to predicted model in the end, but we both had a good idea what we were doing
yeah, using server to move, was a pain
the lag was unreal, and not good for players
yes it is haha but will try Zlo's idea.. you got any more ideas?
well i work with Zlo
SimpleMoveTo will actually give the PC a PFC
so not sure why you are having issues
right? it's weird cuz Editor tests goes great and on builds for some reason the speed goes to hell.. the worst part, not always happens
Do both 'Run on Server' and 'Run on Client' work on singleplayer (Play Standalone)?
I'm trying to integrate a network replicated plugin and I was thinking if I might as well use what it currently have than modifying it
They do yeah
Thanks, Jambax!
Is there no already quantized FVector2D?
can a server RPC called from a client fail due do packet loss?
Does anyone know a good resource to learn a bit more about controlling multiple characters, specifically I need to learn about multiple gamepads inputs
Like say you have a few player controllers each controlling a different character
I'm not quite sure how I assign or how the engine automatically assigns a gamepad to a player controller
yes but it'll retry if it's marked Reliable
Anyone know why I might not be able to find Steam lobbies? I'm using my own steam game ID, steam enabled in ini, I have bUselobbiesifAvailable set to true, i have Search for lobbies set in the query. bshouldadvertise, busepresence, ballowinvites,ballowjoininprogress, are all true, public connections set to 5; map opens with ?listen. In the dev logs it prints that a steam lobby is created with a unique lobby ID with lobby type 2 on host and Steam P2P IP/Port. But search always returns successfully nearly instantly with 0 lobbies found. I myself am signed in on steam and so are my friends who are separate PC's and steam accounts. It shows the correct game title in the steam overlay. Any idea what might be going wrong? If I enable LAN the search returns 0 lobbies as well when on the same network.
{
//Set Session Settings
FOnlineSessionSettings SessionSettings;
SessionSettings.bIsLANMatch = bIsLAN;
SessionSettings.NumPublicConnections = 5;
SessionSettings.bShouldAdvertise = true;
SessionSettings.bUsesPresence = true;
SessionSettings.bUseLobbiesIfAvailable = true;
SessionSettings.bAllowJoinInProgress = true;
SessionSettings.bAllowJoinViaPresence = true;
SessionSettings.bAllowInvites = true;
Sessions->CreateSession(0, SESSION_NAME, SessionSettings);
}
void UGameInstance::Search()
{
if (!Sessions.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("Invalid Session Interface on Search Attempt"));
return;
}
SessionSearch = MakeShareable(new FOnlineSessionSearch);
if (SessionSearch.IsValid())
{
//Set Query Params
SessionSearch->MaxSearchResults = 20; //update val
SessionSearch->bIsLanQuery = bIsLAN;
SessionSearch->QuerySettings.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
UE_LOG(LogTemp, Warning, TEXT("Starting Search for Online Games..."));
Sessions->FindSessions(0, SessionSearch.ToSharedRef());
}
}
if I have some logic that only runs client side on Tick(), and I need to call server RPCs from this client Tick() logic, would it be bad for a multiplayer game?
depends™️ but it needs to be unreliable in any case
hello, is it here that i post this? im trying to make a photocamera in a vr game. so u can actually take pics and it saves like phasmo. how do you capture a picture like that? is it witha 2d scene capture?\
Can UObjects replicate variables? Because I noticed it has the GetLifetimeReplicatedProps
Is there any meaningful difference between the reliability of a UFUNCTION(Client, Reliable) RPC from Server -> Client vs a replicated property? In this context, ignoring:
- The fact that some replicated property values might not arrive (ie. if the value changes quickly on the server and the intermediate value is not sent or is lost in transit). For the the purpose of this question, I am interested in only the final value.
- The fact that properties will replicate to new clients who join late, while RPCs only apply to a currently connected client.
In other words, ignoring those two things, are there advantages of one over the other for communicating a piece of information that needs eventual synchronization on the client? (Hope that makes sense)
Unless your using Push Model, Replicated variables do require some resources to be checked if they have a changed value by the Server.
An RPC will have a higher network overhead than a single replicated variable, assuming of course they are the same type.
Ok, thank you that is helpful.
at the same time Reliable RPCs are guaranteed to get sent in the next buffer
whereas Rep Variables will just Eventually get there
This is maybe getting into the implementation details a bit, but assuming network traffic is below some threshold - will the engine always try to replicate a variable as fast as possible?
Yes, though the Actor itself will be throttled by its relevancy and frequency.
Which subsequently causes replicated variables to change when they are sent.
I think you're on the right path with a 2D Scene Capture. You just need to make it so that the capture is taken on all clients.
RPCs will always be sent as soon as possible, they will only trigger if the Actor that owns them is net relevant to the receiver.
also let's not forget that RPCs that don't exec on a given machine (relevancy or that the client joins later) will end up in desynchronized states
which is where push model is the way to go if you're on 4.26+
I guess this might be a bit specific and I'll just have to experiment with it, but I have something like:
(1) Player tries to pick up world object
(2) Player RPCs to server to request object
(3) Server checks, and RPCs reliably back to client to indicate success/failure
(4) World object item has OwningCharacter set to the relevant player character (so other clients can see that ownership has transferred)
I don't like this pattern though, because it involves the same information being sent twice in the case of pick-up success (namely the RPC to client and OwningCharacter). I want to change it so that the OnRep_OwningCharacter just acts as the successful indicator. In my testing this seems fine so far, but was wondering about the trade-offs for the client who is doing the picking-up (ie. are they getting the result less responsively).
(3) should probably be a ReplicatedUsing variable
also, (4) doesn't need to happen depending on how you handle the owning character.
You mean it could be COND_SkipOwner or something?
Not at all. Making a given Machine the owner of your interacting object is not mandatory
it's an architectural choice
that allows you to code stuff in a given way
but for instance, for pickup/interaction, it could be your Character that RPCs, and that currentHeld is a rep variable
in that model, the item never needs to have its ownership transferred
Ah I see what you mean.
Anyone know of mechanisms for server to server communication in the engine?
How can I disable joining my session? Sth like
UGameInstance::OnLobbyLeave()
{
GetGameSession()->SetJoinable(false)
}
in order to make a display name for the player, should I actually do something to set the player controller's name, or should I just have a string variable for that?
PlayerState has the PlayerName already
There is an UpdateSession call, similar to create session where you can supply new settings. That might help
@thin stratus thanks, will look into it
Hi There, I also came across similar did you solve it?
sorry, I don't quite remember what I had done to fix it because shortly after my drive got corrupted and I lost most of my files :/
Hi everyone, I have a multiplayer project. Every player has a playerstate with the playername. When I collide with another player I'm trying to get other actor playerstate but it always returns my playerstate instead of the other one..I'm using blueprints. Thanks!
This is the blueprint : https://blueprintue.com/blueprint/xzzdusrg/
DisplayName is a little problematic there
there is no guarantee whatsoever that those are named the same between server and clients
usually aren't
that is not a PlayerName
@winged badger It works, I used the console command SetName to set the Playerstate's Playername
Thanks for the suggestion
This is a photo from UE4 Networking Compendium. It is depicted that GameState and PlayerState are shared across all the players. Does this mean that If I change a variable in PlayerState class on Server, it will be replicated to all other clients?
It does
^ and is not marked with any conditionals stopping it being sent to players other than the owner
🥷
not on PlayerState class but on PlayerState instance
Thanks
So I've added a replicated variable using
UPROPERTY(Replicated, Transient)
bool bIsSliding;```
I've put it in
```cpp
void AShooterCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AShooterCharacter, bIsSliding);
}```
but Server slide never prints
```cpp
if (HasAuthority() && bIsSliding)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Server slide!"));
else if (!HasAuthority() && bIsSliding)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Client slide!"));```
and I'm setting it on the client
Because you are setting it on the client. Replication only works one way from server to all clients
yes
ok
if bIsSliding is going to affect your character movement you'll want to handle the replication in the character movement component instead of an RPC for better move prediction / less corrections
Well yes tho that data is sent through rpc
But it does some other stuff beside the rpc
What's the difference between regular DOREPLIFETIME and DOREPLIFETIME_FAST? Is it just faster?
pretty surew the fast is using a push model
but i might be wrong
Yeah, I am seeing that in params
What is that
GAS source code uses DOREPLIFETIME_WITH_PARAMS_FAST exclusively it seems
And I can't find any documentation on it
If you look at the Macros themselves, the FAST version avoids a Property lookup, FAST seems to just assume that the property your replicating is correct and valid to a certain extent.
Okay, so it does not actually like somehow speed up how fast the variable gets replicated or anything, just a slight optimization?
Yeah
Okay, I am going to just use the standard DOREPLIFETIME cuz it's giving me red squigglies despite it working and I don't like that
Its just saving the CPU some time i guess by trusting the programmer got their shit right.
Yeah, I thought fast would just somehow actually make it replicate faster and that would've been awesome but too good to be true
DOREPLIFETIME is just a wrapper for the non FAST version
So basically its a default DOREPLIFETIME_WITH_PARAMS
Red Squiggles is 99% of the time Intellisense not knowing whats going on.
Causing a false positive.
It compiles fine, just red squiggles remain...
get R#/Vax/Rider
Exactly what i just explained above
🤔
does regular Rider even compile Unreal?
it does
for instance, this inside PreReplication makes a red squiggle, but it compiles ```cpp
DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(AMyClass, CarryingPlayer, ItemState == ItemStates::Carried);```
NOOO, Hate red squiggles
then turn off Resharper, and just code without it 😛
use VS Code 
then don't complain about a silly red squiggle. If the code compiles, its fine.
(normally)
Yeah that’s my point. It’s part of the saved moves for replaying and correcting etc. btw I saw you authored a networked movement plug-in but it doesn’t seem to be available on the store anymore?
I haven’t updated my payment method yet and am working on a second version
Tho would prefer not to talk abt it too much here as that could be self promotion etc
still trying to figure out how abilitytasks for root motion work (so i can make my own, hopefully simpler, version since im not using GAS). do root motion tasks need to be replicated to all clients? Right now i'm running root motion predictively on the owning client, then on the server after confirmation, but not on remote clients. I haven't tried anything crazy but it looks alright. For something that's server-initiated (knockback), would I just run it on the server, or would i replicate it to everyone?
Guys, does anyone know how can i simply
GetOnlineSubsystem() // or something like that
Am i missing something in the API? I'm just trying to access the OnlineSubsystem in order to tell it to Destroy the session
Unrelated but I am also trying to make my own version of GAS
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
the more i work on it, the more i start stealing ideas/functionality from GAS anyway, but its helpful to build it myself from a learning perspective. movement has really been the worst part though, dealing with CMC prediction and root motion sources and trying to tie that into the ability system i made
you are using gameplay task component to run those, yes?
no, i'm basically creating something similar to ability tasks but not actually using the gameplaytask class, currently just a UObject that controls applying/removing the source after a certain amount of time. mostly trying to figure out if every machine needs this handler object or just the predicting client and the server
Ah ok. Are you using the new (4.26+) containers for extended move flags etc? Was looking for an example of it as it’s not well documented
I'm trying to access it from GameInstance, because i want to handle Network failures and stuff like that. Problem i have right now is that upon host leaving the game... all the clients are like "hey we are already in a session, therefore we can't join a new one or host"
I will try this though
@vivid seal its not part of GAS
and it runs the root motion pretty much out of the box
if he's the guy that made "Smooth Networked Movement," yes, it does use 4.26 CharacterNetworkMoveData in that plugin
are you using Steam / EGS ?
Actually Game Instance does have a function for Network Failures
SubSystem=null for lan testing
just go from there
I briefly looked at the source for this, but i'll check more in depth. Do you know off the top of your head if it runs root motion individually on every client? this seems more of a CMC concern (whether the server replicates root motion to remote clients smoothly or whether they need to run it themselves).
I'm trying to recreate warcraft 3 lan lobby 😄
Kaos was doing that bit, so not off the top of my head
yeah he mentioned the other day he had root motion sources working without GAS, but i wasnt sure exactly how he structured it
he had it working in 2 hours time
it seems like one of those things where if you know the answers to a few questions and you already have CMC extended its not too much work to implement, i just want to make sure im doing stuff correctly
UFUNCTION()
void HandleNetworkFailure(UWorld* World, UNetDriver* NetDriver, ENetworkFailure::Type FailureType, const FString& ErrorString);
I have borrowed the code from AnswerHub, and i have connected it with this in the constructor.
GetEngine()->OnNetworkFailure().AddUObject(this, &UWorldGameInstance::HandleNetworkFailure);
just don't do what one of my juniors did
handled network error on server by exiting to main menu (with listen servers)
Eh, isn't it just easier to just implement the BIE at the GameInstance Level ?
I'm listening
and just based on the network fail type, handle it
result: anyone disconnects, and server goes to main menu, then everyone disconnects
Eh the way we do it is that we detect who disconnected, and then act based on that
Yeah, that is totally correct. When host disconnects, everyone goes back to mainmenu. And is unable to join new or host a new session because one already exists. So i'm just trying to destroy it
BUT
And since we're using Steam, we can handle other people's connection that way
When you leave (as the client) your session gets destroyed
I just have the problem when host closes the game :/
there is no harm in trying to destroy a session if you're not in one
i find it convenient to have DestroySession call on BeginPlay of MainMenu
Also, there's no harm in destroying your local session if you're not the host
Oh my god, that is like the mother of all solutions... my brain is just not working at 4:50am
Thank you so much guys ❤️
Yup... this works like a charm, no more headache 😄
I also have one more question. How in the world would you transfer a save file? Just with RPC call ? Is there a limit for the save file size?
Or do i need to divide it in chunks?
there is a limit, think default is 40kB for payload
but its configurable
and i would RPC it to server from the PlayerState after it finishes its PostNetInit (if it has a local controller a.k.a. GetOwner() from PS scope)
note that in case of lobby and game level not being the same level, that RPC would had happened in the lobby, and would just get transferred to game level via seamless travel / copyproperties
Interesting, so if i for example add 2 ints to my save file. Like "CurrentChunk", "TotalChunks" and make it the first payload that is recieved, i can chain them till i get to the end. Or if by any chance someone gets disconnected while transfering a bigger save file?
My idea was that once the save file is transfered, everyone would simply regenerate the world when the game starts
for that you just need a seed for a random stream
ideally
unless players can modify the level and that gets saved as well
Oh yeah, seeds would be amazing for procedural. But since it's my first time doing a multiplayer project. I'm trying to make it simple with a static map.
Yet... i need to save stuff like items, talents, spells
that is not part of the level though
part of the map*
you need a struct with which you can fully instantiate the player
Yeah, you are right, but since the default start map is always the same, with the characters and stuff... i wanted to regenerate the characters based on equiped items for example
Alright i got it, thank you again for your time 🙂
So i wont even hit that 40kb mark for a single payload, perfect
and it makes the RPCs simpler
unlikely, my characters are rough equivalent of a MOBA
and the setups are 3kB when in .json format, and just a fraction of that when inside an actual struct
That is a huge relief
for example, they have equipment, of sorts
i don't save the stats for the gear, just the Rowname of the DataTable row that holds the data for it
So all the things like inventory with item IDs... it should be simply nothing
and where its equipped, Slot, Index
This is going to be so much fun, i love indie dev. This community ROCKS
how to make p2p games using eos for mobile
Unreal doesn't support P2P, it only does listen servers which aren't great for mobile
EOS is essentially a matchmaking service so it's irrelevant (doesn't handle multiplayer)
https://dev.epicgames.com/docs/services/en-US/GameServices/P2P/index.html
so this is currently not working? or is it just not usable for unreal engine?
It probably is working, and is also not used by Unreal, which does not support P2P
Saving for characters for multiplayer, what are you guys using?
Currently we're using a object that creates once you save for all players, if a new player joins it checks if there's a save object for that pawn and assign all the saved info to that character.
But the issue is it's not that scalable I've figured out now
save it client-side to the users local prefs, send it to the server when they join
Assuming this is data the client can store anyway
If you're talking about global data that clients shouldn't modify, you're looking at a data server solution or something
i find that RPC from PlayerStates PostNetInit (if the PS is that of local player) works best
It's not an issue, it's a co-op experience. 😄
But if it's just stuff like "I have this hat equipped" then probs client is the best way
that's how we do our cosmetics for e.g.
server just validates their choices
You have that in the cloud?
which is a non issue if you have a lobby
noop
as you can just RPC data while in a lobby and transfer it via seamless travel through PS
So if you format your computer, you'll lose your cosmetics?
Well you lose your choices, not access to them
Whether you have access is either a DLC key on Steam or tied to your steam stats
Which obvs we don't have to worry about cus that's steam
We have a survival experience, think Subnautica, Valheim et.c. So clients will lose their items and so on
Probably have to keep that in the steam cloud save
yeah that's fine
i hate steam cloud
Cloud saves on Steam in UE4 is basically a check box
consider the following scenario
player starts playing on friday and plays through the weekend
then slacker that he is, continues playing on his work computer from work the next day
only the work computer doesn't allow steam client to write into say, AppData
so it tries to fetch a cloud save, fails, and creates a new one
Oh yeah, in that instance it doesn't work 😄
which is the main profile file
then he figures cloud doesn't work fine, continues from home
but now the new profile he made and that cloud was still able to read and pull
had the newer date then the one from weekend
The way I setup cloud in the past was just asked Steam to backup the contents of appdata/mygame/saved
So if you can't write to appdata, nothing gets saved
Makes sense, I can probably do something like you said
this
then you get "OMG I LOST THE SAVES, WTF !?"
because the player is basically computer illiterate
tbh my only real problem with steam cloud is that it seems to be totally impossible to actually delete the cloud data
Trying to test a packaged game that already had a cloud save for my account as if it was a fresh account was a pain
Just kept restoring the cloud data
we have 2 game IDs, one strictly for itnernal use
I'm gonna ask our publisher what they're doing with their own games too, but I'm pretty sure it's something along the lines of what you guys describe
I mean storing per-player save objects server side definitely isn't the solution
You either want some kind of global data server that stores the user data, or you keep it local / confined to the user data of OSS you're usin
I do wonder how many games would be totally unplayable forever if Valve closed their doors tomorrow
I think a lot of us are dependant on that not happening 😄
I'd be job hunting 😄
Hmmm, so when a player joins does it send each saved property to the server? It can be a quite heavy operation
one struct
Depends what it is really too
from which you can completely instantiate a player
Yea, my save file is one struct
unless it's megabytes a one-off packet is ok
You can help yourself out too ofc. Like for our cosmetic choices, we don't send asset names or anything, it's just an FName that get's looked up in a data table that both server+client have
If it's static data you can key with something that helps
we use tags that also happen to be matching the datatable rowname
dat sweet gameplay tag net serialization
Yea, we just have inventory, character stats (health et.c), gear, stamina
exactly
@winged badger how many tags are you up to now :D?
Would be nice if we could do a data table customisation that used tags for row keys tbh
nearing 3000
oof
So by my logic that's..
12 bits for a tag
With enough headroom for another 1,000 or so before you need another bit 😄
it shouldn't be too difficult to make
would just need to replace that one slate element
I'll settle for multi-row editing tbh
i'd go custom DT for that tho
yeah
Still can't believe that's a thing
Was also surprised to find that adding one tag sends the whole container.. which is just upsetting
You'd think they'd have implemented some bespoke delta serialization for tag containers
but they did go and save that one bit on the tag container num
oof
thats important
10/10 Epic
find that odd to say the least
considering most games don't have a bandwidth problem, but are happily choking the server CPU
yeah, really bizarre
to go and complicate stuff for 1 bit per tag container
I guess though they only really replicate FGameplayTagCountContainer in GAS, maybe they never planned for anything else
Might be wrong about that actually
counter is way too complicated for simple use/replication
especially for stuff like COND_InitialOnly, which happens a far bit with tag containers
when we switched from normal container to count in our custom system
we had issues where multiple tags got added, but the same amount was not removed
was.. fun 😛
player getting randomly frozen in place, etc urgh
Earlier conversation does remind me. I was messing around with some RPC testing once and noticed that RPCs are dropped near getting over 65,535 bytes. Is that hard coded, or is that a project setting?
I assume hard coded due to some networking hardware limitation. Just curious about it. Seemed odd that the limit of size matched a uint16 integer size in bytes.
Hi, is there any way to use "OpenLevel" with servertravel?
What i'm trying to achieve is to have the "Completed" node within server travel
For loading screen porpouse
There are two settings for that MaxRepArrayMemory and MaxRepArraySize
They are deprecated in 4.26 though, not sure what they use right now
Huh. I think my testing was in 4.25. Didn't know about those then. 😄
I'm trying to join myself through 2 standalones. What am I doing wrong?🤔
I open the level first and then open my local ip address on the other client.
This is the output i got
can someone direct me to the right way. I'm looking to replicate the Jump from the server to the other clients, What needs to be changed on the MovementComponent? I see the state it's being stored in the FSavedMove_Character but it's not sent to other players unlike the rest of the movement events.
I thought Jump was automatically replicated?
Me too... but it seems it's not?
Only client to server, but not other clients
thought it was my project, but I've just tried with the thirdperson example
only executed on the server
Jump is not replicated to Simulated clients
You will need to fire an RPC there
And filter server and owning client
Yeah, i've checked this is quite annoying right now, because i was testing yesterday a build and it was working apparently? i even have a gif of the movement lol
Well you are jumping
But the simulated code has no concept of jumping
It just applies the velocity
So no callbacks are called
You don't even know if velocity is a jump or not as a simulated client
@shy copper
I just checked the gif again and realized it was a buggy animation 😥
So is there a way to send a multicast event but ignore the owning client? 🤔
Did you open level as listen?
I have a question regarding hit registration in multiplayer scenario, with 2 clients (client A, client B). Assume its a FPS game with guns firing projectiles slow enough that player may attempt to dodge them (think something like alt-fire shock rifle from unreal tournament), if the distance between clients is not too close.
My understanding so far is this:
-
Client A calls
SERVER_FIRERPC locally to fire a projectile at client B;
simulation projectile is being spawned locally;
then Client A (locally) simulates all the necessary things like sound of gun firing, various animations;
and finally projectile collision animation, either a blood splatter when it hit player or explosion when it missed; -
Server determines if the fire action is valid, and then if appropriate, proceeds to fire on the server;
projectile is being spawned (it can either hit or miss, the outcome is not neccesarily bound to be the same on client and server)
someON_REPfunction tells other clients that they should play appropriate animations and effects; -
Client B first notices that a projectile is being spawned;
...
In this situation, will player B have more time to dodge, depending on how good his connection quality is?
The worse his connection, the later will he notice projectile being spawned?
Similarly how do games tackle following:
Client A has bad connection issues, fire a projectile and scores a hit locally;
but in fact misses miserably on the server (in the end no hit is being registered).
You need to implement lag compensation. Server will store a history of transforms for each player and timestamp them. Hit registration takes place client-side (shooters POV). When they think they shot something, they tell the Server, and the server validates the hit by checking whether the hit player was where the shooter says they were (rewinding by the RTT of the shooter)
Don't forget each client sees every other client back in time by a factor of their own ping, the server processing time + the victims ping.
All of these things can vary so you have to build in tolerances
Non-shooters may also want to fast-forward other players' projectiles by RTT / 2 so they are closer to the Servers' current position. However that also means they might think the projectile missed them when in fact it didn't, since on the Server, their pawn is actually behind by RTT / 2 + processing time.
I found out how to do that in blueprints, but not through console
I was thinking about this just now 😄
fast-forwarding by RTT / 2 would give you where it currently is on the server (roughly) - RTT would give you where it currently is in relation to you on the Server
So it's a trade off
perfect sync (sadly) isn't possible. Whichever choice you make also affects how you see projectiles hitting other players
I.e. projectile might fly past another player on your screen since they're all in different timesteps, but it might hit on theirs
But usually unless it's your own shot, player doesn't care or cry BS 😄
Do you happen to know if ShooterGame examples does this?
nah it doesn't
ShooterGame just does client-side hit reg for hitscan weapons, and server-side for projectile weapons
UT does it to some extent, but UT's system is also really tightly integrated with the weapons and the character movement so I don't like it much
Does that mean if I were to build a simple project, server side hit registration isn't necessarily that bad right?
Probably fine as a basic starting point but not for anything competitive or PVP
Hi,
could someone help me with actor components (in a player character class)?
They contain replicated stuff like movement, peeking, flashlight etc. because I don't want a huge monolithic player character class.
I create them in the actor's BeginPlay with NewComponent.
I don't use CreateDefaultSubobject in the constructor because if I change them later it messes up child blueprints, at least this is my experience.
The problem is, whenever the client tries to use these actor components, it gets disconnected with this error:
Client attempted to create sub-object.
If I'm correct this means that the server doesn't have that component and this should never happen. So basically there is one component instance on the server and one on the client but the engine doesn't think they are the same. (?) Or the server just ignores NewObject and all of them are just null on the server?
All of these components marked as replicated and stored in a UPROPERTY. If I create them only on the server they are not present on the client.
I've read on some forum thread that I should create them in a multicast RPC and I thought it may solve my problem (but doesn't seem logical because I think it's basically the same as calling BeginPlay on every client).
I tried calling this multicast RPC on the server but the method only runs on the server but not on the owning client (I can't figure out why, the actor is replicated).
Basically all I want is to create actor components that have replicated functionality (properties and methods too). I want the same as if I were using an actor but with actor components.
I'm not a beginner so if you could give me some tips I'm sure I can figure this out.
I'm surely missing something basic, I would be really grateful for some tips or any documentation where I can learn about how actor component replication works.
First off, the corruption in the child blueprints.
Are you by any chance hotreloading? i.e Compiling in the editor or compiling in your IDE while the editor is still open.
Also, marking the components as replicated and creating them on the server should work fine. I think?
Hot reloading doesn't matter in this scenario because I tried building and starting the editor afterwards, it was the same. With default objects some of my components weren't ticking for example and I tried everything. As soon as I started using NewObject they started to work as intended. I don't want to play this gamble so I really don't want to use CreateDefaultSubobject if I don't have to.
Well if they are corrupted…
I don’t think just building will do anything
I haven't changed any code just created them with NewObject and they were suddenly working fine. I think this might be some blueprint cache or magic stuff which I'm not interested in, I don't want to learn the behind the scenes of UE. I don't want monolithic 10k rows classes because they are hard to manage and disgusting. Also I don't want to use actors for basic stuff. My question is how can I make an actor component that is present on both the server and the client and can call RPCs and have replicated properties? If it's even possible.
No, I'm not saying hotreload is the issue. I'm just saying that the corrupt blueprints could be from that.
Just back up to a version that worked. And if your answer is, you're not using version control, then consider this a lesson learned LOL
I’m using git, as I said I’m not a beginner. The problem is it never worked. I shorten my question, maybe someone knows the answer: can I use actor components for replicated stuff and if I can, could you explain how actor component replication works? Not the properties but the component itself.
After marking the component UPROPERTY as replicated do you also set them to replicate after construction?
SetReplicates() or something similar. It's not enough to mark them as replicated in your actor class
If you mark the component replicated, and it's created by a replicating actor, the component itself will replicate. Past that it's largely identical to Actor replication.
Yup, I call SetReplicates(true) after I created them.
The client only disconnects when I call an RPC in these components, I try to dig deeper right now.
I don't think you need to do anything besides set SetIsReplicatedByDefault(true); in the component class constructor, then do NewObject, and RegisterComponent? Not as familiar with runtime component creation.
Like this?
Dunno. My only known working example uses the class constructor on the component to set replication. But I assume that should work.
SetIsReplicatedByDefault(true); in the component construct makes no difference 😦
this = the owner actor, and this is currently in the actor's BeginPlay
if I use HasAuthority() the components are not created on the client, this is my problem. If I create them on the client too, it disconnects, if I create them only on the server, the client doesn't have them.
Odd.
Usually you'd create on the server and let the client receive the replicated version. It's quite weird what you're getting.
Yup, this is why I'm clueless.
Are you sure this might not be a test fail? How are you checking their validity on clients?
It's pretty easy, you can't move if you don't have the movement ability. 🙂
Have you tried a simple is valid to check the validity on both client and server.
Personally, I'd just create a print in the Component's Tick. See if it ever prints on clients. If it does, you have an issue somewhere else.
Only ticks on server. But this is weird:
BeginPlay runs 1x on server and 2x on client (?) WTF?
Hey guys. I'm trying to add a directional combat system, and to do that I compare two floats from eachother and get the Up, Down, Right and Left direction that the mouse is inputting. I've set the input to be a replicated float variable representing the mouse input. Depending on what direction I drag the mouse to, I run an animation montage with a Multicast.
However, the animation does not replicate to other clients. If I remove the directional stuff the animation plays. Any takes? 🙂
"BeginPlay runs 1x on server and 2x on client (?) WTF?" -> never mind, one is for the server character, one is for the client
Multicast? Why don't just replicate the float and let the client handle what animation to play?
Here's the graph showing the setup for those interested: https://gyazo.com/278b510d6e252990be455c7f8d0afa49
https://gyazo.com/17d0239ec61af47d90d326f8ce3ce0f3
https://gyazo.com/b5cfa08f5ec3df9334c1ea7736a1d969
Hmm, I'm not entirely sure how to do that as I've been following a tutorial setting this up (the directional stuff is added to it though), and he used a Multicast. He did say his setup was kind of wonky, but it initially worked for me. I weirdly understood his way of setting it up aswell, but I guess its wrong usage
Oh I see. Do you call the multicast on the server?
If the client attacks, you have to tell the server first that the client wants to attack, and then call the multicast on the server.
Yeah I call the Multicast on the server
https://gyazo.com/e26cdea4bb9964cf1d72360295fbed9b unless I've misunderstood the setup, this should be doing exactly that 🙂
Now the strange thing is that the animations run just fine if I skip the directional variable jumbowumbo and just run an animation. The variables are replicated, so not sure what else should be done in regard to that 🙂
You have to send the values to the server
Just create an input for the server call and send the float with it
And store the float on the server so it can replicate it to the clients
An input for the server call? Sorry, completely new to network-coding 🙂
Your float is 0 on the server
So your function doesn’t do anything (the action based on movement thing)
I mean an input for that function, a float input
Like this.
Hmm, okay that makes sense! I've got a question in regards to that though.
I'm setting the Mouse variable here: https://gyazo.com/346dc6ff2c738923eea275a3fbaa4e0e
Not sure if I used your suggestion correctly here though, but I'm setting that variable here on the servercall https://gyazo.com/1a93808e02ca59213d1f6cea09f5309f but no effect. I guess I fail to understand how the Server is actually being fed that information 😅 Thanks for all your inputs so far, feel like that was enough to teach me some things already haha
Do you see the prints on the screen? The "Down", "Up" etc.
Yeah as the client calling it
So they are there on the client but not on the server?
Actually both clients see the print
This won’t work
Inputs only run on the local machine
how do i change the ALobbyBeaconState to my custom one?
LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = FailureReceived, ErrorString = Host closed the connection., Driver = GameNetDriver IpNetDriver_28
I am facing this issue. please help
I am new to unreal its my first multiplayer game.
#online-subsystems has some pinned stuff about beacons
Can anyone please help?
Hmm, do you have any suggestions as to how I can collect the variable on the server? 🤔
Im thinking maybe I shouldve done all of that variable stuff on the client, and then just set bools depending on which comøarefloat is correct, and then just check that bool as the server? 🤔
by using custom ALobbyBeaconHost and setting LobbyStateClass in ctor
Does anyone know how to let RepNotify for bool variable work on initialization?
Details: I have bool:bVREnabled, which is replicated and has a RepNotify function. If it is changed, RepNotify exists to do some stuff on clients, such as calling EnableHMD. A client can call ServerRPC to send a requent to change the value.
The problem is on the initialization. If I initialize it with false on BeginPlay, RepNotify wouldn't be called on clients because the default value is false.
Why not just call the function anyway on beginplay?
Oh I didn't notice that way.
I can call the RepNotify function on clients if the value is the same, but the time delay might be issues.
Does it take some time for clients to get notify from server, right?
Usually. Network travel time at least plus usual server tick time. Can sometimes be up to a full half second in bad situations.
Then that might make another issues because on RepNotify i do a lot of stuff.
Is there other solution for this?
It usually doesn't matter. Your replication state should take into consideration all of the other state that it relies on. For instance, if you have three different states, and these all do a ton of things, it should matter if it's called three times once per state. Specially if this is initial setup, you can hide it behind some camera work or a loading screen.
I'm curious though. If this is a client set value, why does it matter so much? If it's client authoritive, the client should set it and call necessary functions after sending it to server. The Replication should never come back to client since it should skip owner.
The only onreps that would need to happen would be on other machines than the owner, and if the state is set to true, then it can change them, if it's false, then that should be their default state on initial setup.
I quickly checked my codes, but maybe that doesn't matter.
so I will try that way until i find issues
thanks, man
By the way, I found something called ELifetimeRepNotifyCondition::REPNOTIFY_Always. Do you know if this is something useful for this situation? just curious.
Could work. Though on that note if you're running 4.26 or more, it might be worth considering a pushmodel system that you can just mark dirty.
More deliberate.
What is that system?
You can check it out in the native PlayerState.
Pretty easy system. You specify the variable the same way.
Call a slightly different macro in GetLifetimeReplicatedProps.
Then when you set it, you also mark it dirty.
I'm semi sure that marking it dirty will send it to a client regardless of the value changing.
Curious, will test.
Does it skip all of the replicated variables, or just specified ones?
Skip?
it skips changes, right?
on sync
I meants, skip all of the changes or changes of specified variables only
Normal currently replication just checks the variable on tick basically. Little more complicated, but still. Pushmodel only checks the ones specifically marked dirty. Saves a lot on server ticks in some cases.
You can use the two together as well, it's not one or the other as far as I'm aware.
I see. That sounds good. I will take a look at it.
I noticed issues on the initialization thing. I am a bit confused, so please correct me if I am wrong.
If the value is not the same as default, doesn't matter. server changes it and rep notify is called on all clients
but if the same, all clients call RepNotify by themselves
but in the function, I have something I have to wait for at least one frame
I mean I use SetTimer in RepNotify to do some stuff after that
that might be an issue
Oh, it is not that the problem happens if the value is the same. it happens if the value is different.
clients which is not local call RepNotify and set timer, then a local client finds the value is different, and then call ServerRPC so server notify changes to other clients
Okay. Seems even with Pushmodel, the OnReps won't run without that condition set.
I will definitely learn that.
Hmm. Well that's.. odd. Even with that condition set to always it isn't running. :/