#multiplayer
1 messages · Page 185 of 1
Setting it up, replicating your first property.
Integrating it with cmc and mover
It's honestly barely different until you get to the lower level stuff like serializers and filters
Integrating it with mover 
good joke
In CMC it just works
You know I think very highly of you and your ability to do this!
hahah why
There's actually also a way way bigger difference than this they aren't mentioning here btw
In Iris they made RPCs to become partial net blobs so you can send an absolutely ridiculously sized RPC and it will work fine
cos it just chops it up into little bits, streams it over and pieces the call back together on the other side
One thing I was utilizing to much enjoyment with Iris is sending my voxel chunk updates all as one RPC with a TArray ~16MB in size on average and it just works fine
Incoming 200gb map transfer rpc
Heh
yeah it is actually really cool tho, I didn't benchmark the limits of it so I have absolutely no idea where it becomes too ridiculous, but I didn't hit a limit on it with a fair amount of data
the only thing that sucks about it is that if you want to utilize that feature ur basically on the spot opting out of being able to swap back to the original replication system :(
Is it much work to add everything to iris?
Or has epic done that already with the major gameplay classes?
Hi, im trying to add foot steps to my game. Im doing the whole 9, using an anim notify, added a physical material to my layer info's , line tracing to get the Surface type... all works.
However, im getting a no owning connection for (player) so "ServerPlayFootStep" will not run.. my players are all connected. The only issue I can see is that the other client doesn't know about the footstep since AnimNotifies arent replicated so that would make sense. But im calling the footstep sounds and RPC functions on the player. So that doesn't make any sense either...
whats node should I use instead of get player character if even get owner isn't working?
Prob get owning pawn
or get pawn
That just uses index
and owning pawn has something to do with hud idk
Pretty sure pawn can achieve the same thing you're tryig to do
If you're trying to get the client, you can use the pawn to grab the client of the game.
so I have this grab system and in grabable object I want to cast to character whos holding it
I guess I have to make a work around
I mean doesnt hurt to just try it. If it fails, it fails.
yeah Ive tried already
You should prob set the owner of the grabable object to the character holding it
if you are not already
so you can just cast the grabable object->GetOwner()
Because logically, when you pick up the object, the player is now the owner of that object.
oh I should mention Im doing it in blueprints
A little different but the logic should be the same imo
I would
set the owner of the grabbed object once picked up by the player to the player
use the owner of the grabbed object to cast to the player
do whatever you want after that
https://blueprintue.com/blueprint/_a4whdp1/
https://blueprintue.com/blueprint/xv-kx-o8/
I can't get item info on inventory slot. I'm trying to do this on mp
I feel like I am having a mistake in the way I am thinking of dedicated servers.
Do I even need to setup the dedicated server with steam if my game is on steam? I mean, I don't want the server to show up in a server list, it should just be available in-game for people to join matches etc.
They've done it with most things
just not NPP
Ya
You're going to cry if you look at the net serializers
i hate iris net serializers so fucking much
Lol
I bet you can macro them real good.
My project manager just sneezed. He hates macros with a passion 😄
I followed this tutorial here from epic regarding setting up a dedicated server. Only difference is I am using my game instead haha.
When starting the server, everything looks fine in the logs. Now when trying to connect with clients, it shows me this and then proceeds to open the level locally so it doesn't connect to the server. Anyone has an idea what could be the issue?
What I tried:
- Changing the levels being run by both.
- deactivating firewall
:|
I hate macros too
I agree but i still avoid them like the plague
But If I have to create a crap ton of boilerplate that isn't templateable, I'm not gunna.
I don't mind em for #if UE_BUILD_SHIPPING kinda thing
or just disabling blocks of code
but I hate stuff like UE_KINDA_SMALL_NUMBER
using it for constants is lame
Unless you have super specific edge case needs, you can just have a bool that is open or closed and let the clients animate them.
So i keep struggling, basically I need on each widget of my players to get a struct variable, but I cant set it via event construct, do you have any advice? Basically my blueprint generates a map and creates a struct with a lot of information, and sometimes the struct doeesnt reach the client, how could I work this arround, any help would be really usefull
I just immediately ate my words in #cpp
literally got bad juju'd from dissing on macros
Heyo, weird issue here: I have a replicated actor placed in the level. When I start the game with 2 players as listen server in PIE windows, the actor has authority in BeginPlay on the client. I guess that has something to do with BeginPlay being called on the client before it properly connects or something? Anyone knows what I'm missing here?
If it's placed in world the server has authority on the actor
Do you want the client to connect locally, or are you trying to join your server across the network?
There's a few places you can go wrong, so I just want to make sure what your intention is.
Hi you can make one game in multiplayer pm game Metin2 server windows and apk
I want to make a Metin2 server you can do that? On your computer and on your phone
You mean, similar to it if you were to develop your own version of it?
Or literally a Server for the Game Metin2?
a metin2 server to run on the computer and on the phone
If Metin2 uses UE (which I'm sure it doesn't?), then you'd still need the code to actually build the Server.
You can't just make a random Server for Metin2 with UE.
So my answer would be: No.
who can make a metin2 server to run on the computer and on the phone
The Developers of Metin2?
right now still locally before I try it across the network. So via 127.0.0.1
I used these commands
would work better for my situation:
replicate the door + door movement (so I can use the rotation in between)
the number of player in it (if it's more than 1 than dont change the animation)
You don't need to replicate the door movement and rotation. Once the client knows that the door is open, you can play the animation locally. To avoid some late joiners edge cases, you could replicate last state change time, and compare the time since that to the animation duration, and if it's less than the time since that, you can avoid playing any animation, and snap the door rotation. Make sure to replicate that time on actor creation only using InitialOnly in the RepNotify
Hmm. It might be easier without Steam for local play, even if it could work.
If you want to test your game with Steam outside the editor, then you could just test it non-locally, by yourself if needed.
but I want it to work when you start the animation and then go away end the animation switch between opening to closing smoothly
oh I haven'T even set it up for dedicated servers atm. Do you think that might be the problem?
not trying to connect via steam as in creating an advanced session or so
shall I ?
Oh. I saw it failed to load the Steam subsystem, but it might not interfere with the local connection attempt afterwards.
maybe the problem is that I am not creating a session 🫠
I thought I wouldn't need to because the dedicated server running is basically a session or isn't it
I don't remember if you need to create a session for the loopback address, sorry. I think the Unreal Engine documentation should be enough.
Meaning you don't need to do anything else to connect with your client, other than what it says.
in the docs they use the lyra template though
Idk if they create a session in some other way there
That is true. I can't remember if I got it to work or not from the base template, or if I created sessions using Advanced Sessions.
Either way, you could just try using Advanced Sessions if you would like to. They have an option for LAN, so it should work for local play if you want that option.
I tried this as well that I open the client in main menu like it should be and then on a button press join the server. There it said it can't find main menu after clicking the button although the server isn't in main menu lol
Maybe I really need to create a session via advanced sessions. It has a checkbox with "Dedicated server" when creating one
Yeah, it works for sure. I can help you with the configuration if needed. Sorry for not being much help regarding local play.
When you specify the loopback address in the command-line argument (in the shortcut), it should attempt to connect directly.
I just thought I would follow the docs for now to test it out locally first
Understandable
in the cmd window yea, I did that too. That on the other hand would only be helpful if on startup the player should be connected to the server but usually you wouldn't do that. There is a main menu first and only when they play online they shall connect to the server
that's why I would think that the open level with the ip adress as the level name is a better method for that
and not connecting on launch
For sure, and it's not really secure once you're playing over the internet. It's better to allow Steam's backend to handle the IP address stuff.
I can help you with Advanced Sessions if that's the plugin you want to use. There's other options too.
found some info in their docs but really little
I am already using it
My game was listen server first but switching it to dedicated
Cool. There's basically nothing you need to do with the dedicated server besides setting it up following the Unreal docs.
Everything else can be handled with the plugin, and just making sure open the right ports.
from what I have understood the 7777 port is the default one and should be open?
opening a port could be dangerous
the docs didn't talk about opening it
they assumed it's open I guess
Look, usually I created sessions when I pressed on create match in the main menu
I believe you don't need to open Unreal's default port, but you will have to open some ports for Steam.
now how am I supposed to do this for a dedicated server if he initially is in the game level only
It will open the level when you use the Join Session node.
put the create advanced session node at the end of the game mode and test for if it's the dedicated server before that?
You just have to find the session first.
I have to create it first
You can create dedicated sessions, and look for dedicated sessions.
but where shall I create dedicated sessions I mean
That's up to you. I put it inside my Game Instance, but it might not be the best place for it.
The server now doesn't go the old listen server route of opening it up with a button press in main menu. They initially are on the game level and because only server shall create sessions no one does atm
I would then put it at the end of my game mode i guess
You can open a level on the server directly after creating the session.
But if he isn't on any level he can't run code. So first server needs to open a level and then create a session, no?
The server loads a default level first, yes.
or do you mean using something like a intro level where the server chills and then creates a session from there and opens the game level
Basically
yea, the one I selected as "Server Default Map" in the project settings
Correct
Look maybe I need to approach it differently. I have a main menu where you shall be able to invite friends and start matches together if you want. Does this already need to happen on a dedicated server or should only the actual game level be on a dedicated server?
otherwise I would handle it for the main menu and then create a session or so maybe
or join
Well, as you know, the dedicated server has no GUI.
It doesn't mean you can't launch a dedicated server via. the client though.
correct, but via a button press you could call an event on the pc or so and that then can call the server event that creates the session
Which is one way to indirectly create a UI for the creating servers.
I don't want UI for the servers, the clients handle all this part. That's not a problem
You could invite friends to a lobby level, which is already hosted by the dedicated server.
just the logic of it isn't yet that fixed in my brain how dedicates servers work haha. If they were on a dedicated server already in the main menu then they can't join a game mode like Team Deathmatch for example and instead have to create a session with their dedicated server
my main menu is like a lobby level
like fortnite menu screen where the characters stand there
Sure, that is offline though, I assume. Then you press a button, like "create session".
It is up to you if that session should have a lobby too, or start immediately.
Ohhhh
It needs to be online if players should connect before the match begins obviously.
That is a common way, yeah.
and then takes all players and creates an advanced session with them
Well, they're already inside the Advanced Session, but they will travel to the game map together.
now look here. This is my main menu. When inviting friends they need to be able to join here in the main menu. I assume this can be seen as somehow a lobby, no?
otherwise I could do the route we just discussed if this is too complex
This can be your server lobby for sure.
You need to create the session and make your server go there too.
And then connect your players.
but in games like this usually there are two lobbies. One like this I just screenshotted and the second where you are with your friends + the other players waiting for the start of the game
components should be set to VisibleAnywhere and which other one?
Then you can travel to a new map, and handle any game settings in the game mode, determined by what you select in the lobby.
Oh, yeah, this can be your offline lobby.
Sorry, didn't see the layout properly yet.
if it was offline, you wouldn't be able to invite your friends here, would you?
If you want to view your friends without having joined a server, I guess you could load their Steam IDs as long as you're connected to Steam, without being in a server yet.
Inviting your friends would require you to be connected to an actual server.
So start as listen servers and then go over to dedicated?
ah I see
I just mean, if you want to be able to see your friends without being connected somewhere (well, you're connected to Steam, but not a game server).
Haven't tried that before though.
hmm, yea then the main menu already needs to be on a dedicated server. But how would you then connect the players to a game lobby?
The following is where I don't understand fully how dedicated servers work:
Let's take for 3 friend groups. Each of them are in one of such main menu lobbies on a dedicated server.
Now group 1 starts a match and get's connected to a game lobby waiting for others to join. Now, first, is this on THEIR dedicated server or is it like another one and the initial one from the main menu just sent them there?
Also when the 2nd and 3rd group join the first, do they change dedicated server?
You're confusing me too xD
Beacons.
hahah sorry, it's my 2nd day working on dedicated servers. Before I just read some basic stuff apparently but these questions were never answered xD
Oh yeah, this can be used too.
beacons? What are those
Either way, I think we should clarify some stuff about the connection flow though.
Alright I will write the steps rq, give ma 2 min
Actually, beacons might make it easier to achieve what you want. I'll just let Datura take it from here lol
I don't use beacons personally.
But it can make sense for your lobby system.
Just to clarify one thing though, if you're already connected to a server, you don't need to connect to another one. You could, but it is not necessary.
- Open game
- Spawn in main menu where you shall be able to invite friends
- You can create private custom matches via listen server with friends only or you can join multiplayer vs strangers
- Upon doing the 2nd option in step 3, you get sent to a lobby before starting the match
- upon match start all players in that lobby get sent to a match
- after the match the players land in a lobby again and steps 4 to 6 repeat.
- If you leave with your friends or without you land in main menu again
I got the custom listen server thing in step 3 already finished basically besides the inviting friends part xD
like I have said my game was listen server only before
All of that is the same, except I think you would need to create the session before inviting your friends.
are you using listen server or dedicated server? :3
He is trying to setup dedicated servers now.
working on dedicated server now
first I need to have the flow set on paper before coding it
I need to know where and when who connectes to what server etc.
I would avoid connecting to any dedicated game servers at all until you're actually ready to play the game. They're expensive to run, and you don't need the same level of processing power or engine capabiltiies if you're just trying to get players together before launching the game. You shouldn't need to have a player act as a host before either as you're not really "playing the game".
You likely want to have some kind of backend service that does matchmaking for you, that is event based, essentially, not an actual server server that is running, but instead a system that can communicate data between different players. Epic Online Services for example has a "Lobby" system that you can utilize to help join players together.
https://dev.epicgames.com/documentation/en-us/unreal-engine/lobbies-interface-in-unreal-engine?application_version=5.1
Once you have your "players joined up" together in your Lobby, you'd want to send a request from the lobby "leader" to your backend that manages your dedicated servers, spin one up for you with the desired map & settings and reports it back to your lobby system which then causes your "clients" (currently they're all just standalone instance games) to join to that server.
A lobby is a group of players in a client application with some shared state. The Online Services Lobbies Interface provides an API for creating and man...
I mispoke with Beacons, as those are mostly useful for communicating with a server that is already running.
Oh, didn't know Epic has a lobby system like that.
that's just Online Subsystems and Epic Online Services
just not published yet
They too have a lobby system.
peer-to-peer is listen server based, no?
why wouldn't they, that's what they are for lol
Don't know how you would integrate that with the engine though. Like displaying game settings and all that. Definetely a C++ thing.
No.
if no player acts as a host in the lobby and no dedicated server is utilized as well, how shall they connect even?
oh
true true
Peer-to-Peer is a very specific communication model whereby everyone is responsible for their own state of replicated systems.
A listen server is still a client-server model where the server is the one responsible for the state of replicated systems.
They simply gather in the lobby, but once they're ready, a server is either joined or created.
oh awesome
Without creating a dedicated server first. It's just a peer-to-peer system.
Apparently it's more lightweight like Datura recommended.
so @sinful tree you would say peer-to-peer shall be utilized in main menu here and the lobby as well? Only connect to dedicates server upon game join/creation?
i am indeed an indie developer so if that minimizes cost it's in my interest xD
The way you created the layout, your main menu and lobby is kind of one and the same.
there's no P2P in unreal
It's outside of Unreal, Cat. It's Steam's backend.
same
🤷♂️
You don't really get a choice in the matter unless you're designing your own server system.
You want to utilize Lobby systems to not have the requirement of running a server that is the "host" of the game before the game is actually being played.
If you were to say have a dedicated server launched and had 4 players sitting around waiting on it for hours just chatting for whatever reason, it's a big drain on your money for 0 benefit.
If you were to have one client act as a listen server host to act as your lobby system, every time the leader hops out you get that fun time of "host left the game..." scenario where all the players would be disconnected and have to search for more lobbies, even though they may have had a full one and just the host dropped.
The only solution then is to have a system in which the clients don't technically connect to a server, but just broadcast to a system like Steam saying they want to join a game, and allow Steam to pair up the players and send the messaging indicating who has joined, who left, what the settings for the game are, etc.
Dedicated servers are expensive either way, so it's not a bad idea to consider relying on your community to host servers. Doesn't mean using Steam's matchmaking is a bad idea though.
gamelift and playfab give you the option that it only runs when needed to the amount of money you can pay as well
if no one is playing, you pay 0
if 1000 play you should hopefully earn the money to pay the fees and get yourself a coffee
so trueee
If you plan to pay for servers I would definitely look into Steam's matchmaking, like Datura recommends.
I don't have any extra resources for that, so I just want my players to host xD
the thing with host left the game honestly isn'T that bad if they were chilling in the main menu. But yea I see what you mean by all that
You don't need a listen server lobby either way though.
Just forget about that lol
Well it's an option, but yeah
the peer-to-peer is for lobby and main menu and stuff yea. But dedicated servers are just necessary for competetive multiplayer games
There's been plenty of games that do that - have the one host act as the listen server that you connect to... But yea, as soon as the host leaves it kicks everyone out before even starting the game. Super annoying. >_<
That's true, it will go to a dedicated server eventually
haha yea, no worries just did 😄
I remember the COD zombie mode days
pain.
By backend that manages my dedicated servers you mean gamelift or playfab, correct? I send them a signal or whatever and then it launches and the players join
awesome
Yes.
One last question. Where shall the creation of the session happen in the code @sinful tree ? Before with listen servers I did it when pressing on a button that says something like "create match". Then others join by selecting a lobby and press "join match" . Now the dedicated server doesn't have that step though so shall I put the "create advanced session" node at the end of the game mode begin play?
I have a component attached to an actor, the actor relative transform changes, but the component shouldn't move, how?
Create Match / Join Match buttons > Communicate to Steam Lobby system to either create a lobby or find one.
You don't want the component to move?
that's for the private listen server ones or for the dedicated server ones? For the dedicated server you shouldn't be able to create a match, just join and basically be put into a lobby waiting on it to start. The creation happens on the dedicated server side, but where in the code
no (it's a door)
The dedicated server should create a session automatically on launch, but I'm not sure how it can take settings from somewhere. Does the matchmaking system allow you to configure a server, or simply find an appropriate one?
so the relative rotation changes of the door, but the box collision shouldn't
apparently it does not, otherwise I would be able to connect with my current setup now
if there is no session creation node I don't think it works
Yeah it needs to create a session of course, for playing online.
Also the lobby is handled before you join a session, if you use Steam's matchmaking.
It should most likely
Even for steam I need to put the create session node :/
You could probably use the matchmaking system or even beacons to configure server settings though.
Before connecting anyone.
You're going to allow players to host their own servers (either listen server or dedicated)?
yes, listen for if you just want to play with/against friends
that works so far already. Just besides the inviting friends part, rn they have to find the lobby and join it in the panel
dedicated to online where you also get level XP etc. . So competitive is only dedicated
I know many of my audience will use the private lobby part so I have to do it too
Ok, so then again, you'd "Create" a game, you could specify Open (joins a dedicated server) or Private (they'll be the listen server). In both instances, you can still utilize the Lobby system to pair up players.
When "Joining" you'd have the same thing - either Open or Private.
You'd report to the lobby system which kind of game you're wanting to join - private I'm not sure how you'd filter this.
hmm i see, well for dedicated players shouldn't create either way and not have the option. It shall happen automatically if none are open though
but nevertheless, do dedicated servers need to create the session in the Project code as well or only in backend on gamelift etc.?
like do I need something like a create advanced session node in the game mode begin play?
You technically don't need any sessions. It all depends on your backend and how you want things to work.
what would be the difference with and without? Right now I don'T create a session and it does not work with clients joining. But I don't also have a backend yet and only run the server locally from cmd
like the UE docs say here https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-dedicated-servers-in-unreal-engine?application_version=5.2#server
Set up and run a dedicated server for your project.
maybe I messed something else up in the process for why it does not work if that's supposed to work without creating sessions too, idk
Sessions is part of Online Subsystems, it's a means of communicating data about a game server without requiring you to actually connect to a server.
It's very much similar to a lobby, but for players to find active games.
Lobby = Players find Players
Session = Players find Games
I see, so it's more a thing for listen server games only?
Not necessarily.
I can have a dedicated server running on my computer at home that players could join for example.
I may still want to use sessions for players to be able to find that active game.
But that also means it should work without
It can, but it's usually a bit more difficult.
I don't need players to find specific dedicated server active games
they should just randomly join some
Sessions typically handle NAT punchthrough for example... If you don't know how to set up your firewalls and route network traffic through your router, then you likely would have trouble getting players to connect.
So that's maybe why locally it's not working for me
If you're connecting locally, like all on the same network, then you shouldn't even be using your external IP address.
i deactivated my anti virus firewall for the test but didn't help
I do not. I am using 127.0.0.1
and port 7777
And all running on the same computer?
yes
exactly like in the link here https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-dedicated-servers-in-unreal-engine?application_version=5.2#server
Set up and run a dedicated server for your project.
just with my game and not lyra template
The server runs correctly from what I can tell via the logs
the client on the other hand cannot connect to the server. The server logs don't even notice the client trying to
that's the client logs. After that part he just give sup and opens an own local game
Should be working. Sessions doesn't really have much to do with it.
You would still create a session in the server executable though, no?
Connecting to the loopback address is different though.
You technically don't have to.
Oh
But it's convenient when using Steam, it handles connection to the server for you.
Sessions handle some of the networking stuff that you don't necessarily need to anymore - knowing IP Addresses, ensuring networking is set up correctly, etc.
GameLift itself can handle it without creating sessions for example.
I see
As long as you're not directly connecting, and you're using authenticated users, it's secure enough.
So I guess sessions are convenient for that reason.
So my problem lies somewhere else
great 🫠
I will try it out nevertheless and see if it fixes my problem
if so, then it doesn't have disadvantages using it I guess
alright so creating a session did not solve it 😄
it might be that port 7777 is closed for me though now that I checked online
but this doesn't mean it wouldn't work if I try it with an external IP adress of a different pc, does it?
Port shouldn't matter if it's on the same PC, unless something else is running on 7777 on that same machine.
@ruby lodge The client is not able to connect to the dedicated server?
Yes
I don't think there is something else
What else could be the problem? :/
So I made a door, as a lot of you guys told me to do and for the multiplayer part, I didn't do anything and everything is replicated correctly, I would like to know how?
Here's my BP code for the timeline:
You likely ticked "Component Replicates" on your mesh which can replicate the position/rotation of the component. It is one possible solution, but it is not very network friendly.
Hello everyone. I'm trying to create, find and join sessions using OnlineSessionInterfaceNull (it's just to test stuff) and I can actually do that, everything seems to work, but I'm getting this weird warning and it sounds concerning:
LogOnlineSession: Warning: OSS: Player DESKTOP-7K12KN8-A7597F9A407475C5698866B32B34339F is not part of session (GameSession)
Strangely, if I try to do the same process in an empty project, the warning doesn't show up, but I can't figure out what may be the cause. Does anyone experienced this and can help me understand what's going on? I tried to look around, but there's not much on Google on the topic.
If you need any extra details on the matters, I'll be more than happy to provide them.
nop, nothing is checked
Then this isn't being replicated. What calls "Door Opens" and "Door Closes"?
NotifyActorBeginOverlap
Then it's happening locally on each client.
so this function is like replicating everything?
No
It's not replicating anything. It only happens if the local machine detects an overlap
the character is replicated,. is that why the door replicates too?
The door isn't replicating.
You are moving your character to the door, the local machine detects that the character is there.
This means that it can be out of sync.
If you didn't detect the character at the door, then the local machine wouldn't open the door.
ohhh, that's just a character which is replicated hitting it, not replicated
Is that a good way of doing it?
No
void ADoor::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
if(AGASTrainingCharacter* player = Cast<AGASTrainingCharacter>(OtherActor))
{
DoorOpens();
}
}
```This is what I have rn, what's the correct way of doing it?
If you want the door to be properly replicated, and only when there is a character overlapping it, you would ensure that the overlap is handled only on the server. The server would set a bool that is set up with OnRep. The bool's OnRep when true can trigger the "Play" of the timeline. When set false can trigger the "Reverse" of the timeline.
I want it to work in between too
Then you may want to replicate the rotation value itself and have that OnRep set the rotation of the mesh.
wait so a Server RPC for the timeline? and a OnRep variable for the angle?
A server RPC only if you want the client to tell the server.
If you're using an overlap, the server itself should be able to detect it without a client telling it.
but I think it's from the client
I made this but unsure what to do:
UPROPERTY(ReplicatedUsing=OnRep_Rotation)
FRotator currentRelativeRotation{0,0,0};
UFUNCTION()
void OnRep_Rotation();
When you have replicated actors, like characters, they exist on the server and the client.
So when you move your character on your client, you're also telling the server where you want to move that actor, and that actor position is then replicated to all other clients.
So when you move your character to an overlap area, the server can detect that overlap automatically and replicate any results of that overlap to other clients without the client walking into the overlap telling the server that they walked into that overlap.
You can have things done on the client without the server doing it, but then you're running into a scenario where it can become desynchronized from what the server has.
Should the code in the NotifyActorEndOverlap change?
You can check HasAuthority().
I understand how the networking stuff works but not what the OnRep would do here
If so, then you are executing on the authority (which is usually the server) of replicated actors.
The OnRep is what tells other clients what to move the door to.
so it would be the things that start the timeline, right
If you're replicating the rotation then there's not really a point to starting a timeline on the clients.
Something like this?
// Server
void ADoor::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
AGASTrainingCharacter* player = Cast<AGASTrainingCharacter>(OtherActor);
if(HasAuthority() && player != nullptr)
{
currentRelativeRotation = doorMesh->GetRelativeRotation();
DoorOpens();
}
}
void ADoor::NotifyActorEndOverlap(AActor* OtherActor)
{
Super::NotifyActorEndOverlap(OtherActor);
AGASTrainingCharacter* player = Cast<AGASTrainingCharacter>(OtherActor);
if(HasAuthority() && player != nullptr)
{
currentRelativeRotation = doorMesh->GetRelativeRotation();
DoorCloses();
}
}
// Clients
void ADoor::OnRep_Rotation(bool entered)
{
if(entered == true)
{
DoorOpens();
}
else
{
DoorCloses();
}
}
```This is a listen server game so yes I want the door to animate on the server too
That looks a bit better, yea
it says that they first param must be FRotator
Likely because your variable "Rotation" isn't a bool.
FRotator currentRelativeRotation{0,0,0};
if it would be a bool, then it wouldn't work for in between the start and the end of the timeline I think
If you want to replicate just the start and stop of a timeline, you can do this with a bool. When the bool goes true or false, the timeline can start locally on clients which can play the timeline to show the door being open or closed. It won't be 100% in sync, but the state and timeline woudl ensure that all clients will either see the door opened or closed by the time the timeline finishes playing.
If you want to replicate the position of the rotation, eg. lets say you have a slow moving door (takes like 5 seconds to open or something) and you want it to be more or less in sync on clients, even if they happen to get to the door a little bit later (eg. it entered relevancy later) then you'd need to replicate its rotation, and then have the client set the rotation based on the replicated variable, not use a timeline on the clients.
the timeline is about 0.8 sec
So then you're probably fine using just a bool and a timeline.
Overlap>
Has Authority? YES >>> Set Bool True >> DoorOpens()
However You trigger the close>
Has authority? YES>>> Set Bool False >> DoorCloses()
because the overlap happens on the server and client
No....
The overlap is happening on the server as you're gating the trigger of it using HasAuthority.
The server sets the bool.
The bool replicates to clients.
I meant before (when not using HasAuthority)
lets see if it works!
@sinful tree the server is the only one to see the door rotating...
Is your door set to replicate?
nop, should it be?
It would need to be in order to replicate properties.
so we basically fixed the issue that the door was not replicated, now, it is actually replicated!!!
so the actor has to be set to 'replicates'
Should I also check 'Replicate Movement' ? I dont understand this proprety
No you don't need to do that for this particular object.
Replicating movement means the server will tell the clients where that object is located in the world.
If it's just a placed object, and you don't expect it to move, no need to replicate movement.
ohhhh that's a good point, 'in the world', so if the physic is enabled on an actor, Replicate Movement should be enabled
@sinful tree Thanks a lot, I could not be more happy rn, you saved me a lot of time!!! Thanks ❤️ ❤️ ❤️
Hi! Is it better to replicate 1 variable (float) with the calculations made from the client, or is it better to get an already replicated variable and everyone does the calculations on their end?
Depends on what you're doing and how much you're willing to trust the client to give everyone the right value.
That makes sense. But in terms of performance, it would have to be a trade off between network performance (with more variables being replicated) vs cpu performance (with the calculations being made on everyone else's machine) right?
can you explain this a little more
Depend on how important of that variable, if it just relate to cosmetic then client can do the calculation, otherwise server should do it.
Not really. Security is a bit more of a concern here as depending on what that value is used for, it could potentially break the game and plague it with cheating, thereby ruining the experience and then no one is playing your game. If it's nothing that alters the game at all, then it doesn't really matter if it's calculated on a client first and then sent to everyone else. In terms of trying to optimize it for the network or CPU usage, you'd need to profile first to determine if some performance could be gained, but it's better to first think about how that value interacts with systems to determine whether it should be executed on the client, the server or allow clients to handle the result themselves based on existing data.
I was trying to understand if it was better to trade of cpu performance for network performance, or the other way around. Datura explained it perfectly. But thank you for taking the time!
This makes sense. Thank you!
Thank you! That explains it perfectly.
Question about moving platforms that move from A to B, back to A again until the end of time. Do we do this movement only on the server, and replicate the transform to all clients (on tick)? Or do we just execute the movement on every client individually without replicating the resulting movements?
Is it better to use delays or timers in your blueprints when it comes to multiplayer?
If the actor is replicated, the movement of the platform will be automated replicated. So you just apply a timeline movement on the server, and everything else is handled.
Right gotcha. That sounds good to me
Usually a timer. Delays work for quick testing. But you can't control them or stop them.
Why would you use delay at all?
Because I need a delay in execution of certain functions, basically a waiting timer ⏱️
Are delays as bad as ticks ?
Or is it that in multiplayer the server delay is different from client delay
What are you even talking about
Ticks are never bad. It is neccesary. You use tick when you should use it.
Does the delay run on client side or server side? I’m still new to the whole multiplayer thing so I don’t know much
I don't know how to respond to that confusion but basically in networked game, you want to execute some codes in server and some code in client machines.
You determine what data to exchange and what server send to client. The goal is to try synchronise data so every machine somewhat see the same representation of the game
I was trying to talk about synchronisation since you mentioned it.
You seem to think that players somewhat share the same world or something.
Each player run their own instance of the game. Each executing instruction in their own machine.
Delay node or other nodes will just do its thing when executed in a machine
the delays run on my server 🤡
I need some advice, basically on an actor I am generating the world on an event which is run on server, after it`s generation I want to send to all my players the struct with the generated map so it can create the minimap, but how can I achieve this?
In theory with a Multicast
But what is that world generation based on?
its a procedural generation
In theory you should ensure that the Server only replicates the required info to generate the world locally.
Like, if it's all Seed based, just replicate the seed.
And Actors that require Replication can either be limited to spawn by the Server
basically from the begin start of the actor, goes to an event which is run on server that generates the world, and after I would want to send to both players the struct
Or you check if you can hook them up by stably naming them. Not sure.
RunOnServer?
Like an RPC?
only run on server, the actor is set to reeplicate and it apears to the client too
nope
rpc means to have an event run on server and to call another event multicast, right?
RPC is one of three things. OwninClient to Server, Server to OwningClient or Server to Everyone (that are relevant).
If then yo uare just using HasAuthority on BeginPlay to limit it I guess
But the main answer remains: Replicate the data the client can use to build the world themselves.
And not the finished world
hmm, okay
but why doesn`t it work to notify the second player from the game mode?
i try to use get player controller of index 1 and it fails when trying to cast to the player controller
Idk, timing maybe
The world is a State anyway
So I would have that Actor you have there that generates the world just have a OnRep_GenerationData
Where GenerationData is a Struct with the minimum data required to generate the world
Which would be set to RepNotify
And then use the OnRep to generate the world
And fwiw send an RPC to the Server via the PlayerController to notify when the World is done building.
Is there a way to “emulate” connected controllers without having to plug in physical controllers so that unreal engine can detect them?
Are there any minimal examples for structs NetDeltaSerialize around? I tried looking into FGameplayDebuggerNetPack::NetDeltaSerialize but it's a bit complicated.
Looking for simple examples such as replicating a single property
I recently implemented NetSerialize to replicate raw classes and I'm liking the control it gives, Then I read about NetDeltaSerialize which seems to be even better, Any help / notes / general info is appreciated!
does anyone know if the bp call return to main menu host is seamless or not?
Here is the situation: When a player joins the lobby of my multiplayer game, a team selection widget is displayed. I want to know how to update the session information for players who have not yet joined the session, so they can see the number of people in each team as clients, considering that clients do not have access to the Game Mode and certain classes in multiplayer.
hi anyone know any tutorials for being able to drag other players bodies in a multiplayer system? Or how i can go about doing it?
Should be an un-seamless one
ah I see
is there any way to seamless return to main menu? Im trying to preserve the playerstate (in this case a randomly generated name and bool on the playerstate) but it doesnt' carry over when the return to main menu is called
Disconnections are a hard travel by definition, so no, it's impossible.
The Data is saved on the server's PlayerState, which is kept in the server. So as a client, that will be lost
Find a proper replacement, probably a gameinstance subsystem that manages your saves
There used to be a NetSerialize.h which was the entry point to this realm
It has a lot of 101 on serialization and stuff
Also pinned in this channel is an article that goes over net serializing structs (atomic replication structs something)
I set up steam as well so that steam detects it in the servers tab and the clients don't show the steam warnings anymore. It still doesn't work. Worth noting maybe is that I looked for the 7777 port in powershell after starting the server and it wasn't showing.
Also the server logs say something about a SteamNetDriver
Could it be that the clients can't connect to the dedicated server because of steam or so? Still just running both locally
Are you logged in to Steam while testing? You could try running Steam in offline mode. There's always the chance the SteamNetDriver is messing something up, so you could try using the default net driver and see if it works.
what is the simplest way to make a game playable through lan?
Here is the situation: When a player joins the lobby of my multiplayer game, a team selection widget is displayed. I want to know how to update the session information for players who have not yet joined the session, so they can see the number of people in each team as clients, considering that clients do not have access to the Game Mode and certain classes in multiplayer. How can i do it ?
This statement is confusing. What exactly do you mean when you say " I want to know how to update the session information for players who have not yet joined the session"? By this definition they're not connected to the host yet.
I'm just wondering if you're trying to update literal session information. As in to display on a game search before a user actually joins the lobby or game at all.
If they are already connected and you just need to know how to get data to clients about teams, then you should put this state on the GameState or their PlayerControllers. They will have access to both as clients. Server can set this and let it replicate.
You can update and retrieve the session information, like Authaer suggested.
Alternatively, you could look into UE's online beacons, EOS lobby interface, or Steam matchmaking and lobbies.
i have a pickup in a multiplayer game , that i want when client picked it up it only removed from his world , so other clients can pick it up too, and my logic now i have the result of picking it up is marked as "run in owning client" and i get the resources from the pickup normally and i think this is not possible to destroy a replicated actor so i unticked also the replicate option , and also instead of destroying it i try to call hide actor but it wont get hidden , any advice and tips ? thanks in advance
How many of these pickups are around?
And do they respawn or go back to pickupable?
yes i have a spawner that is on the place of the pickup and when it is picked up it waited 3 seconds then respawn again , but i am thinking to not respawn it to make things easier on replication
more than 20
Start by not thinking about spawning and destroying as what should be done to this thing
if it's a replicated actor it has to stick around forever
I'd just have an array of playerstates or pawns on the thing which stores the players that have recently interacted with it
yes i learnt the hard way XD, so i try to hide actor in client side
not hide actor even, just hide the visuals of it
but you need to store the state somewhere, I'd probably put it in the pickup
just give the pickup an array of pawns or playerstates that have interacted with it, and in the onrep, if LocalPlayerPawn is in the array, hide stuff
also on overlap, check vs the array to know if they should be able to pick it up or not, serverside
if the visuals is just a niagara system component in the actor can i just set it visibility will this work ? cuz now i try to do it and it's not working so maybe am doing something wrong
i loved the idea of the Array seems to work fine with me , the last thing is just correctly hiding it , but thanks untill now it got way better thank i had it before
but you need to have that logic like:
ListOfPlayersIShouldBeInvisibleTo updated -> is LocalPlayer in that list? -> yes -> make self invisible somehow
okay i think i got the idea about this , thanks for helping me
I'm new the replication, working on Wizardcell's Replication guide. I'm having troubles with saving variables from the game insance to the game state. For now, my game instance is setting a random float and my state is casting to the game instance to set the float. The way it currently is, my client will get the server's float when trying to access it from the Game State.
because it's a replicated variable
gamestates float will be servers idea of it
Game state begin play will run on server and client
the servers value will override the clients
since it's replicated
I've then tried to make it a function from the game state, and then add "is local player controller" but it saves the server's function. But maybe because the function is a Run On Server?
What are you trying to do?
do you want servers version of RandomFloat to be what EVERYONE gets when they pull it off GameState?
If yes, then that's what you got.
If no, then make it not replicated.
I'm just trying to put practice into what I read so far, so maybe I'm misunderstanding what the GS is for? I know the GI saves variables between levels. So I want the client and server's game state to just get a copy of their own.
thats fine, just make the variable not replicated
replicated means everyone will eventually get the value that is set on the server
if you want the state of the game for everyone to be that random float is 0.5, then setting it on the server is enough
if you want everyones state of the game to have a different random float, then what you have will work if you make that float not replicated
Oooh. I see. I think I misunderstood. GameState is replicated to everyone, but the variables itself does not need to be replicated\
if I want everyone to have their own values
So if I want to print out everyone's random float, how would I access that? In here (called from the controller), I'm getting all player's, finding their state, and printing it. In a 2 person listen server, the client is just repeating their value twice, and the server is repeating their's twice.
Oh god, my brain is so cooked. I've been saying game state, when I meant Player State. Sorry, I know why you're confused now. I want the Game Instance variables to be copied over to the PLAYER state because these are replicated to all clients (username, levels, w/e).
So right now I have the PLAYER state (via function on controller) get the float from the GI. Now I'm looping from the GAME State to read everyone's values, but they only can read their own. The other shows up as 0.0
I cut this out of the DefaultEngine.ini now and did the steps again to build and cook a dedicated server but now it can't be created at all. The logs when trying are just visible for 1 sec and then many errors appear and it instantly shuts down. Don't even have enough time to screenshot it
I think it's a steam problem because the server is visible under lan servers on steam even but not locally
I tried Lyra and it worked completely fine so I assume it might be that steam handles matchmaking completely themselves and thus I can't join a dedicated server I started locally with the same device through the internal IP
to test this theory out I wanted to cut out the steam stuff out of the DefaultEngine.ini and test it out. It is supposed to work without I guess but maybe the DefaultEngine.ini is messed up without any OnlineSubsystem entry at all
although Lyra also doesn't have one
It's not saving the logs under saved -> logs otherwise I would share
Rather than using "Get PlayerState by Index" the controller should have a PlayerState variable you can directly use to feed into your cast.
When you want to transfer the value, you'll need to RPC to the Server and have an input on that RPC for the value from Game Instance that you want to send to the server.
On the server RPC event, you'd set a replicated variable to the value passed into the RPC.
If you do not mark the variable as replicated, the the value will only be stored on the server. If you mark it as replicated, then all clients will receive the value set by the server.
To read the value, you can get reference to the playerstate and then read the value, but it must be done so after the value has been set.
@sinful tree , Thanks for the tip!! RPCs sound like they make sense in your head when you read about them but in practice... Right now, on the client, doesn't set the variable. I'm assuming beacuse I'm doing the RPC wrong?
You can't pass the game instance through your RPC. The game instance isn't replicated and so would be null on the receiving end. You want to send the value stored in the game instance through the RPC.
This "Random Float" is the thing you want to send in the RPC.
Oooooh haha. Before asking this question, that is what I've been doing, but I just assumed it was a hacky way of doing it
Is this the best way of passing on variables to the Game State? Using the controller as the middle man?
palyer state***
You can use the playerstate itself and not involve the controller at all. What is important is that in order to communicate anything from a client to the server is that you need to use a Run On Server event on a replicated actor that is owned by that client, such as their controller, playerstate, controlled pawn, or any other actor you've created that the client would own, or a replicated component attached to one of these actors. If you need to pass data from the client to the server then you need to include an input on the RPC.
Oooo I understand. So in order for this to work on the client's playerstate itself, it should be like this
But what do you actually want to do? This code doesn't look good. Begin play will get called on both server and client since the player state exist in multiple machines. This code gonna get run multiple times, it's reek
And each machine executing it, will grab their GI to pass the value
Yeah I noticed it ran mulitple times haha. I'm just praticing theory is all. But I guess I was imagining passing on a custom username or their level
If you want to pass client value to server with Gi then filter it so only that player that own the player state to set the value on server
Begin play, add a branch, is locally controller, server rpc send the float
And to confirm, this would be done on the controller then right?
well, thuat's going to fire on the server
Player state should be fine
As ColdSummer pointed out, it would be executed on both the server and client as Begin Play can fire on both. You can use something like this to ensure only the local client or host is executing.
Thanks guys! I think it will take some time to really wrap my head around it, but at the moment, I think I get it now LMAO. '
Is this too much replicated variables? Will my game be buggy when it's going to be bigger size-wise?
// Variables for rotation
UPROPERTY(Replicated, BlueprintReadOnly)
float maxRelativeRotationAngle = 115.f;
UPROPERTY(ReplicatedUsing=OnRep_Rotation)
bool hasEntered = false;
UPROPERTY(Replicated)
int8 numberPlayer = 0;
UFUNCTION()
void OnRep_Rotation();
Btw, the way my door works is that there are 2 components each sides, to easily determine which way to open the door, I also check to see if there's already a player touching the component, if yes then nothing happens, if no then a timeline triggers
Is that a good thing, or could / should it be better? (if yes, any idea?)
tried it now out with a third personal default template. I didn't change anything about the project or any configs whatsoever. Clients do not connect to the server, each are in their own game
logs show no error unlike my project in the message I replied to.
so: Lyra worked completely fine like the docs showed and the default template as well
Managed to make a screenshot here at the moment where I try to start the server and it shows a fatal error and closes instantly
numberPlayer is kind of useless. You're better off referring to players by their PlayerState.
Things won't be buggy due to the number of replicated variables. The problems usually with replication come in with how often they're being updated and how many of them exist in total.
For example, if you had 500 doors in your level, and that one float variable is 4 bytes, if you happened to update all your doors rotation on the same frame, about 2KB of data would need to be sent in that one instant. Not guaranteed to be a problem, but if you happened to be changing the variable 60 times a second (ie. at frame rate) on every single door, then all of a sudden you're trying to send through 120KB/s just for those 500 doors. This is an exaggerated case, as I don't think you'd have 500 doors in your level, nor having them all replicating their data 60 times a second at once, but it's where problems can start to arise with replication if you're going out of bounds of how much data the engine wants to send and receive per second, and then having to manage all the CPU time to handle all that replication as well.
You also do not need to replicate everything. The maxRelativeRotationAngle seems like something that just needs to be set on the door, not replicated. If clients swing their doors wider than what you're expecting, then they'd only be breaking their game as you would only allow the door to be opened to the max on the server.
Does anyone know if Unreal waits until all connected players have loaded into the map before exiting the transition level? E.g. in Valorant, you sit in the transition level until all 10 players have loaded into the map, so every player is ready when you actually go to the map.
you can check that yourself in the gamemode by using the built-in variable: Num Travelling Players
Sure, but afaik Unreal unloads the transition level when the destination level is loaded. I'm wondering if you can make the engine wait until everyone has the destination level loaded to unload the transition level.
Well Valorant would keep the loading screen up purely based on if someone is still travelling (loading the map). You can do that all yourself easily
Valorant keeps all players in the loading screen until everyone else has loaded the map and initialized their game. Sometimes everyone gets stuck in the loading screen, waiting for the last person to load the map, but it ensures that everyone's characters can be initialized together when they finally leave the loading screen. Otherwise, you'd have some players sitting in spawn, waiting for everyone else to load in.
Err, not really.
They're just going to keep the loading screen up while still fully loaded into the new level
^
nothing says you have to pull the loading screen down once you're loaded in. Nor is there anything that says you have to spawn a character immediately.
I think you're talking about manually handling loading screens. I'm referring to the transition level system that Unreal has built-in
I'm aware of what you are talking about.
Does Unreal not unload the transition level automatically when the map is loaded locally?
Sure.
And nothing says you have to do anything specific like spawning a player once you've loaded into the new level.
You're free to wait on everyone at that point.
And valorant was a bad example because they're not using seamless travel either. They use hard loads from matchmaking into a server and back because there's no other possible way to connect to a server.
Are transition levels only used for seamless travel?
Gotcha, thanks!
To join a server, you need to find a session and enter it. Sessions are displayed as cards with information such as the name, playground, and number of players. To display this information on the cards, we retrieve the available sessions and read the information in each session to update the default values of the cards. I want to know how to allow someone who hasn't joined a session to perform a find session and get up-to-date information on the extra settings.
Hey guys, can somebody help me to understand nature of some strange, very consistent crash I experience. I have some things set in my Gamemode which is derived from AGameModeBase. Things like:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Default Effects")
TSubclassOf<UGameplayEffect> AdrenalineRushEffect;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Default Effects")
TSubclassOf<UGameplayEffect> RegenHealthEffect;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Default Effects")
TSubclassOf<UGameplayEffect> RegenManaEffect;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Default Effects")
TSubclassOf<UGameplayEffect> RegenMovementsEffect;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Default Abilities")
TArray<TSubclassOf<UCOR_GameplayAbility>> DefaultGameplayAbilities;
during the first run in editor, everything is always fine.
but if I run POE second time it always crashes on trying to access items in those properties.
And debugger shows some really strange stuff like in screenshots I attached. What can be the nature of this failure? What am I doing so wrong? 🙂
the static is only executed once, don't do that
you are setting this once and never again, each new game is a new world
if you are really terrified of running getworld twice I suggest profiling it or caching it
nono, I used static instead of const. prolly was drunk 🙂
ooh, you mean the word not writing a const, I get you
so bad I spent years programming in javascript 😢
static means different things in different contexts, in general you had better know what you are doing when storing uobject anything in a static and cleaning it up accordingly
there are some things that are nice to store in there that are application-level like cvars though
yeah, okay. thanks 🙂
a static function means it doesn't need a this pointer (it is called just by itself and not on an instance of the class etc)
Hey guys 👋
do we have to multicast destroying of actor on server?
I can see actor being destroyed on listen server however it doesn't propagate to clients 🤔
No, replicated Actors should destroy themselves through replication if the Server destroys them.
Also you seem to use A LOT of RPCs
Server on right 😄
Is the Arrow a replicated Actor?
SetBowStateOnServer is already a ServerRPC, and then in the Interface call "DestroyArrow" you are also performing another ServerRPC.
*cries in pain 😄
You are using too many RPCs
Why is SetBowStartOnServer an RPC anyway? Is that something coming from a KeyPress of the Player?
Okay, but "IsNotAiming" is a state, right?
Why is that a Multicast then? State should be communicated via RepNotify Variables.
And the DestroyArrow call is a Interface why exactly? Is there anything despite the Bow Class that would implement this?
Just generally checking your code a bit, you can ignore it if you don't mind. Just seeing some stuff that doesn't necessarily make sense from a coding standpoint.
Thanks for feedback 🙂 I will look into it 🙂 I’m beginner with MP in unreal 🙂
The only way to do this normally is simply to set data in the session arguments. You can't put a lot of data here though so you either need it very packed or not a lot.
The only other way is with beacons. Which require the possible client to request a beacon with the server. Which allows a very basic networking setup without a map travel in which you cannot replicate data, but you can RPC through the beacon itself. And on connection the server's beacon could send the info. You can do this if you need slightly more realtime, or much larger data sets. IE you can't fit it in the session data or sessions update too slow.
Can I access the players Hud from the Player controller ? I try to acces a refrence from the players hud but it doesnt let me, any ideea why?
Which event are you trying to access it on?
I'm asking because it's important to know how you're trying to access it. An AHUD is created for each local player with a player controller on a machine. And only that machine can access it. Which means that if you're on a Listenserver with two players. If you try to access Player2's HUD on the server, it won't have one. They don't have a local player on the server.
yeah still, I tried on the hud to create the widget blueprint, and with an get owner player controller to store in there its own widget blueprint, it doesnt find it, I don`t know why
Accesed nonee trying to read property, but If i print it in hud it will print the name
You'd need to share the code
here is in the AHUD
here in the player controller when I try to call this function to make it visible it tells me that it canno`t acces that variable
Access none when trying to read property WB_Minimap Node : Set visibility
and it won`t even print the name of the WB_minimap
oh apparently idk how the hud get assignated much later, I had to delay it in order to work, I will work this stuff out
Delays are always bad
You should figure out an even that is clearly calling at the right time
Is there a method to tell if the struct is doing initial replication in NetSerialize or do I have to create my own?
I have a code that needs to run if the struct is replicating for the first time to the target connection
Wouldn’t that just be the first OnRep notification? So in the OnRep for the struct, have a bool that triggers something once.
is the late join option a reliable way to test late joiners?
OnReps are clientside, My issue is on server side
I recently discovered it and so far its seems reliable
just confused cause I use just a multicast to open and close the door but when I add another client they see the correct state
Hmm weird, I believe you have a replicated variable
Do you have anything on beginplay? Maybe you're checking the variable there on client side
thats all i have for the door
I don't think you should replicate the mesh, It could be the reason
Timeline is replicated? 😮
yeah
anyone im gonna make this work with repnotify was just curious
im not sure how I should do it with repnotify tho
I never used timelines, thanks for the info
You could set a timer to set the rotation with interp on rep
I made this door when was a noob so coming back to it lol
so when i join it wouldnt instantly be open but it opens when joins?
It wont instantly open for anyone
I'm not sure how timelines replicate, But I'd keep it if it's doing the job
im not sure either lol I did this door awhile back. im guessing since its running on multicast and running on server too it gets replicated
If i predict item changes in hand, how should i do this ?
initially, i was spawning the actor on server, since im predicting now i should spawn it on client, but how should i replicate on server afterwards ?
should i create a fake item on client, then when server creats it, destory it ?
this works but I have to switch the logic in the rep function sine i guess not replicating fast enough
probably should just use a bool
Wat? Like how
Only things that replicate are variable and RPC
Nodes or timeline don't replicate, I believe that's one hell of confusion
idk theres a replicate option in timeline
Not sure, but that's very strange
Well I guess I might be wrong but I don't see how that work
I always wondered about it but never knew how it works or what it replicates
maybe it replicates the value?
I don't know but for your door, you don't want to multicast at all
im not anymore
Assuming you want all players to see the same state of the door
i was confused because having the timeline replicated allowed new players to see correct state of door
According to docs it replicate play rate, direction, and position so yeah that tracks
so if you wanted everyone to see the same state of a door that’s a way you could do it 🤷♂️
The docs do seem to suggest just cause you can do it doesn’t mean you should
So I would say yeah that’s probably better
Yea in your case using timeline costs more
if i just use a lerp how would I determine which way it should go
cause this really doesnt make sense
if I switch this to the logical way it doesnt work
seems it doesn't replicate fast enough
should just use bool?
What don't replicate fast enough? Normally for rotation or movement, it won't be fast enough. So you want to interpolate the target value in clients.
That's what been done for control rotation, aiming, movement etc
the door status variable in the rep function. I have to switch if its status closed call close door, if status open call open door
I actually haven't worked on a door before (for mp). Would you guys just make it a server authoritative process?
That's kinda my plan
So for clients, I just need to replicate the door rotation instead simulating timeline on their own end.
The maxRelativeRotationAngle is actually to determine the side of the door to rotate (115 or -115), to make sure it rotates correctly as well on the server and the clients
the int numberPlayer is just a number when someone enter a component, it goes up to 1, and when he leaves, goes down to 0
see here
void ADoor::OnFirstComponentBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult &SweepResult)
{
OverlappingServer(OtherActor, true, defaultRelativeRotation);
}
// ---
void ADoor::OnFirstComponentEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
OverlappingServer(OtherActor, false);
}
// ---
void ADoor::OnSecondComponentBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult &SweepResult)
{
OverlappingServer(OtherActor, true, -defaultRelativeRotation);
}
// ---
void ADoor::OnSecondComponentEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
OverlappingServer(OtherActor, false);
}
// --- SERVER Side Logic --- //
void ADoor::OverlappingServer(AActor* OtherActor, bool hasJustBeginOverlapped, float relativeRotationAngle)
{
AGASTrainingCharacter* player = Cast<AGASTrainingCharacter>(OtherActor);
if(HasAuthority() && player != nullptr)
{
// Making the door rotate the right way
if(relativeRotationAngle != 0 && numberPlayer <= 0)
{
maxRelativeRotationAngle = relativeRotationAngle;
}
if(hasJustBeginOverlapped)
{
numberPlayer++;
if(numberPlayer == 1) // Making sure there's no multiple player in the box collision...
{
hasEntered = true;
DoorOpens();
}
}
else
{
numberPlayer--;
if(numberPlayer <= 0) // Making sure there's not a player in the box collision...
{
hasEntered = false;
DoorCloses();
}
}
}
}
/*
** Client Logic for Overlapping
*/
void ADoor::OnRep_Rotation()
{
hasEntered ? DoorOpens() : DoorCloses();
}
@twin juniper Random suggestion: please use IsValid to check UObject pointers.
They can be != Nullptr, yet cause a crash if they are pending kill.
IsValid checks against both.
the player variable?
For example yes
mhm i see
@thin stratus Here are hte screenshots, 1st shows the onrep function + variable being repnotify, 2nd shows part of update lobby ui event and shows playr controller being replicated (it doesnt get to this part it just never calls onrep, 3rd shows where the variable is being changed in 1st place in my gamemode, 4th shows lobby being opened as a listen, 5th shows gamestate rep
lmk if u need any other screenshots
or if anyone wants to help its just repnotify not being called
for sounds, does it matter to call it on the server / clients? Should it just be replicated to all clients AND the server (when using listen server mode)
so multicast is used for effects (particle) and sounds?
mostly yes
second question, when spawning an actor, should it always spawn on the server first and then replicate? (if not, explain )
I got a dash in the CMC that i am doing like this "Velocity = direction * 10000;", this is not frame rate independent what would be my best option here to achieve the same thing and have it be frame rate independent?
yes thats how it works, you can spawn it on the client but the other players wont see it
I would like to know more about Client Prediction, what would happen if someone shoot a bullet on the client? Spawn a dummy one not replicated on the client and then spawn the real one on the server and replicate it the fastest you can to ensure that the shot was real? The client who shot will then see 2 bullets...
did you tested if its frame dependent ?
ye
you are running on tick this code ?
im running on "OnMovementUpdated" of the CMC
In the Unreal Engine design style.
Does it make sense for the PlayerController to directly access the player?
Like if the player has a collider that will tell the controller if it can turn left or right?
Or what's the best way to pass updates about the player's state to the player controller?
why is the ui shown on start of the game, when i have the UI shown only with colission with a capsule
anyone know why my repnotify function isnt bieng called
How do I handle any kind of resource collection over multiplayer with client prediction? So say a player has insane ping, collects 4 coins, updates coin counter locally. The server then registers all that and sends confirmations to the client with their current coin sounter value. So now the player sees their counte go to 4, then to 0, then slowly to 4 again. Should I instead just return a boolean from the server indicating whether the player successfully collected the thing and if no, just deduct it back on the client instead of sending the entire state?
Why does it need to go to 0? Could you do 1) increment count locally (set to 4) 2) send request to server to collect, server sends back count (which should match predicted count)
Has anyone had an issue with PIE with 2 standalone players where player 1 enhanced input action events don't fire? Problem occurs in 5.3.2 and 5.4.1. The input mapping context is being assigned in the player controller begin play
Player sends 4 requests to collect in a short time, has giant ping, by the time first request hits the server they already have local counter at 4. Server sends back count sequentially, player sees their counter go 1->2->3->4
I think
I see. You might need to send an identifier to the server to that way when you get a new count back, you can check if it's "caught up" or if you still need to overlay some predictions on the client side
@Cedric 'eXi' Neukirchen Here are hte
Does anyone know if it's ok to make a static mesh actor start replicating mid gameplay?
Like is unreal engine able to link up the previously unreplicated client instances?
I would like to know more about Client Prediction, what would happen if someone shoot a bullet on the client? Spawn a dummy one not replicated on the client and then spawn the real one on the server and replicate it the fastest you can to ensure that the shot was real? The client who shot will then see 2 bullets...
regarding VEHICLES:
Is possesion what I'm looking for in terms of best practice, or is there some other solution for multiplayer.
ie. what's the best practice to have a character enter / exit vehicles?
can some body help me with a media sound for media player when i try to put that in multiplayer game listen server it doent actualy play it for every body but playing it only for the host or only one person. can somebody tell me how to fix that? thanks
Just put the play sound on the event and multicast that event.
Thats not what that is. Unless your battlefield most games the “bullet” is client only. The hitscan which is invisible is server side
You also probably wouldn’t check this. You would check can the player fire, and then what did they hit and handle that server side
does anyone know why this happens? my server doesnt allow me to take control of the viewport, the input debug window shows that my viewport client mouse capture mode and louse lock mode show up different between the server and client windows, if i try setting input mode as game only then i cant take control of either of my viewports. I am setting the input config on begin play of my character. If i just plugin the Player Controller for the enhanced local input config instead of Controller and casting to Player controller than its the opposite where my server can take control but my client cannot, ive been stuck on this for two weeks and this is the only project this happens in
also learnt. if i click on the server window before the client fully spawns in, then it kicks me out of control for my server window, and allows me to control my client window, could this have something to do with how im spawning my characters in? Or how i am setting my input mapping context? ive tried many methods for initially setting those things and different methods of spawning my players in, which have all worked for me in the past, and i am stumped as to why its not working. Im happy to share some code, hop in a chat, whatevers needed. I just want to figure this out so i can move onto cooler things!
Is this a common thing or more for specific scenarios? I've hundreds of if (SomeUObjectPtr) checks in my game but don't get any crash reports from users that relate to gameplay code like that. Maybe just very rare but good practice? I'm still using UE4 though so maybe things like that happen more in UE5
You should use IsValid with UObject Pointers.
The BP node does the same too.
If you didn't run into any crashes yet then you are maybe lucky or you are cleaning up your pointer variables properly.
But any Pointer to a UObject that is marked for Pending Kill but not yet GCd would crash if accessed.
hey @thin stratus . I found your comments here on this discussion but unfortunately the wiki the guy wrote with the solution was turned off once UE switched to the new page a year or so ago. Do you by any chance remember or have it noted somewhere how to get dedicated servers running with steam? https://forums.unrealengine.com/t/dedicated-server-with-steam-is-a-joke/52620/59
My point with the rotation value is that it doesn't necessarily need to be replicated unless you're dynamically spawning doors. When you place a door in the level you can set that value and not have to replicate it as clients and server would have the same value for that particular door and you shouldn't need to set it dynamically when the overlap occurs as a "swinging" style door should have one of three states: Closed. Open inward. Open Outward. Closed = Rotation 0. Outward = rotation 90 Inward = InwardRotation*-1 as examples --- all this can be pre-defined on the door and you'd use an enumerator to drive the state.
numberPlayer also shouldn't need to be replicated based on the code you've shown. What use is it to replicate that to players if only the server uses it?
and @sinful tree I managed to make sure that steam is the problem here haha. Apparently many people experienced this, it needs a more heavy setup than without
Interesting, I don't really do anything special to the pointers to clean them up, other than properly destroying component pointers after use.
I'm sure I'd have seen more crashes though, been very stable for 1000s of users for months! But I'll likely migrate to IsValid anyway just to be sure, thank you 🙂
I assume it's this: https://unrealcommunity.wiki/using-steamworks-with-ue4-ixya242e
Session system In order to successfully set your game servers, you'll need to follow eXi's wiki page (How_To_Use_Sessions_In_C++) to set a basic session system in C++. @alert warning You need to us...
But this is 4 years old. I wouldn't really bet on that being up to date anymore.
I see, thanks nevertheless
Also just in case I'm misunderstanding, something like this in the Lyra sample would be better to be replaced with IsValid?
if (ALyraPlayerController* LyraPC = GetController<ALyraPlayerController>())
{
if (Pawn->InputComponent != nullptr)
{
InitializePlayerInput(Pawn->InputComponent);
}
}
Or would it be more for pointers that aren't getting created that same frame
Both of those checks are not taking IsPendingKill into account.
And there are times where that is totally fine fwiw.
But you gotta be sure that the UObject really can't be pending kill at that time.
It's safer to just check for it fwiw
Yeah no harm done
The code isn't really accessing either of the pointers
And I assume that InitializePlayerInput might have a chance to check for the flag
I do love the nice clean one liners like
if (AMyThing* Thing = GetMyThing())
{
Thing->DoSomething();
}
but I guess that just changes to
if (AMyThing* Thing = GetMyThing())
{
if (Thing->IsValid())
{
Thing->DoSomething();
}
}
Or whatever the IsValid syntax is (will look it up)
I mean
That's not the right way haha
AMyThing* const Thing = GetMyThing();
if (IsValid(Thing))
{
Thing->DoSomething();
}
Much cleaner ty!
And I guess I can do the first option with correct IsValid syntax if wanting to keep the pointer in the scope of the brackets
Which is partly why I love that way of checking pointers (as you could accidentally use the pointer later on in the func without checking if valid etc.)
I would just not put the pointer into the brackets tbh
You can do that for non-UObject types fwiw
Only time I can think of that is for interfaces but maybe blanking on more types
If you use Thing without checking that it's valid, then that's up to you, as the programmer, to simply fix
Yeah true
TMap<FSomeKey, FSomeStruct> SomeMap;
FSomeStruct* FoundStruct = SomeMap.Find(SomeKey);
Mmmm interesting, haven't dabbled with struct pointers before
TMap generally returns a pointer when calling find, cause it need a way to return a default value for not finding something
TMap<FSomeKey, AActor*> SomeMap;
AActor** FoundActorPtr = SomeMap.Find(SomeKey);
:P
Oooh so you need to dereference the pointer to get a regular pointer there? 👀
pointer to a pointer
Yeah, I imagine peeps that didn't have C in school or at uni or similar wouldn't expect that
But you can endlessly chain pointers fwiw
I did not know this 😄
You can imagine a Pointer being an int Variable.
It has an address in the memory, like any other.
And the value of it is the address of another variable.
So you can point to a pointer that points to a pointer
etc.
There are also some fun little things that you might never have thought about due to TArrays and not using native arrays.
E.g. MyArray[0] is the same as *MyArray.
And MyArray[5] is the same as *(MyArray + 5).
(unless I typod stuff now)
Oh that's really interesting actually
Yeah at Uni we had a task where we had some fake small RAM address table and some fake pointers that were doing stuff like:
ppptr*** = 20;
*(ppptr) + 20;
*(ppptr + 5) - 10;
Etc.
And you had to figure out what cell updates to what.
whenever I feel like I'm actually learning C++ by using Unreal I see something like that 😄
and remember that I'm just doing high level gameplay code
This is actually C even
But doesn't change for C++ fwiw
And yes, UE++ shields you from a lot of stuff
But at the same time, you could do all of that as long as it doesn't have to reach BPs :D
😄 yeah I like that you get as much of both worlds as you want
Hey so I'm having issues properly replicating a crouch, so for the most part it works but in some off cases when I am testing with network emulation it will freak out. By that I mean it rubber bands. Not too sure how to fix it since my other movement works like alt walking and jumping. If I get rid of the capsule height setter it will work fine. So I think it might have to do with the capsule component of my character?
I know I should probably just do repnotify instead of multicast for the crouch but wanted to just figure this issue first
Why exactly are you not just using the Character's build in crouch?
You can still animate the camera to properly interpolate down to the right eye height over time fwiw
Changing the capsule height like this in BP won't ever be rubber band free
That is def the best move sorry for the dumb question lol
I usually do something similar to this for a smooth camera feel when i have done small stuff before but only single player
Yeah that's not gonna do it in BPs for Movement
In C++ you could maybe drive some transitional stance state through the CMCs Tick
But here you are better off just using what CMC offers you and hiding the instant capsule change with the CameraManager
Sounds good then, thanks!
I'll try using the character movement crouch
oh also how would i prevent the camera from being kind of snappy at first since its parented to the capsule?
since its an instant crouch
I have the relative location for the stand and crouch and interpolate but from starting the crouch or uncrouch it kind of snaps with the capsule at first
I assume you'll want to create a PlayerCameraManager class
You can set that on your PlayerController
In there you will find an UpdateCamera (or similar) function you can override
That will allow you to return the Rotation, Location and FOV of the Camera.
By default I would assume you will want to return the CharacterLocation (ViewTarget is usually your character, so you can just use that) and then offset it height-wise by some eye height for standing.
Here you'd also add any kind of transition between eye heights.
But that's a bit more involved so I won't be writing that out here.
It would give you full control over the camera though fwiw
oh i see thanks!
Can anyone offer me some tips on best practice for multiplayer vehicles in terms of possession?
I'm a bit new to multiplayer and have the Advanced Vehicle System (AVS) up and running but now want to learn best practices for possession etc.
Hoping to have dedicated servers.
possession is only way to possess the pawn. You could do some way to fake possession and have the inputs routed to the car or something but seems harder than just possessing it
Thanks for clarifying funkyspunky. I had read something about 'attaching', or both possession AND attaching, so I was confused.
well you can attach the character to the seat of the vehicle depends how far you want to go into it
but to use the input actions on the vehicle youd need to possess. Possess is just telling your player controller to possess the vehicle instead of your humanoid player
I gotcha. I've been overwhelmed with tutorials as it seems there's a number of ways to do it and I'm not sure which is best for multiplayer.
Do you think an approach like this: https://www.youtube.com/watch?v=NbAkRI5EztM is reasonable?
He uses a 'blue print interface' for possession.
Or do you have some other dev you recommend for multiplayer dev?
Hey guys, in today's video, I'm going to be showing you how to enter and exit a car as well as being able to control and drive said car.
Blueprint Interfaces Tutorial: https://youtu.be/m90ZkbtPA9s
#Ue4 #UnrealEngine4 #Ue4Tutorial
00:00 - Intro
00:28 - Overview
01:03 - ...
multiplayer will make it alittle different. I assume you understand multiplayer a bit at least?
the possess node only works on server
I understand the basics. Just looking for keywords to research
Like even a few bullet points of best practice
for my setup I have a base vehicle class and the mesh and vehicle movement component settings are setup on a child class of the base class. All the code is in the base class and child class just for adding different vehicles
i use a bp interface that is run on server to interact with the vehicle passing in the character interacting
Thanks for this overview I appreciate it
id just start with getting it to possess the vehicle and move it around first
its not that hard you just have to possess on the server
I have a simple ragdoll system in my character but on the client side its very laggy and doesnt predict well, obviously i need to implement a network prediction system but i did some research found that i either use gas or mover 2.0 with npp
what would be considered better for latency for this
where do call the function? you'll need to replicate it correctly
Hey, I'm trying to make a power up that when picked up by one client it changes material, yet this should not happen on the other clients which it currently does, any idea how to do this?
You'd need to execute the change of material only on the client that picked it up.
You could use a replicated array of characters or playerstates that have picked up the item. In the OnRep, you'd loop through the array, get their controller from the pawn/character/playerstate reference and check if the controller is valid, if so, check if the controller is locally controlled, if true, then you can change the material as you know that this character is the one being locally controlled, and then break the loop as you shouldn't need to check any more. This array can also be used by the server to know who has or has not picked up the item.
like this, because this is what i have and it doesn't work
oh
You can't RPC to the "owning client" as no client should own this actor.
sorry i'm a bit of a newbie, is there a tutorial or anything for this?
oh
wow that makes sense, what have i been doing, thanks a lot
You want to gate the Overlap with a HasAuthority as well so only the server is the one handling the overlap and replicating the results out, otherwise each client is also handling everything when the overlap occurs on their own end (not replicated, just every client sees and executes the overlap)
thanks, but sorry once again, i'm not quite sure how to do that, is their any tutorials or something like that, somewhere?
Check the pins of this channel. There's the network compendium and a few videos in there that can teach about replication and authority.
Don't cross pins like that
about that i tryed that and it did not work i think that i need that to play the media sound that coms uot of the stream media and make that to play in any of the places like every player i can fro some reson to put the sound to play it in a multicast player can you mabey show me how it should look
Ok i've given it a look, and tryed many things but as i said, i'm inexperienced and couldn't get anything to work. Any ideas.
how can i make that his only happens when the player is overlappin aka in the capsule?
because when i start the game it shows the widget or prints the string
Is there any client-side prediction in AI movement? Is there any important reason to use CMC for AI characters specifically?
Is packaging for the server or for the client inside the editor not the same as building the solution in the IDE and then cooking in the editor seperately?
or does it make a difference to the server/client?
hello guys, where's the best place to keep an array of created teams for the multiplayer match? i'm kinda stuck with this, since i need players to know information about teams, so i've put it into the game state and set it to be replicated, but i've seen some games, like UT have the same array but in game mode, and it's not replicated (there is a team array in game state too, but it's also not replicated)
Im kinda new to this but i would need some help about adding multiplayer feature to my game.Do i need some kind of plugin or some actual code? (C++ or Blueprint).if anyone has like link for some actual good tutorial that they reccommend on how to add multiplayer and how it works would be perfect.
if you want other players to know about the teams use game state. otherwise gamemode, the gamemode doesn't replicate to other clients which is what the game state is for.
yeah, i know that the game mode only exists on the server. i'm kinda fried right now so my writing is bad. but i guess i will stick with the game state. thank you!
This compendium is meant to give you a good start into multiplayer programming for Unreal Engine.
so i tried doing the camera manager and I ended up finding out that it still has an issue snapping with the capsule height when using the built in crouch and uncrouch
I don't necessarily want the camera to be affected by the capsule height when it crouches so that I can smoothly transition it separately
I think it has to do with crouching affecting the Z location
Then you math is wrong though
Assume you have a CharacterLocation and a HalfCapsuleHeight, your EyeHeight will be:
float EyeHeight = CharacterLocation.Z - HalfCapsuleHeight + StandingEyeHeight;
Where StandingEyeHeight is the Distance from the Ground to the Eyes.
Given that your CharacterLocation.Z is always HalfCapsuleHeight away from the floor, it shouldn't matter if you crouch or not.
Could someone please tell me why this is executing only on the server despite being marked to execute on all?
This is insanity, if something its marked to execute on all, isn't it supposed to run on the clients as well?
okay I think I got it thanks
about that i tryed that and it did not work i think that i need that to play the media sound that coms uot of the stream media and make that to play in any of the places like every player i can fro some reson to put the sound to play it in a multicast player can you mabey show me how it should look
also for an FPS camera should i use control rotation for update camera
or the world rotation of it
Hello, I am trying to implement a "GameplayAbility". For this, I have done some tests, but I find myself at an impasse. I have my "Bp_thirdPersonCharacter" that calls a "bp_GameplayAbility", which in turn calls a "spawn system attached (Niagara)" from the "Bp_GameplayAbilityFire" which is a "child" of the "Bp_GameplayAbility". The problem is that when I have to specify the "mesh" of the "attachcomponent" in the "bp_gameplayAbilityFire" (see the screenshot "BP_GameplayAbilityFire.png"), it makes the "systemTemplate" pop on the client if it comes from the server, and vice versa. I found a solution, which is by passing the "mesh" as input in my "custom event" to directly call it in my logic at the level of the "BP_ThirdP". But I would like not to have to specify it. Do you have any solutions? Sorry for long post =/ Thx!
Does the dedicated server need to be registered on a steam master server for a steam game? I don't want the servers to appear in the server browser on steam but I need the peer-to-peer functionality, matchmaking etc.
Hi, I am trying to make a multiplayer (Local Host) open world survival game. How do I go about saving the game? I'm not sure how I should approach saving and loading when it comes to multiple players. How do I save a users data and how do I load the correct data for each specific user during the next session? (Unreal Engine 5)
Hello!
Got everybody bug, when MovementState sometime does not replicate correctly with WorldPartition?
but the bullet which you said is client only, should be replicated to everyone so they are able to see it as well...
"numberPlayer also shouldn't need to be replicated based on the code you've shown. What use is it to replicate that to players if only the server uses it?"
ohh so the variable shouldn't be replicated since it's already kinda server only
Sure you could multicast the effects playing, but rarely is that a gameplay element
Again unless your trying to do what battlefield does, visible bullets are really only a visual effect not determining damage
what if the bullet is an actor?
That doesn’t relate to what I said?
that was my question at first
I mean if your going with some of the popular FPS they don’t even show bullets except for sniper trails
Lot of the times a simple hit scan does the job. Then play whatever flashy effects on the gun you want
ex: valorant, you see a bullet trace when shooting
multicast the gun trail
Trace was the keyword
you see a visual effect of the gun going off
The trace is not what’s doing damage
but that's still a multicast from the server
so everything yhappens on the server
no
Most things do
Especially in an FPS you don’t want everything server side
But stuff like a visual effect, yes the server tells all clients to play the visual effect
But it’s up to the clients to do it assuming that even gets to the clients
and if it doesn’t reach the client oh well
people were talking about smt dummy on the client and then checking if the bullet was real on the server, but that's not what you said
lot of ways to do it, What they probably meant was you spawn a trace or bullet or whatever on the client
the server spawns an invisible trace that detects what it hit, damage ext
that trace is a multicast from the client?
no trace is server side
There's so many different ways to handle projectiles in multiplayer.
The end result is you always want the server being the authority of what is happening or at the very least checking to see if what is happening is ok.
A projectile spawning on the client first is a way to do client prediction so that it feels responsive, otherwise the player has to wait their ping*2 to actually see anything happening, and if you have 100 ping, that can feel pretty slow.
If you want to have a visual effect only play on the client and then have the server actually handle a trace to determine who you hit, that's another way of making it feel responsive without letting the client say that they're hitting someone.
any effects are multicast
not the trace, the visual part
if you want visual to show for everyone yes thats replicated. Basic multiplayer replication
yes this exactly xD
uhh the visual isn't replicated, it would just be a mutlicast
You need to balance responsivness and server authority
I have some ideas for a projectile system, haven't really worked on it much but the general idea is VERY predictable trajectories and only syncing the bare minimum state. Wonder if anyone does that?
Yes the actual visual isnt replicated. I mean telling all the clients to play a visual
I wouldn't know, I haven't even messed with projectile prediction myself, I just constantly keep reading about people trying to figure it out.
@twin juniper
https://snapnet.dev/blog/performing-lag-compensation-in-unreal-engine-5/
This might give you some ideas on ways to have client-side prediction while compensating for latency.
My general idea is that you have no drag, so you can have an exact projectile path solution. The only thing replicated around in the barest sense are the initial conditions (projectile start transform, start velocity) and it simulates the same on all machines. If the firing client gets a hit, they tell the server, which does a sanity check before doing gameplay-important stuff. The impacts and such happen locally wherever. The only thing crossing the network is the initial projectile conditions.
has anyone networked the visual logger? Trying to follow the sea of thieves method of using visual logger but it doesn't seem to be registering both server/client characters
I dont really see how the rotation value would work, (going to - it's value)
like this:
void ADoor::OnRep_Rotation()
{
switch(doorState)
{
case EDoorState::Closed:
DoorCloses();
break;
case EDoorState::OpenInward:
case EDoorState::OpenOutward:
DoorOpens(doorState);
break;
}
}
State allows you to determine what the target rotation should be without having to replicate the rotation.
the only problem is that the minus thing must be done in BP
--
That's what the BP now looks like... Is there a way to now use some of these nodes? (btw, now there's only 1 variable replicated, the state!) @sinful tree
that will look goofy when you close from open reverse
it'll snap to open normal then close
just use the enum to select 1 or -1 for max rotation angle
nop, everything looks perfect
and you can get current door state, don't need to pass it
I would just have 1 event, DoDoorThing
DoDoorThing -> switch on enum -> play or reverse -> select on enum to choose the max angle -> set relative rotation
Does enabling Replicates mean that replicating variables with this function: GetLifetimeReplicatedProps is possible?
Is that what it means and allow?
Replicates just means that it CAN be replicated, right? but doesn't mean it is replicated...
wait, you are right... How would I fix it? (I just realized)
that's opening in 1 direction tho...
for me, the angle could be 110 or -110 ...
It’s similar to what your doing using less nodes as suggested above
You might still wanna include a state though as new players joining/reconnecting won’t see the correct state of the door
well the default is closed
Right so you should combine the two examples given
And use state that way everyone knows what the state of the door is regardless when they enter the game
my question here is how to make it work better
See what Adriel posted
I saw it and tried but didn't understand
1 node, that grabs your enum, switches on it
And based on the switch either plays or reverses
that's my current code:
// --- SERVER Side Logic --- //
void ADoor::OverlappingServer(AActor* OtherActor, bool hasJustBeginOverlapped, bool isInward)
{
AGASTrainingCharacter* player = Cast<AGASTrainingCharacter>(OtherActor);
if(HasAuthority() && player != nullptr)
{
if(hasJustBeginOverlapped) // Entering an Overlap Component
{
numberPlayer++;
if(numberPlayer == 1) // Making sure there's no multiple player in the box collision...
{
doorState = isInward ? EDoorState::OpenInward : EDoorState::OpenOutward;
DoorOpens();
}
}
else // Leaving an Overlap Component
{
numberPlayer--;
if(numberPlayer <= 0) // Making sure there's not a player in the box collision...
{
doorState = EDoorState::Closed;
DoorCloses();
}
}
}
}
/*
** Client Logic for Overlapping
*/
void ADoor::OnRep_Rotation()
{
switch(doorState)
{
case EDoorState::Closed:
DoorCloses();
break;
case EDoorState::OpenInward:
case EDoorState::OpenOutward:
DoorOpens();
break;
}
}
How would the negative angle work here, that's the issue
How are you doing it now
Your rotation nodes are identical
Oh I see your -
I guess you could also replicate an angle 🤷♂️
that's is what I'm trying to avoid, @sinful tree told me it was possible without replicating it...
I’m sure it is
I Mean you could do an enum check to see if it’s the other angle, then a select to multiple it 🤷♂️
Then you don’t need to replicate it
maybe I'd create 1 mroe var that's not replicated, it would be the default rotation angle
UPROPERTY(BlueprintReadWrite)
float maxRelativeRotationAngle = 115.f; // to be set to - or not
const float defaultMaxRelativeRotationAngle = maxRelativeRotationAngle; // default value
```like this
I mean I guess
But why not just a select on your enum
To determine if you need the extra multiply
select where
As an input for your Z rotation
I dont understand what would that do?
A select node selects a variable based on its inputs
So pull off door state and type select
And for the one you need to be -1 just for -1 there
??
Yep there ya go
Now the other inputs in your case would be int
So you could just use a “make literal int” node
And plug those into your three options
Sorry float
Not int
doesn't work
Pic?
Plug the return into the pin where your negative 1 is
Then you just need a single instance of that set rotation