#multiplayer
1 messages · Page 209 of 1
Think about what you want to tell the server
Do you want to tell it "I want to open this safe"
Or do you want to tell it "I want to interact with whatever's in front of me"
Or do you want to tell it "I pressed E"
“I want to open this safe”
Thank you for the replies btw.
Are you going to have other objects you may need to interact with in a similar way? Other objects that when you approach them and press E you'd like them to do something?
Is it always going to be the same player interacting with the safe, or can other players potentially interact with that safe at any time?
Yes more objects will need to be interacted with, with E.
And yes up to 5 people!
Ok, so that means you wouldn't be able to use inputs events on the object itself, nor be able to run RPCs on it, and you probably want to have something more generic to handle interactions rather than implementing the "E Key" input event in each actor.
Since inputs are normally only routed to pawns that you have control of, you would have to locally call "Enable Input" on the actor you want to send inputs to, which is kind of finicky to do in a multiplayer game. RPCs can only be sent to the server from a client through actors that are owned by that client, and an actor can only have 1 owner, so it wouldn't work well if you need to be able to have those 5 players being able to send that RPC.
What you need to do is create a generic function on your character or player controller as you mentioned, and send the RPC through it instead. You can pass along a reference to the actor you're wanting to interact with through the RPC. On the server's end, you can then use the actor reference to either retrieve an interactable component you can place on all interactable objects that may share similar code, or, use an interface and implement your own interaction logic per actor as you desire. As you're running on the server, you would likely also want to verify that the player can actually interact with the object, like they are within an acceptable interaction range and the object can indeed be interacted with by this player.
so the issue was that i was nulling the Item At Slot A
then adding a new item (that was added at Slot A since it was freed)
since this is happening the same frame (tried next tick but same results) the NetSerialized is called only once to save and load the new item
so for Slot A i dont have (as expected):
- Slot A: save on server & load on client Item to nullptr;
- Slot A: save on server & load on client Item to NewItem;
but its only doing: - Slot A: save on server & load on client Item to NewItem;
i would atleast the server to try saving twice
Hello can anyone tell me the advantages and disadvantages of dedicated servers? because cannot even make dedicated server because you have to compile the source on windows and it is a nightmare on windows.... Is it very hard to on windows, and I am thinking of making some " not even rendering or all of that listen server, any idea?
Can I use RPCS anywhere, or must the actor/component be set to replicated first?
You can only use RPCs in replicated Actors/Components and then they still follow the normal Ownership rules.
Aka ServerRPCs can only be called by the Owning Client.
Multicasts only by the Server.
And ClientRPCs only by the Server and only if the Actor (Component) is owned by a Client.
Ah, I was using a UObject and my Server RPC was being ran by the clients lol
I swapped it to an ActorComponent, but I don't see how to set it to replicated?
This is the only option on ActorComponent 🤔
OR does the entire actor need to be set to replicate?
Yes, both
Hmm strange, I change my UObject into a component, and now the ServerRpc is obsorbed but doesn't do anything, not even print msg to screen
Like this should work fine, I have the same thing in another component. But for some reason the server RPC does not print "Dropped" from the client side
Oh wait lol. This code is on an Actor in the scene posing as "global" code. Does it not work because it's not owned by the player?
does TMap has any known replication issue ?
is it already in the level or spawn while gameplay ?
It's already in the level, an actor that manages all item drops
then its owned by the server iirc
Oh, so the client can't use it at all?
wait let me check something in my code
for a chest (level actor) i remember having to go through the player pawn to call server RPC
but i dont remeber if it was because i was firing in UI
if your actor is set to replicate then it means he has no owner
So the player calls the ServerRPC > which interacts with the chest
could just pipe a generic "Interact" rpc through your PC and use an interface inherited by the actor you want to be interacted with to do specific stuff when interacted with
yeah i had to do some redirects to use player owning conenction
to add items to chest inventory, i called a server RPC on my player, that then calls the event on the chest
Eh, I hate interfaces, find them to be messy lol
Ah right on thanks man
Interfaces aren't messy at all and help clean up code immensely.
Depending on your implementation of them.
Chest:
- PlayerRef->Reroute_ServerRPC(this, ...)
Player:
- Reroute
- ChestRef->AddItem(...)
https://forums.unrealengine.com/t/tmap-replication-exposing-to-unreal-reflection/6653/38
I found this btw. Looks like it may not be fully supported, but check the last post
Ah, I used em a while ago and just didn't like the idea of "merging" classes. More of a mental messy than a code messy lol. I'm using a scripting language based off Blueprints, so can't use interfaces anyway 😛
Interfaces don't "merge" classes.
Blueprints have interfaces. AngelScript should support them. Should.
thanks, interesting stuff
igot what i want in
FMinimalReplicationTagCountMap::NetSerialize
You know what I mean lol, mixing code from multiple classes/files/implementations
Interfaces have usecases, very important ones. If you have the mindset of avoiding them, then you need to learn how to properly use them, cause you are most certainly creating shitty code in cases where you should have used them.
I used em in my last C++ game heavily, and now I don't even have the option to use them and don't really miss em. 🤷♂️
If you ever do a if (X->IsA<...>() { do thing } else if (X->IsA<...>() { do thing } else if (X->IsA<...>() { do thing } you've got a clear case for an interface that'll make your code a lot cleaner.
looks like they save it using
const int32 CountBits = UAbilitySystemGlobals::Get().MinimalReplicationTagCountBits;
int32 Count = TagMap.Num();
Ar.SerializeBits(&Count, CountBits);
for(auto& It : TagMap)
{
FGameplayTag& Tag = It.Key;
Tag.NetSerialize(Ar, Map, bOutSuccess);
if (--Count <= 0)
{
break;
}
}
and load with
// Update MapID even when loading so that when the property is compared for replication,
// it will be different, ensuring the data will be recorded in client replays.
MapID++;
int32 Count = TagMap.Num();
Ar.SerializeBits(&Count, CountBits);
// Reset our local map
for(auto& It : TagMap)
{
It.Value = 0;
}
// See what we have
while(Count-- > 0)
{
FGameplayTag Tag;
Tag.NetSerialize(Ar, Map, bOutSuccess);
TagMap.FindOrAdd(Tag) = 1;
}
UPackageMapClient* PackageMap = CastChecked<UPackageMapClient>(Map);
LastConnection = PackageMap ? PackageMap->GetConnection() : nullptr;
if (Owner)
{
UpdateOwnerTagMap();
}
to reset the map, why dont they clear it directly ?
while(Count-- > 0) this is cursed
true
same as having a public var Owner and func SetOwner thats has logic and only use Owner
Also
Why do you have a Map and then just set the value to 1?
Does it ever go above 1?
?
oh
its just the default value
keys with 0 as value are removed
with such setup, am i forced to us Replicated or can i try ReplicateUsing ?
what does Rep notifies need extra ?
Don't have the option to use them ?
Eww who's using angelscript
Me! The speed improvements are insane when you get programming with their blueprint system. (No headers/crashes/compiling/etc). Just write some code, hit save, and poof it's in unreal
You whole conception of interfaces merging classes is very wrong. Interfaces are for things that can respond to something but you as an implementer don't care what it is. For example interaction interface can be on a chair, a player, a door. Etc. You don't care what it is when you call interact just that it responds to yours calls.
We have never needed to use anything like Angel script on a team. Nor have we have ever considered it. Verse will becoming soon
Yeah I know, I've used em many times. I guess I'm just salty to the stupid long iteration progress with compiling in C++ lol
We don't have long iteration times with c++
We have what we want in our head. Design the base layout and class layout before writing any logic.
Then we start implementing the details
Yeah every setup is different. Sometimes you're a team with design phases, powerful computers with build farms, etc.
Sometimes you're a dude in his basement with a shit laptop and a second job where every second count lol
Closing and booting the editor takes me 1 or 2mins max and compiling is also super fast. We also live code our implementations once the class layout is made so we don't need to keep rebooting editor when implementing the logic
Everyone's got different options that are right for them 😄
I mean sure. But if you want to make anything viable in unreal your work station is very important
If your workstation is slow then you have to compensate somehow
I know that feeling all too well..
But Angel script? Urgh
There was a game released that used it
Can't remember what it was
It Takes Two
Ah that's it
But the majority of the people on that team were not progrsmmers at c++ level
That's why the ones they did have integrated Angel script iirc
isnt there a popular crash on The Finals with Angel script
The finals use it ?
yeah i remember
It's still programming the same as C++, and you still need to use C++ fairly often
But it's let me recreate my Minecraft-like voxel game in unreal in just a month, complete with turn based combat and almost-online multiplayer
Sarcasm btw
now im currious what angle script is, i thought it was just some private the finals plugin name
Which is crazy -- but just because of the literal 0 downtime when working
It's a scripting language
Yup!
Bit like lua
or py
Basically yeah lol
Py?
Python is a programming language
Scripting languages work on as layer on top of another language
Either way it's nice that it sits on top of C++, it's not a replacement. So full C++ is still an option but it saves us from ever having to look at a blueprint node hehe
so angel script i just a language that overwrite a lot of UE native functions so you dev with it instead of doing c++ ?
from i read on the home page, it sounds "cool"
but what are the down sides ?
souns like a in-between c++ dev and BP designer
It's an additional scripting language that sits on top of C++. You can use it as much or as little as you want, and literally removes every single annoyance of C++. Give it a go if you're not "HardcoreC++" and want an easier/faster time.
Can read about it here
https://angelscript.hazelight.se/
i just realized that
it saves the keys but not the values

If the only value it ever has is 1, just use a set, not a map.
no the value is a uint8
so it can be 0-255
i need to figure out how to serialize the values
I'm for some reason still struggling to getting smooth rotations based on mouse. The client jitters a bit still when i move the mouse slowly. Am i still not getting this right?
Enabling camera lag does seem to smooth out the visuals
Just something i tried, disregard that part 😄
Why you replicating the rotation for
Control rotation is already all handled
I don't think I have ever needed to replicate the actors rotation to server
Doesn't work any other way, at least that i have tried. I'm doing 6dof, which might be why
Right but there is better ways to do it other than this but require c++
If your BP only. Your very limited
Yeah i've noticed that. I'll keep it like this for now since it seemingly works, if i need to i might have to do some c++ instead
I assume this is the best way if i'm sticking to BP? Or is there a better way. If i introduce emulated lag it's bad.
you need to replicate smooth rotation?
Yeah basically
@torn zinc I did something like this recently. The actor that will rotate needs to have Start With Tick Enabled = false (I'm sure it exists in BP), and have a bool bShouldRotate. Inside the tick, have a branch checking for the bShouldRotate condition, when it's true, you set the rotation however you want. Have a RepNotify on the bShouldRotate, when it fires, it checks if bShouldRotate is true, if yes, then Set Actor Tick Enabled = true, if not, then set it to false. Now have the server call a function inside the actor that needs to rotate, the function shouuld start with a branch checking if Actor Tick Enabled = true, if so then return (leave the function), if Actor tick enabled = false, then set any parameters that define how your actor will rotate IF any, finally, set bShouldRotate = true.
Ok im gonna try that after dinner, thanks!
Np!
Think about who BeginPlay fires on for a player controller, here’s a hint. It exists for both the server and the owning connection.
Begin Play of Player Controllers fires on both the client and the server. If you're running a dedicated server, it doesn't have widgets as it's headless, so it can't create a widget, and then you're attempting to add that widget to the server's viewport, but because it couldn't create the widget, you get the accessed None.
i have!
its a bit messy to setup but i can help
currently only using it to store/retrieve some data though nothing too fancy
does anyone have any idea what those jitters are? im sure the attachment is working properly because i set it on server then use on rep to set for clients
hii
the oil rig is the only idea i could get for a cool conquest point on water
and yes rust is kinda to blame hehe
oh shit thats actually a very good idea, im gonna very much use it! thanks
i dont remember very well because i set it up long time ago, although let me look back into some of the code and let you know
also i do know some tutorials that might help you up
If I have a reliable event that I call on server, let's call it event A, and in event A I do set timer by event for event B, will event B be reliably called even if I don't tick the box for reliable?
All local events are reliable, if your event A called on the server and is reliable, and then calls event B which is an unreliable multicast then no it's not guaranteed for the server or the clients.
If event B is not marked for replication then it would always be reliable
Hey ppl, simple question, im confused.
i have a mesh on each pawn, i want each pawn to move it (client side, auth proxy), and i want that movement to be replicated to other clients.
what's the most common way to do that?
should i add an rpc or a replicated var on the client to send the transform every so often?
im reading the docs but im confused.
https://forums.unrealengine.com/t/trying-to-replicate-a-static-mesh-component-from-a-client-to-all-other-players/1761002
https://dev.epicgames.com/documentation/en-us/unreal-engine/networking-overview-for-unreal-engine?application_version=5.0#actorreplication
someone on the forums said
"Replication is Server to Client, Always. Then engine will not replicate changes on a client to the server or any other client.
Clients must request the server to make the change, then that change can be replicated out to other clients."
so i wonder if i should do the rpc route.
The absolute minimum information you need to send is Location and Rotation
The usable minimum probably also includes Velocity and possibly Acceleration
It would be good practice to compress the information in some manner also - possibly using an FFastArraySerializer so you only replicate what/when you need - after you have it working
This should all be contained within a struct
Then you send it from Client (Auth) -> Server via unreliable RPC on Tick
And the server Replicates this data with COND_SimulatedOnly
Client auth is very simplistic 🙂
you're a hero.
follow up please. just to be sure. if i change a replicated variable on the (auth-proxy) client. that change is not sent to the server automatically right?
As that someone said, replication is server to client only
So the client must send the information in an RPC instead of using replication
But then the server can replicate that to all other clients (i.e COND_SimulatedOnly)
:drakeyes: aaaaaaaah thanks a lot! so helpful!! 🙏
what about calling a server event from server
so if i have a reliable event A and in that event I do set timer by function name of event B, if i want B reliable I dont mark it for replication according to you, but what if I want it to be unreliable for bandwidth reasons
of course I always want A to be reliable because I want the initial timer trigger to be guaranteed
So I'm a little confused, the only reason I can see event B being replicated is if it were a multicast, and yeah with my experience with unreal engine. It would be terrible design if the multicast only ever got called on the server and not the clients. I guess I am not 100% sure but I'm taking an educated guess as that is really bad design
Also the way unreliable works is pretty specific, either you have enough bandwidth available that frame to send out the multicast or you don't. It's not checking per individual client
Packet loss is a different story though
We are way over thinking this. Event A being reliable and guaranteed does not mean Event B will be reliable
It's great if you can't afford Steamcore
It actually works as intended I've never found any bugs with it
You might be doing something wrong
Just curious. Do you use SAS for anything more than the basic sessions?
I'd like to build a widget that shows the number of connected players. I'm thinking of using OnPostLogin/Logout to send an event that counts the connected player and multi-casts the number to all player controllers.
Am I overthinking this, or is there an out-of-the-box way to do this?
I did, it had some other features as well, but they're all pretty basic.
Playerstates are already replicated to all. All players have a PlayerState, and all playerstates are stored in GameState's PlayerArray.
Begin Play of PlayerState can call to the GameState and trigger an Event Dispatcher that signals when a player joins the game.
End Play of PlayerState can be used similarly to notify when a player has left the game.
Any UI and widgets can then bind to that event dispatcher in the GameState to know when a player joins and leaves - make sure you have the event dispatcher pass a reference to the PlayerState that calls that dispatcher so that your UI can read the appropriate PlayerState.
If you ever need to construct something based on whoever is currently in the game, then yes, use the PlayerArray in the GameState to get all the PlayerStates.
Thanks both!
Its terrible for other reasons.
Namely that each of those nodes is likely creating a new UObject for every call.
GameSparks had a plugin that had a similar design
UI Designers would go crazy with their nodes
Throwing them on Tick and in for loops
Creating crazy amounts of Objects
We ditched GameSparks after that.
So it was a short lived issue for us.
You are likely better off creating a Struct with the same layout as your expected data and exposing that instead.
If not, then you are kinda shit out of luck.
Probably
Is there a nice way to send somewhat large amounts of data (~100kb) that isn't me just sending an omega rpc?
I currently just yolo it into an RPC and it's of course turned into a large object rpc
I could probably look into it but I have no context for what a socket is here
Just a TCPSocket
If it was static why would I send it?
@nova wasp Take a look at FTCPSocketBuilder
Ah, so this is what python remote calls use
Hilariously the rpc is working... okay-ish
I could heavily compress it and I probably should
RPCs arent exactly designed for large data
100kb is fucking massive beyond words for an rpc
that is like 20 separate rpcs end to end
it's not a lot of data at the high level but you have to consider that most rpcs are like 100 bits
of course, this is mostly for two things
- initial world state
- the occasional "you are being yelled at back to this state" rpc
Let me see if I have a network profile of it
server to one client
replicate the texture data? what replicates that?
Does anything send rendertargets over the network built in?
If you havent realised yet, he typically makes suggestions that are completely off base.
yeah that is... not something that implies it being a texture makes it easier to send over the network
the data is arbitrary, it could be anything
nevermind...
TcpSocket ftw!
My other hilarious attempt: one giant fastarray
for each type of thing
it actually worked, but quickly starts capping out how fast it sends updates
Just use a Socket man, its what they are for.
yeah, I guess I still also have another more "per object" transmission that's more typical of actor replication
because I am foolishly tiling at windmills not using actors here I am in for a bad time
You might be able to use a UChannel but I havent looked into that
UDataStream maybe in Iris
they are incredibly annoying to make extensible because epic did not consider anyone would
Im stuck in UE4 so not sure how much has been made better
Sounds like it would do about the same as a streaming socket
Guess theres no real-time network transmission options in UE yet
I imagine coming up with the hard parts of how to stream the data is the user's problem?
Do they require me to come up with acking the pieces?
sick, this sounds great then
It handles that itself
thank you all for the suggestions
The Socket API is really friendly
I wonder how a realtime protocol would compare to regular sockets tho
Probably wouldnt even be worth the implementation
The hilarious part is that the netblobbed reliable rpc is already kind of doing what I want
of course this is wasting some bits I imagine but... meh
but yeah I imagine the socket won't get cute with splitting it up 200 times
Uchannels are pretty easy to use
Hey broskis, is there a way to get a list of all connected PlayerControllers, or Controlled Pawns?
Basically when someone drops an item, I just want it to check if anyone is nearby to auto pick it up
on the server you have all controllers, I think game mode and or game state knows about them
Oh nm, looks like I can do GetNumPlayerControllers, and then loop over GetPlayerController(i)
Might be able to do it through ugameplaystatics 😄
Inventory or held items should have nothing to do with player controllers. :/
When the item's on the ground, it's gotta check for anyone nearby to loot it
I would assumed the item will be dropped somewhere in the level, then it would just check nearby player pawns to be considered for the loop
How would you get nearby player pawns, if not looping over them and checking their distance?
But you're right, because players might be in a different Level at some point, in which case this code may error
I guess GetActorsOfClass may work better? Or GameTags
You can loop and check the distance I am just not sure why you want to loop according to the number of the players in the world.
Imo it can just be the relevant pawn near the items
How would you do something like this?
Relevant pawn near items
When the item drop, get the location, do a radius trace filter it with player character.
that will be the relevant
then I can just loop over them
so Player 7 at the end of the world don't need to be considered
Oh, isn't that expensive to perform every tick?
Oh no if the item drops on the ground it can sit there until it expires, if no one grabs it
like minecraft
I wouldn't say it's expensive at all either, but you certainly don't want to send rpc on tick when you don't have to
You can just check for overlap
the item can have Collision component
on Overlap -> suck the item
no need to check every frame
Yeah was wondering that too, not sure how expensive overlap is either as i assume it's doing the same traces internally
And what if players have some sort of upgrade that increases pickup radius
I figure individual checks might be easier
most mesh in the world already have collision anyway
the item shouldn't be an exception
Then you probably want the check from the player
instead item reacting to player
Hmm yeah guess I could attach some sort of overlap on the players soon. I haven't looked much into unreal overlaps yet
Thanks for the suggestion!
So, is there any way to delay destroying an item for clients?
Ex: An object moves to a position and gets destroyed.
The clients see it's movement 0.5s delayed, but still see it get destroyed at the same time as the server. So it appears to be destroyed 0.5s too early.
Unreplicating it at the end would be nice, so the client can destroy it on their own time. But I don't think it's possible
Do a collision query
GetWorld->OverlapMultiByChannel or whatever and filter the results
Pickups querying players is wierd though. Should really be players querying pickups. You're bound to have far less of them to start with.
Oh right! I forgot overlaps can be done in code. I was imagining setting up meshes and their collision properties and stuff lol
Yeah player overlaps -> items definitely makes sense
Well, you still need to set them up with a valid collision profile ofc, but scene queries are fast
Overlap events are slow. You can turn them off and quite literally get 50% of your CPU time back.
GetWorld->OverlapMultiByChannel This would be considered a scene query right?
By overlap events, do you mean actual physical collision with meshes?
I mean ultimately they are the same thing, but yeah that's a scene query. Overlaps are also scene queries though tbf
But they're costly because they are updated everytime something moves, which is usually just wasteful
Another interesting question: If it's possible to force OnRep, even if the var is the same?
nope, they're immediatte
Yeah, but only in C++
Use DOREPLIFETIME_CONDITION_NOTIFY and pass COND_Always as the last argument
I've got an FString that stores the animation, and OnReps to clients. BUT if the animation is repeated, like Attack is done twice in a row, it won't rep it
O dang nice
If it's done twice in a row, it won't replicate twice anyway
Server sends all property "differences" at the end of the frame. If it thinks client already has a value, it won't send it again
Yeah that's my question
Which is ofc by design, replications only job is to ensure the state matches
And it needs to do that as efficiently as possible
Yeah, might have to send along a multicase if the attack is repeated
COND_Always is usually used when you are modifying replicated properties ahead of the server, for prediction or something. Rarely has much use though.
and COND_Always is clientside
Yeah
a multicast RPC is more appropriate for these one shot things
You could use an incrementing counter also, that would technically qualify as "different"
My issue is that the Client who requested the multicast will also get hit by it
but ye, multicast might be what you want here
Like, Client does "Attack", then "Attack". It obviously knows to repeat it properly.
Requests a multicast from the server, multicast comes back and forces is to run "Attack" again (a third time, now)
yeah so ignore it?
you could send a client RPC from the server to each individual player except the one you want to ignore if you really wanted, unreal doesn't have an easy mechanism for multicast RPC filtering
Eh it just gets odd. If I do if(Anim == "Attack") return , then the other clients would ignore it, as they were already set to "Attack"
Yeah that would have been ideal if it could multicast for clients except the requester
well that doesn't even sound like a correct condition for ignoring it
like you can tell if a pawn is locally controlled and therefore has predicted the action
Considered this too lol. Lots of workaround possible. Was hoping there was some sort of built in solution like multicast filtering or forcing a repvar. But guess not. Oh well no worries
Which is a darn shame honestly. YawLighthouse has a PR for it though. Big change though.
Oh no you're right, this is the key. Thanks that'll work
yeah I even gave feedback for the specifiers to allow more granular control
Is the HasAuthority() function not available in an actor component class? I can't access it somehow
I would also strongly consider using FName not FString if you are doing string comparisons like that
Or tags, even
No. GetOwner()->HasAuthority()
Aah right thank you
So what's the deal with IsLocallyViewed()?
My player uses a CameraActor that follows the pawn (and does some other stuff when needed), yet IsLocallyViewed() for all pawns at all times. Is it just better to use "WasRecentlyRendered?"
IsLocallyViewed is true if the pawn is a view target for a local player controller
and when possessing, your local pawn is likely to be the view target
it's not a visibility check
Hello guys I have a question. Can a pointer to asset be replicated? I have a AnimMontage, that I know is loaded on every peer, can I replicate a direct pointer to it (instead of soft ref)
UPROPERTY(replicated)
TObjectPtr<UAnimMontage> Montage;
will appreciate any info ; )
It can yeah
And what happens if this montage is loaded only on serwer, but is not in memory on peer? Will it still work?
depends on the value of net.AllowAsyncLoading
if it's false (the default) it will hitch
read the cvar description
TEXT("net.AllowAsyncLoading"),
0,
TEXT("Allow async loading of unloaded assets referenced in packets."
" If false the client will hitch and immediately load the asset,"
" if true the packet will be delayed while the asset is async loaded."
" net.DelayUnmappedRPCs can be enabled to delay RPCs relying on async loading assets.")
);```
ok i understand, so it will always load, it variable is false it will bock load, hence hitch
good, thank you very much
When serializing a struct for an RPC or replicated property is there a way to make sure it is byte aligned (for better oodle dictionary compression)? Or are they all packed into the Bunch as bit aligned with no control over it depending on what came before?
like can you read from the Ar an amount of padding bits to add/read to get things back into byte alignment?
I made this object on my map
first of all, how do I get reference to it so i can rotate it - triggered by my character input action
and how does the replication works here?
How, if possible can I limit the tickrate of the server in PIE?
I think it may not be possible (someone correct if wrong), pretty sure it is all synced together; if you need to debug blueprints in dedicated server and another instance you could launch two editor instances and limit the server with t.maxfps, and also turn off the stuff that slows down unfocused windows in the editor settings
Ya, I think that's the way to go sadly. Or I just suck it up and package the server
First point, you'll want a soft actor reference and then you should be able to select the actor in the loaded level
As for the replication, you should be able to add a rotating movement component to it that (if memory serves) replicates the rotation for you
Then you just add to the rotation on the component
Is there a better way to do this?
im noticing some stuttering after this. Trying to keep it as stable as possible since it involves physics
i have an issue with a minimap camera
this logic perfectly works with main camera, and makes visible characters of the same team to each other
but a minimap camera always showing team1 units, ignoring this check
how to make it affect another camera too?
thanks god
https://blueprintue.com/blueprint/j667v7ab/
hey ive got this minimap in PIE it works as it should with listen + clients but when building and testing it dosent work for clients :/ ? any ideas (its on player character bp)
This seems strange and not sure why you need a multicast for this. Minimap stuff is almost always something that can be handled entirely locally based on data about the actors you're trying to represent within the minimap, so that means it almost always could be handled through OnReps and appropriate already locally triggering events (like begin and end plays). A multicast could maybe be used with a minimap if you're trying to do something like a "ping" on the minimap in which case a player would need to communicate to others the location of that ping, it's not something that late joiners would necessarily need to know about, and it's not something that needs to stick around, but that doesn't appear to be what you're trying to do here.
Team information is usually something you would store within the PlayerState if it's only players that can have a team. If you have AI or other actors that you want to have on teams, then you'll likely need to utilize the pawn to store that information. I'd highly recommend aginst using a Name for teams, and instead use an enumerator or GameplayTag, the GameplayTag being a bit more flexible to use. You can use OnReps of the Team variable to signal an event dispatcher that can notify your minimap of the pawn's team that changed - the minimap can also check the owning player pawn's team value against it, and if they match, then you know that they are on the same team.
hello does anyone have a good video/website to understand what I need to change to make my custom movement component compatible with unreal's network prediction ? preferably in c++ but I could manage with blueprints, thanks
If you're only working in blueprint, then all you really have is an event in the PlayerController when their pawn changes, On Possess
yes, i use this logic for "pings", and its bugged same way
i try to place this logic into GameState, and in a base Char class, multicasts, local events, everything, but always have the same result
reworked like 10 times and nothing helps
aye, but really i could just call it from the controller dont really need the event possessed stuff
are rep notifies reliable?
for attaching my player to boat im doing it on server and setting it as a replicated w notify variable, on the notify func im calling the attachment so any new comers and the client themselves know of this attachment, however its not really syncing" up, sometimes the client doesnt snap to the location yet is attached
the boat jitter,i cant tell what it is
never mind people, im literally stupid. it was the collission
is it a local function that gets called on each client?
but it acts on the client with their copy of the variable right?
i see
seems reliable to replicate stuff
Well, it boils down to:
Server replicates variables to clients and can call multicasts and run on client RPCs (which execute on the client that owns that actor).
As a client, you can only send Server RPCs on actors that you own.
Any data that you want to share with clients need to be replicated through replicated actors by setting replicated values on the server or sending those RPCs. Those actors need to be relevant to the client in order to receive the information as the actor wouldn't exist otherwise.
So if you want something to show and hide based on a Name value, then you should be setting the value as you need while running on the server and using the OnRep of that value to trigger the event that would then cause things to change as needed when the new value is received.
i mean i would only chose to use it in sitaution whre im sure that the value will change
for example the driver once seated cant be set to another one, and if he leaves then the variables to go null ptr so i believe that works
multicasts ruin my project because irrespective of stuff being set, it goes ahead
wouldnt i want to run something like that on multicast though?
right but as you said the repnotify wont work, then i wont really have a choice?
wow im gonna need some chai to do this
the collission being the problem and then this repnotify/multicast
i surely have to revisit a lot of stuff i wrote like 2 years ago or smth
This is my first time using Blueprint Interfaces. I have two doors: Safe Door and an actual Door. What am I missing here? If i disable the interaction input for the top (safe door) then the regular door opens fine and is replicated, and vice versa. If i leave both interaction inputs connected then nothing happens for either door (although if i put print statements at the end of the run on server and multicast, they are both printed).
Oh and this is in my Character blueprint^^
This completely negates the use of the interface if you're having to cast.
Press E (Or whatever input) > Detect Interactable > RPC To Server with Actor that is interactable > RPC then calls interface to interact with actor.
This was from Matt Asplands Replicated door tutorial!
Should i remove the cast altogether?
For instance if I have the Safe blueprint like this:
and then the character blueprint has this:
The purpose of an interface is to allow you to communicate to another class without having to know the specific type as you implement that interface in the target actor. If the target actor doesn't have the interface, then the interface function will not be called on it.
A cast attempts to convert an object variable's type to also allows you to communicate to another class but requires you to know the class (and also creates a dependency in your blueprint to that class) which then allows you to call the already known about functions and access the variables of that class. If the cast fails, then the output reference will be invalid preventing access.
Once you're running on the server in your character, you can call the interface in which case you can call any other multicasts or set any replicated values that your door can then use without having to involve your character blueprint.
Im sorry im very new, but im trying to understand. Do i need to remove the casting part, and somehow after TRUE branch, I need to send the interact message to the SAFE?
if bp safe implements the interface then you can call an event/func from the message directly
this is your message
you dont need a hard reference to that class anymore. think of it as if you had not just safe but many other things you wanted to interact with, would you send a message to that item and then on that message run a function or would you keep casting and binding an event and individually write down all your code in player/whatever that wants to interact
this is what that message calls
and instead of binding the event i believe you can just call a server RPC that sets the rotation right after the message comes in
@daring gorge Would you have time for a discord call so i could share my screen? im still a little confused!
if not i understand!
Press Input > Detect Interactable Actor > RPC To Server with Interactable Actor reference > Server RPC calls Interact Interface
Actors that Implement that interface > Do whatever is required from the interface call.
No casting is needed for this.
i might not be the best person but i can help with some basics, however cant rn its around 5 am haha
Heyas, any way to know if a remote pawn is controlled by a player or AI?
IsPlayerControlled() returns false for everything
unless.. beginplay is just lying again -- in which case, which event to use??
So do you think the RPC's should be in safe logic? Like the custom events?
If you assign a PlayerState to the Pawn you can check APlayerState::bIsBot
AI Controlled Pawns dont have a PlayerState by default, you would need to set that up yourself.
Nopenope
If you try this in BeginPlay, Playerstate is nullptr for everything lol
That's why I ask if there's some correct event to use, as seemingly nothing net-related works in beginplay
Yeah probably because the PlayerStates havent replicated that early.
and I feel odd using an arbitrary timer
Yeah exactly, so is there some ideal event to use, or safe time to wait before initializing everything?
Or like, how is it done in most games
Wait until the PlayerState calls BeginPlay
And for remote AI? (which have no playerstate OR AIcontroller)
How/When are they initialized remotely
Atm I have no way of knowing if a pawn is controlled by AI by a remote player, as it doesn't really trigger any playerstates or controllers
so it just looks like a Pawn that's not net-ready yet
I told you above, that AI controlled pawns do not have a PlayerState by default, they can be setup to have one.
Look at the AIController
It should have a property called bWantsPlayerState
This should give a PlayerState to your AI Pawns
If its enabled
Oh interesting, but then am I able to specify which Playerstate? Or do the AI pawns get the same PlayerState as human players
They get the same PlayerState
You would need to override the functionality to inject your own.
Which seems like a very odd way of just knowing when they're net-ready lol
Aight nvm, was hoping there was an easier solution but guess not
Unreal could really benefit from an OnNetReady() event or something
🤦
🤦♂️
Anyone ever run into an issue where Mutli Box Trace By Channel doesn't work on their dedicated server, seemingly for no reason? I've triple checked all the obvious reasons it wouldn't generate a hit event, and still I'm stumped. I'm getting the feeling that it's some hidden setting
I'm calling it in an Anim Notify State during an animation montage, when a sword is swung
What do you mean by "doesnt work"?
An RPC to the server must happen on a client owned actor. If you attempt to call a server RPC on any other actors, like your safe, it won't work.
You can run mutlicasts on other actors when executing code while running on the server.
Input (which would happen on something normally owned) > Detect Interactable Actor > RPC to Server with actor reference > The RPC should then call the interface on the actor reference passed through the RPC.
The implemented interface in the actor (which would be running on whatever actor you call it on if it implements it, and also on the server if you called it in the RPC) will do whatever you want it to do.
An interface can be called locally on the client, but then that code is only going to be executing on that client. An interface is a means of calling a "generic" function that classes can choose to implement and each class can have their own implementation - they don't specifically care about any networking themselves as it's just like calling a function.
Doesn't generate any hits.
The animation montage is running on both the server & client through a gameplay ability. The hit is successful on the client, but for some reason, not the dedicated server.
I've read that VisibilityBasedAnimTickOption can potentially affect that, and have changed the property, but to no avail.
oh sorry didnt see your message hang on
No. After your branch, call an RPC to the server passing in a reference to the actor you want to interact with.
Once running on the server, use the referenced actor from the RPC and call the interface.
The interface implemented on the actor can then do whatever you want - exactly like how you're calling the timeline. You don't need to have separate events for each object your character may want to interact with in this way - just one RPC for causing an interaction from a client to the server, and then letting the server replicate anything necessary back VIA the actor itself rather than the character that first initiated the process.
Would you have 5 mins to hop in a call so i could share my screen? if not its alright.
Sorry, don't do voice.
no problem
by RPC do you mean custom event (checked for Run on Server)?
That is one type of RPC, yes.
Three types of RPCs:
Server (Run On Server) ---- Will execute on the server if executed while already running on the server on any actor, but if requesting to execute on a client it will only start to execute on the server if called on a client owned actor.
Client (Run On Owning Client) ---- Will only execute on the client that owns the actor. I believe if there is no link to a client being the owner it'll execute on the server
Multicast (Executes On All) ---- Can only be called by the server and will attempt to communicate to all clients, so long as the clients have that actor relevant.
im sure this is still incorrect lol
That is closer.
You need to pass a reference to the actor you want to interact with through the RPC (You'll need to take the "Array Element" pin and have it connect into the RPC)
Change the "SAFESM" type to "Actor" and rename the pin to "Actor" then use that to call the interface in the RPC.
It worked!!
I was originally asking because I have two doors, and the code looks the same^ but i could only operate one at a time. If the InputActionINTERACT (at the start) was connected to both sets of code for the different doors in my character blueprint, then nothing would happen. It would only open if one was disconnected. Im going to change the code to the updated version and see if i can use both now
Now you can rename that RPC to be something like "Interact ON SERVER".
This will work for any actor that implements the interface, so yea, any doors you place should work fine. If you want to create more actors that utilize this functionality, all they need to do is implement that interface and code out what happens when someone interacts with it.
okay turns out that I had some weird code from a tutorial, causing the second door not to work! Thank you so much for your patience and help! Made my night to get it done! Have a good one!!!
I'm trying to create multiplayer game and I have some question.
I want to damage system according to which body is hit.
For example, if bullet or sword is hit head then dealing damage 50, if bullet or sword is hit arm then, dealing damage 20
In this circumstance, server need to know client is cheating or something.
So, I need something like rollback system to get sort of information about the actual head or body physics body is actually that position certain of that time.
To achieve this, I started looking at charcter movement component but I'm not sure, this component actually can handle physics body rollback system.
Does anyone know how to figure it out this problem?
In this circumstance, server need to know client is cheating or something.
no u dont
So, I need something like rollback system
use GAS
Hi,
I have a native actor class I'm spawning on the server side that doesn't get replicated. Anyone knows what could cause it?
Ctor:
{
PrimaryActorTick.bCanEverTick = false;
bReplicates = true;
bAlwaysRelevant = true;
}```
How I spawn it:
```void UVallhundVoxelWorldManager::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
UWorld* World = GetWorld();
if (World->GetNetMode() != NM_Client && World->IsGameWorld())
{
WorldManagerActor = GetWorld()->SpawnActor<AVallhundVoxelWorldManagerActor>();
}
}```
What is the parent of AVallhundVoxelWorldManagerActor.
AActor
AActor does not have RootComponent by default. Without RootComponent your actor won't get replicated. Add RootComponent or set bAlwayRelevant to true.
Right! I forgot about that 😄 Thank you!
I guess AInfo is better for these purposes
hey im creating an actor from a character to the server (all works) inside that actor im Timelining movement around the map (this works but not showing same for Server/Clients) which is the problem
how would i replicate that character so the client tells the server where it should move etc ?=
this is how im moving the Actor
i need the player to tell the actor to move via the server rather then have the actor moving itself on server since its local side and cant talk with the server right
Some basic questions here:
- Is the actor you are trying to move definitely replicated?
- Is the actor setup to replicate it's movement?
it is replicated
it is set to replicate movement
but i changed it calling the movementpart from the character bp (owner) then everything works
i knew it would its more what practice is best when creating an actor on the server how would u "controll" it via the client
since the other way i only know how is using the CMC which is very costly
was the settings on the Actor
Hey guys
I have **multiplayer widget( cull) **problem
There is a nametag above each players ( child component in Pawn blueprint), host always can see others, but if a client is too far deactivate or cull other players, when REAPPEAR in certain distance the widget reset all values and name is incorrect.
Any idea, what event can I call to set name again ?
( temp solution: I increased Net Cull Distance Squared, )
Hey there, I’ve been following the tutorials from GameDevRaw on how to create an online game with blueprints and I have reached a point in the editor where I when play a standalone game I can create a server, it shows up in a server list for another player, I can join with that other player and the game can start with both players. But when I made a build for the game to test it out on two different computers, when I try hosting, it doesn’t show up in the servers list on the other computer with the build. Did I forget to check a box that allows it to actually create servers or be online or is it some other issue?
I think it might be find sessions that isn't working but I don't know
it also seems when I play in the editor it doesn't matter if it is set to lan or not, the server always shows up in the list
Does anyone know how I could conditionally make a static mesh in my level see-through for just one player but normal for everyone else?
I basically want to have one player who can see through all the ceilings in my level
I have a question I can’t find an answer to online; does a replicated ACharacter, seen by a client that doesn’t control it, still execute all the ticks of its components?
2 separate actors. A replicated one and a personal one
Heya guys, RPCS can not have return types right?
Like it won't do anything?
Yo so - i'm a lil rusty on gameplay network programming, quick question for you peeps - how does attachment work in a networking context? If I do AttachToComponent on the server, does that rep down to clients or do I need to multicast the attachment
I think it is replicated. I can't recall me ever doing an onrep/rpc to attach on clients.
But would it really matter? Server is authority on positions and the client would follow the server's position.
So as long as it is attached on the server, probably doesn't matter much.
yes, because it means the position would be latent and out of sync with predicted movement
and if you don't want that behaviour - aka you want mismatching positions on an actor
Yeah - attachment is onrep'd @fossil veldt
USceneComponent::SetAttachParent marks the field dirty
And there is an onrep for the attach parent
So my understanding was that Switch Has Authority execution pins only get called if it happens on such.. For instance the remote would only happen if a client uses it.. Is this wrong? Because I am having an issue where if my player moves left / right / or backwards then it creates two line traces.. So I am misunderstanding something here??
You don't care if you're a client or not
you care if you're locally controlled
Isn't that the same thing?
no
ahhh interesting, ty
I wonder is there a way to do attachments without triggering the onrep
Your character would return Remote on my machine
if we're both clients
You don't want that, you want your character to trace only on your machine
like i actually don't want the behaviour of server + client attachment in this case, i'd like an item to be attached to the 1P mesh on the local client and then for everyone else it's on the 3P mesh
does it have to be a replicated thing?
okay thank you.
I mostly stick to 3rd person games because of stuff like this. Zoom far enough in OTS and it is pretty much first person 😄
@chrome bay might remember how they did it in HLL
What is remote then? I couldn't find docs for it for some reason. I thought local control and clients where the same thing.
If you have doc link to explain Ill definitely read that.
Remote means not authority.
Locally controlled means the local playerController owns it.
Your character on your machine is remote and locally controlled.
Other clients characters on your machine are remote but not locally controlled
Listen servers character is authority and locally controlled.
The 2 concepts are orthogonal. You can be locally controlled or not, and you can have authority or not.
So remote is just another way of saying a replicated entity in the world that is controlled by a client?
Also do you mean orthogonal in the sense that they do not affect each other directly? ( but we assume they can do it indirectly, maybe? )
Appreciate your patience.
Server has authority over all actors spawned on its instance, clients don’t have authority over actors spawned on the servers instance. If the server spawned an actor, it will be the authority on the actor, the clients will not be. To them it’s a simulated proxy. Being controlled by something doesn’t necessarily have anything to do with network authority.
So I'm having a really weird issue regarding replicated physics. When the game starts, all my replicated physics objects work as well as can be expected. However, once a player picks one up (and gains ownership) and drops it (and loses ownership), it becomes extremely buggy:
Anyone know what to make of this?
It also happens if another client player picks it up, although I wanted a high FPS for the demo so I left it as one player
Is the TV set the simulate physics by default (class defaults), or are you setting it at runtime
Both
You check the box and you set it to simulate physics at the start of the game?
yeah
The parent class sets it to simulate physics on beginplay
But I check the box anyway
And when you drop it, who sets it to simulate physics then?
Which connections
void APickupActor::Detach()
{
GetRootPrimitive()->SetSimulatePhysics(bWasPhysicsEnabled);
GetRootPrimitive()->SetCollisionEnabled(PrevCollisionType);
DetachFromActor(FDetachmentTransformRules(EDetachmentRule::KeepWorld, true));
}
Is that function called from an RPC?
Well attachment replication is already handled via a rep-notify. But shouldn’t matter anyway
Which type of physics simulation are you using?
rigid body
I'm a fucking...
I replaced bWasPhysicsEnabled with true and it worked
I think
I need to test more
Is the server calling that rep-notify as well?
yeah
So just know that attachment is already handled from a rep-notify. When the server executes that function it’s going to set the attachment again when the notify fires, which is fine. But just know it’s happening twice
See AActor::OnRep_AttachmentReplication()
Nope
So I think the root of my question has came to what does "Authority" and "Remote" pins do off of Switch Has Authority node?
Does it just check if the said actor or whatever is client or server?
Basically, it checks whether the current piece of code is running on the server or the client
For a replicated actor, authority = server and remote = client
Although if a client spawned an actor, it means the client has authority and no one else knows it exists
Authority and remote actually has to do with who owns the object it is not necessarily the server
But in your own example if a client spawns something they are the authority
So its authority over the object it isn’t a network check
?
Non-replicated actor -> has authority
replicated actor -> server machine has authority, others are remote
exactly
Heya guys, can Clients spawn actors?
Yeah, but they'll be client-only
I ask because I'm making a large open world game. So in some situations, clients will be far from the host, and thus the host will not have their area loaded
So if the host spawns the items, they'll fall down into the abyss
In that instance, no
Any way way to give ownership after they're spawned?
The host needs to have the area loaded. If it's not, actor spawning is the least of your concerns.
Same goes with enemies and AI, I might have to transfer ownership when to whoever is closest
But think of games like minecraft, valheim, etc. Where clients can be literally miles away from the host and still play normally
The host still loads those areas
They're just not rendered
Unreal Engine uses a server-authoritive model. If you're looking to change that, you're gonna be in for a world of hurt
lol
But Unreal has a really powerful open-world system out of the box, and a lot of great resources on how to use it
I'd start there
Don't re-invent the wheel
Oh interesting, though I find unreal tools are VERY hard to customize
like you either cookie cutter exactly what they have, or make your own from scratch
Though mine's a voxel game, so already the host is generating the world as fast as it can for a decent draw distance
Can't imagine it also generating 3 other areas at once, when players split up
Well that's how Minecraft works
And every other open world game I can think of
(there's a reason the server starts to chug in MC when players split up and load new terrain)
I've learned the hard way that it's important to have a strong foundation before getting into the details like replicated actor spawning
Notch had "cave game" years before he made it open-world
Oh yeah, I've got a pretty good voxel base with turn based combat and all
works great in multiplayer too
BUT
nice
Yeah the host needs to have all areas loaded
That's a major performance concern you're gonna have to think about
Yeah because the rendering itself is nothing, but actually generating the voxels is what takes the time
Especially because mine are much more details than minecraft
For instance, Minecraft has a separate render distance and "simulation distance," and world processing that would need to be synced is only done within the simulation distance
Hmm interesting, yeah and my shapes can be simple cubes for collision too
Even if you think it might not work out in the long term, I highly recommend exploring some of Unreal's open world tools before ruling them out entirely
Is this written somewhere? I'd love to read more about it
Oh yeah I'm already looking for them lol
Awesome
But keep in mind they were implementing their engine from scratch
I do modding, so I can tell you that Unreal is structured quite differently to the Minecraft engine.
Oh yeah for sure
Fortnite is dedicated server though right?
So I'd imagine it can handle a lot more, not having to render the world it's simulating
Yeah, but listen servers and dedicated servers work on the same principles.
Also, rendering and simulating happen on separate threads
So the fact that you're doing both won't be too much of a performance hit
Hmm okay, yeah thinking about it already
Would you happen to know the name of their Openworld sample?
I can't seem to find it
Also, I don't play fortnite, but I think it can be a listen server as well
The city sample?
This
The great resources you mentioned
What I just posted
Also, just google "Unreal Engine Open World"
Check out the new features and tools that make it easier to work on large open worlds in Unreal Engine 5. With a bird’s-eye overview of World Partition, One File Per Actor, and more, you’ll have everything you need to start creating your own open world games.
I have, I'm just worried about the engine generating procedual voxels for a bunch of players at once, as apposed to just flipping on/off premade areas
I'd say try to get a pre-made open world working first, then try to focus on dynamic generation
Mmm shit, I've already got my minecraft game going, would hate to start over lol. But definitely a lot to consider, thanks for all the info man!
You don't have to start over
If you've already got the combat system and other stuff in place, you have a really strong framework
But if you've built the voxel system with the assumption that clients can be authoritive in generation, that's gonna have to go
That's just not how UE works
Or any mainstream game engine for that matter
Oh I meant testing with pre-made areas, as it's already designed for loading chunks, breaking blocks, etc 😛
But yeah definitely a lot to think about here 😄
Thankya 😄
If you can figure out how to serialize your world at runtime in a format that's compatible with World Partition, that could probably serve you really well
But I don't know the details of your game
The base of it is very similar to minecraft -- the other details aren't really that important in this circumstance
cool
Do you mean like, saving the world to disk?
In minecraft the way it works is that the server has complete control over the voxel world. When you break and place blocks, the client just tells the server via RPC that it wants to break or place a block in a certain spot.
That's how I would do it
That's how I'm doing it atm yeah
And also, make the particles that appear when she breaks the block completely client-side
No reason to waste bandwidth and processing power replicating those
Oh? I replicated every single block in the particle!
Jk of course lol, server just says what broke
and clients take care of all the visuals 😛
just making sure lol
But here were ya talking about saving to disk?
How would that speed things up though?
I assume you're saving the contents of your world to disk when they're unloaded
If not, ignore that part
Oh nope lol
ok lol nvm
I just save any block that was modified in a big tasty TMap
And then regenerate the world, plugging back in the changed blocks
Haha 🤷♂️
Minecraft loads its worlds from disk significantly faster than it generates them
Yeah I'll prob incorporate that later on, just trying to get it feature rich asap
Like, almost three times as fast
But I guess that depends if you expect players to enter pre-explored terrain much
And if they'll be updating it a lot
Oh, I only generate like 5 blocks tall though (not gonna have huge cave systems), the big resource sink is actually creating the procedural mesh
Ah
Well you could always cache those meshes
But it's probably not worth
Also, you probably shouldn't be replicating the mesh
Tell the client about the voxel pattern and then generate it on the client
Yeah that's why I let everyone generate their own world based on a seed
and only replicate changes made to it
But hmm, I think the simulation thing could be a good idea. Generate ultra basic collision for other players
I see what you were thinking with client-authorative generation then
Yeah everyone explores their own identical worlds, and RPC back changes made
What I would do is have the server do base voxelization alongside the client, and then the client handles generating detail parts of the mesh
That won't effect gameplay
Yeah that's what I'm thinking
Will also read a lot more into this in case of any other pitfalls
But look at Unreal's default open world system and see if you can use anything from it
Could be very helpful
Right on will do, and will try to find as much other info as I can. thanks man!
exactly how imma do proc gen replication in mine
i have afriend who did the same and even let people have their own lil radius to generate and delete chunks around em
Yeah that can cut down on network lag significantly. But the server still needs to have it generated as well
in my case the server spawns in the proc gen actor and replicates the seed, im making like 4-5 small islands at max in my game
I think Lego Fortnite does procedural open-world generation
Maybe you could try to research how they did that
*in a multiplayer setting
ive already made the terrain generation and even added in some monuments, ive even experimented with caves and such so, all we need is to layer up stuff basically and since my case isnt very complex i dont have much left to do
theres also an article for replicating proc gen
Oh hey sorry just explaining all this to my GF haha. But def gonna give it all a read over again after 🙂
i just have it bookmarked, yet to look into this myself
all the best mate! your project looks v cool!
Oh thanks man haha. Goodluck to yours as well! 😄
Been having this issue with my client. The server sees it perfectly, but the client seems to be missing some info. Any suggestions or help is welcomed :)
Hello, What do I need to replicate in order to get each of these to only apply to the person activating it? It should be visible to everyone that that person has it activated.
Current Workflow is
Widget button click > widget icon hover > third person character (widget component)
https://streamable.com/8f9gul
basically what id suggest is the widget has a character variable to it and the selection can either be saved in the character bp itself or the attachment done through that variable. so when the character spawns in the widget takes the information from the character variable that being the person it belongs to or is on top of
is the cart to be attached to the vehicle?
yes, It is attached using a physics constraint
What do you mean character spawns in the widget? Currently It is a widget component on the character
I have it setup to RPC server from the player BP when you press E. Then it leads to the entire connection process within the wagon BP
so i dont know how to solve your exact issue but i had issues replicating actors with physics so i tend to simulate physics locally, and as for the attachment i had this sorta issue so i made sure the clients were informed of the attachment through a rep notify
yea so all you need is a variable in the widget and use a RPC to set the variables value to your character on server so the widget thats attached to any character has the value of that character for all the clients
ive had the same thing without using physics constraint, so i cant tell if the physics constraint would make the difference
also the same way i got mine working
dont mind the breaking character but only when client knew of the attachment was this smooth, or else it would just lag around in the air whilst the boat would be going forwards
is this character BP?
gotcha, so maybe thats the part im having a hard time grasping. What should I tell the client and when?
you could use a rep notify? something like set the wagon as a variable and on the func call the attachment. this makes sure it is called on all the clients. if this doesnt fix it then it could be literally physics being replicated. physics actors do that, you can try debugging this part by simply using smoothsync component, if it works then it should be the physics, if not then sure attachment
This is the widget that that character BP uses
right so the widget should have a character variable, the character it belongs to and you could essentially take the image variable from there and it should work easily
On event construct it casts to BP_ThirdPersonCharacter and stores it as a variable
UI is not replicated so imagine it as a local component
you could store the image variable in the character BP and extract and use it from there itself using that character variable
that way the UI works in respect to that character variable
I have the HUD widget that uses an event dispatcher to pass in to this widget what the image should be, then that character has that widget as a component on him
I just don't know what inside this widget should be replicated
UI cant be replicated
wait let me show you like a simple thing i have in my project
So I should just use the event dispatcher to pass the image directly to the character?
How do I set it so that the space is Screen If I do that?
Guess I'm trying to wrap my head around what to do after the character gets the image
I have it set to screen so that all the icons face the individual user (client)
ive sent ya dm
I don't fully understand, you want to display the icons above the characters head for all players ?
yes
In screen space so that all the icons face the client
Runescape?
The space type doesn't impact anything on how to make that "replicated" :)
I'm just figuring what I need to replicate to get it to work properly.
Basically lol
What i would do:
(Lets say you want to replicate the info using a texture, but it could be anything, a tag, some id, etc)
- Have the actor with the widget component or the widget component replicate
- make a soft ptr Texture(2D?) variable
- make it replicated OnRep
- in the onrep, load the soft ptr and apply it to the widget
Now to make it set on server (so it gets replicated) you need to call a Server RPC (with the texture as parameter) on the characters/widget components
^^
I will try this after I get done with dinner
also you neednt use a dispatcher at all but if you do then you can use it as the alternative of on rep
just to say "ive set the image"
do arrays in bps when marked as onRep not call the onrep function when stuff is added?
I'm trying to set up a listen server and conect from an external network. Its worked fine on the local network between 2 PC's. It doesnt work with external network.
I've opened the port (17777) and have a public IP. I've used online port checkers and they are saying the port is closed. From what I'm reading this could be because the service (the unreal game) isnt listening, or something isnt working with port forwarding
Idk about newer versions, but you used to have to set the array to itself to guarantee a callback. This might only be the needed when an element is changed, and onrep might be working as expected for adding/removing items.
If it works over the local network, does this confirm that the service is forwarding the port correctly, and that I should focus on troubleshooting the router, etc. instead?
i see, im using 4.26 and my onrep func doenst hit when i add an element
yeah that's what I had in the exact same version. Bit weird, but yeah, the method I mentioned should work.
I'm only forwarding 7777, and if the map is opened with the 'listen' option, it's working perfectly for me 🤷
think i might just use fastarray replication and convert code to cpp cus why not
yeah you get much less of that random behavior 😄
I'll try 7777, 17777 was default for me but maybe it doesnt work for some reason
wasnt 17777 the port for PIE? Let me know how it goes!
BP is not great when working in MP
really isnt, im planning to convert almost all -except some of what ive written to cpp
Thats good news
7777 is also coming back as closed
I allowed inbound and outbound for that port in firewall too
UDP I assume
other than your usual antivirus stuff I have no immediate ideas :x I'd definitely be interested tho when you find the reason.
Is there a way to troubleshoot ports? Want to figure out if its a router issue or a game issue first. I havent used port forwarding on this router before so it could be that
If I run netstat in command prompt would the port show up there while the game is running? because its not
I'm clearly overthinking here....
How would I spawn an actor locally for each player knowing that one of them is a listen server?
I've tried making it a non-replicated actor that is only relevant to the owner.
What does the Listen Server have to do with that?
In what context are you trying to spawn the Actor?
All non replicated Actors are considered "local"
Player State Server event runs through a series of spawn functions (Load save, create save, etc). Which then spawns a widget.
I'm trying to spawn a local actor that will hold the character "creator" that you visually see in that widget.
If I call the spawn within the server event, both users see the same thing and only the server can "change it" (It's still replicated somehow 🤔). If I spawn it on the client, it's reverse, they both see the same thing but only the client can use it.
You want to check the PlayerController for IsLocalPlayerController
Only spawn the Actor that belongs to that PlayerState if the PlayerController is a Local PlayerController.
is there any tutorials about mesh visibility? like setting mesh as visible to other players only
doing a fps game,
but other persons should only see the third perso mesh
or should I use the same mesh for first person and third person view since I'm beginner on ue5
(or replicating a mesh with yourself being the one that can't see it)
That's not even network related?
You just need to tick bOnlyOwnerSee in the component panel
Or something down that line
Since when?
Maybe I'm misunderstanding what he want
Isn't it just a component that only the owner see e.g first person hand
They want what you answered them: Only display FP Mesh to Local Player and TP Mesh to others.
That's a Multiplayer problem. So why is that not network related?
Or wydm with Network Related?
Cuz I thought ticking only owner see will do the trick. Regardless multiplayer or not
Since only the owner will see the mesh
Yeah but that's a Network Owner.
And the question is still about a multiplayer problem.
Ohh ok, well I never done fps before but I would suppose other character like A.I can also "hide" their fps arms from the player by ticking the box
Yea my bad
The Boolean is even worse. Cause it relies on the ViewTarget
You can tick that and change the ViewTarget and you will see the TP Mesh
Which is good of course, but the Boolean is shitty named
Booleans fwiw
But the problem is a multiplayer problem, even if the solution is useful in Singleplayer too
No you usually have 2 mesh components. Which you either add by default or spawn dynamically when needed to save performance.
The TP one will have the full body with the bOwnerNoSee flag true.
The FP one will have the arms with the bOwnerOnlySee flag true.
Most people for starters have the character's Mesh Component as TP and add an additional one as a child to that as FP.
Just make sure you don't add the FP one to the capsule directly, but rather to the Mesh when using a character
Add / Attach I mean
Cause the Mesh is smoothed so everything visible has to be attached to it
Anyone have an idea on what would be the best way to attach a playerpawn to a unpossed/ai pawn using a physicsconstraint?
this is my current setup just to get debugging with replication
just have no idea how to replicate a physics constraint tbh
i've done it on my player pawn, but I cant get it working with an outside object
it is
multiplayer fps
you can see your hands, but not your feet
I think most fps you can't see your feet when you look down
but other players can see your whole body
The ones you can are called true fps afaik. It is network related, I was just confused how owner only see work internally since we can just tick it on A.I and it still work.
Ignore what I said and read what exi says about it
I know, he mentioned me
@fossil veldt for items? No movement replication - just drive attachment from inventory
constraint components don't have any replicated properties so they won't replicate, you'd have to replicate yourself and create constraints locally. Keep in mind a physics constraint won't do anything unless your pawn is a physics-simulating body
these modular arms are working fine from players perspective but in mulitplayer it seems its not moving at all
could it be becuase these arms nor replicating their animations ? or is there some other issue
You usually have entirely separate first and third person meshes. Nothing about them should be replicated.
Add the -log argument. By default they run with no window
So they're probably all running in the background if you look at task manager
Should get a crash dump or log file somewhere you can look at
If not, launch it via visual studio and see why it crashes
seems okay, just outputting the available device memory I think
so what do you think could be a problem here ?
thirdperson's arms are hidden and modular arms are used instead of them
viewport looks like these
Don't hide the third person arms. Use them for third person characters
hide the first person arms for third person
Doesn't make sense to do it any other way
None of your animations will match up
Hello guys ,
i am attaching one actor to another while spawning on the server side and then giving possesion to player controller , that object is coming under the parent in server side only but not on client side , so do i need to again attach it to that parent on client side ?
Hello, I am still having trouble with what exactly to replicate. I've tried different suggestions the best I could but am still having difficulty getting things to replicate. Or knowing exactly what to replicate and where. I was able to fix an earlier problem where the buttons were affecting both characters.
Issue : When one character clicks on the button, the icon should show up for that player on every client.
Widgets don't network
what you should be replicating is some struct or class CurrentlyCastPrayer or something to that effect, in the pawn
the HUD or widgets aren't doing the prayer, the Pawn is
So I cant replicate anything inside the widget blueprint or the widget itself?
I need to replicate a structure?
I'm still not understanding how to do it if I cant replicate the widget
UI should never be the source of data, just a view into that data
The UI isn't where a spell "comes from"
Is FWorldDelegates::OnPostWorldInitialization delegate safe to use for checking if the menu or game world is being loaded? I am using the World parameter on the delegate itself to get the world name and compare it with my predefined menu and game level names in developers settings to determine which level is being loaded. But from time to time I'm getting a crash from World->GetName() function even though I have a valid check for world. Logs and callstack shows it's caused by GetFName().ToString(), the implementation of UWorld::GetName() with an access violation. Is there anything visible that I'm doing wrong here?
That defiantly makes sense when you put it like that, it just brings the next problem of how to get it to look like that on another client if I don't use the widget as the replicant. I can replicate the image right on the character, but how do I get it to show up above the head with the size and what not in the right place
Everyone knows what prayer is active because it's a replicated repnotify variable on the pawn
onrep -> look at the ActivePrayer -> set widget based on ActivePrayer.IconImage
So Instead of setting the variable on the widget BP, I need to set it on the BP_ThirdPersonCharacter?
Only Actors and ActorComponents can replicate. And only replicated objects can use Replication. Eg: A hud cannot use replication as it is not replicated to other players the same way pawns are (every pawn exists in every game).
The way I get around this is using a helper class (You can use PlayerState, as all players have one)
I have the widget to spawn as an actor component during runtime, but I guess that is not going to count?
So for example if you want a button to appear on everyones hud, your character would ask the helperclass (playerstate) to create a button on everyones hud.
Player -> Helperclass.CreateButton() -> Multicast to all HelperClasses -> Createbutton on player hud
I don't think you can create replicated components. You can have them replicated on replicated actors but I don't think they're as flexible
That's an option
No multicast
Just have a replicated variable in the character or controller
On rep -> update widget
I've read that multicast only works if you dont want to count on it showing up on other peoples things, and should only be used for like emotes
So with this, you use the Helperclass to contact the server, and multicast or netRep to other helperclasses, which would create the widgets on the players. This keeps the net logic all in 1 place when you're using things that can't replicate normally
It's really as simple as replicating a variable
I have name tags for each player
They are represented by a fName, that lives in a character
OnRep -> get widget -> set text
No multicast should even be considered for something like this
Only lead to broken codes
You don't have to ask the server for anything, the server update the variable eventually if it's marked as replicated
The client respond accordingly with OnRep function. In your case just update the widget
Okay, right now I have a HUD widget that updates the ActivePrayerOverhead Widget on button click, Should I use an Event dispatcher to Character, then set the ActivePrayerOverhead Widget from there?
Who's updating what
Do the client have a say on what image it will be?
The tip here is that, the only way for client to talk to server is via server rpc
So (currently) my HUD widget has all the buttons, when a button is clicked, it sends what image should be updated on an event dispatcher to the ActivePrayerOverhead widget.
So if you want to click a button that change the variable for everyone, you need to send server rpc as client. Telling the server to change the variable to the value you send.
If the variable is marked as replicated, the server will then update the variable on all clients
Where client can update with OnRep
I would suggest trying to synchronise some primitive values if you still not sure how replication work
Where do I set the variable as replicated? on HUD widget, ActivePrayerOverhead widget, BP_thirdpersoncharacter
Sync a boolean across all network
If you can't do that, it will be harder to leap
Imo stay away from w.e you are doing. Just get very basic replication work
I have done replication before like this >>
Sync one variable across all network. Allow server and client to modify the value but ensuring that everyone sees the same thing eventually
Because the idea is the same
Can't read that on my phone
Button press > call on server > add static mesh > set static mesh > set is replicated (component to add)
No, hud and widget are local to each machine. Read what adriel says
Your been given the answer tbh
Yeah, im going to try to go back and read a few times,
This is an option btw
If it make sense to put it in the character then so be it
the mesh on a static mesh component isn't replicated
It worked in that code that i posted
ah RIP, it is replicated. the more you know
TObjectPtr<class UStaticMesh> StaticMesh;```
Looks like you know more than me haha XD
well I'm not scrolling through the lore, what is the actual issue
I think im going to try one of the solutions and see what happens
solution to what
Basically Widgets dont replicate, and I need to set the variable not inside the widget
if I understand what everyone is saying properly
yes, widgets don't replicate and only exist clientside
One thing that has happened to me though, is that If I set the widget as a component, instead of creating at runtime,
the widget will replicate client side only
for all characters
maybe I didnt use the word replicate properly in my explanation just now
what does this mean
here
That was an issue when I had the widget as a component instead of adding it at runtime
The logic looks flawed, networking aside.
well widgets shouldn't be responsible for any actual gameplay state, but for it to work over the network, it has to be sent using an actor relevant to each player that needs to see it
It doesn't matter if you add it on run time or add as component
such as a character or player state
How are you updating the image to begin with?
It was setting the widget for both characters when I had it as a component, only on the client that activated it though
Yes but isn't that a bug? Networking aside
Shouldt you have the icon on top of the character you control only.
Yeah it was, I fixed it via adding widget at runtime
I don't think that's a fix, but just a hunch
Might just be saved by a race condition which could happend in the future
Currently its set to HUD widget button pressed > send image via event dispatcher to another widget , then BP_ThirdPersonCharacrter uses that widget
Show this event dispatcher and how it is binded
Not sure how much of the code you want to see, so Im going to send this part >>
Then on the widget that it gets sent to >>
on rep notify >>
Where is this located?
The widget that the HUD sends the image to
IE ActivePrayerOverhead widget
Incorrect way of doing it. Calling rpc in hud or widget will just get dropped
Yeah thats what im gathering from everyone, so my idea was to just send to BP_ThirdPersonCharacter, then update inside the character like what everyone is suggesting
That was just me trying to figure out how to do it, it will get reverted
Well as mentioned you can't call rpc in widget as it is not replicated. You will have to route the rpc call to an actor the client owned.
Player state or player character normally.
Yes Sir, that's what I'm about to try. I was just answering everyone's questions about how its currently setup.
Think about it.
Does it seem more correct that the client says what image it wants to display, or rather, that they say which prayer they want to cast?
I set it to update from the character BP (Executes on Server) and have the variables set to replicate. Then update the widget. Its still not working.
You are making this way more complicated than it has to be