#multiplayer
1 messages · Page 220 of 1
But it shouldn't be a part of the networking if you already are syncing the state that matters (bone hp)
It's just decoration
So can I just not make the GAS variable NOT replicated since it's not needed... This would be a waste of network bandwidth, right?
(I do not need them client side since they are enemies and collisions happen only on the server)
Thank you for taking the time to make that!
I’ll try recreate based off of that. I’ll reply back here when I have an update.
Slight change... move the movement node to its own event and ensure the fail and finish re-call the node. Additionally make sure the "Use Continuous Goal Tracking" checkmark is checked. Without these options the AI will sometimes stop behind the player at some point.
Another thing to add to it would be checking for actual line of sight as you probably want the angel to only stop if something has eyes on it and if they're within a certain distance- right now so long as a character is facing the angel it would be considered being "looked at" regardless of how far away they are.
Instead of a line trace could i just check a distance threshold?
You could, but the angel still wouldn't take walls into consideration.
so my chat system is working, but i also want to log the chats for moderation purposes in the future. i dont have any server architecture yet so i dont have any way to really hold the chats for now, but i want to prepare for the future when i do. is there any way i can sort of simulate saving stuff on the server persistently using the tools i already have, that i can then just access later for actual logging?
the GameModeBase is a persistent server actor right? could i just make an .ini file config category for that and i can serialize the chatlog there, or just put an array there that stores some strings representing the chatlog and then when i have server architecture i can figure what to do with it then?
Just save it to a text file?
Use the GameInstance. The GameMode can change depending on the Level.
Or better yet a GameInstance Subsystem
make it work only for the said server
isnt the game instance created locally each time a new client starts the game?
Correct
Its also created for a Dedicated Server
Not really anything to do with Client/Server
It has the same lifetime as the application itself
Application meaning, the executable
So opening a Dedicated Server, starts a single Gameinstance
For that Dedicated Server
got it
so if the game is always online and players join into it, each player will have their session GameInstance and the server will have one for the entire lifetime of the game? as long as i dont switch servers or anything
just to specify the kind of timespan im referring to. a player usually closes the game after they are done in a few hours
Game instance is created when you run the application and gets terminated when you alt f4 or exit the application.
im just separating it in my mind because a server is on for a lot longer
Switching server is not going to change your GI
It's life time is between when the application is run and when the application is closed
right i know, i meant the server itself switching servers, which involves closing it i assume. im not being technical with my syntax
2 different server, but 1 single .txt.... (that's the problem i think)
When chat msg is committed, if dedicated server -> write the msg to a txt file. Call it a day
That makes no sense
A Server doesnt switch servers
A Server is a server, it cant switch to another server like a player
........! i mean whatever game instance is running on the server, if i have to change the server for some reason that players are using
If players move servers, then they are no longer on that Server....
if you have 2 dedicated server, what do you do to make sure you keep 1 .txt file for all of them? DataBase sharding?
i dont mean the players
You literally said Players
You can do what ever you like. You are in control on where to write and as who.
i said "that players are using"
it doesnt matter. just forget it
i meant connecting to
ofc, but what would be the best approach?
Since you need to make sure they all read the same data from somewhere similar even tho they are different machines
If you want centralized access to the same data across machines, you have no choice but to setup some sort of pipeline for accessing that data.
You cant just magically have a single .txt doc that they all read and write to on a different machine
Just write to the same file. Though I don't know how to do that as newbie. I don't imagine a file can be written when it's currently open by something.
I probably won't use txt at that point
He asked for a temporary solution
Writing to a text doc on the local machine, for each Instance of a Server is pretty much as temp as you can get
Yeah maybe just api call to a data base 🤔 if you want to store every chat msg to a source
yeah right now i just wanna store the data, and later i can send it from the server to whatever database i create
He said in substitute of that
Ahh yeah sorry, I was replying to I need help
what would be the best approach? Or maybe just something that I could read about because i know so little about it, I was thinking of making a data base and use sharding but that might be overkilled
then sharding it?
🤷 whats that got to do with it?
whats sharding
i mean, the DB needs to be on all servers then? no?
No
the database can be on a single server
Dude just start simple
DB are using ssh?
Quick question: What is that node when you in the Get Target Actor function?
Right after the for loop you have GET (is Valid) (Is not valid)
i cant seem to find it.
Just use a standard getter and right click on it and select "Convert to Validated Get"
Is pretty much everything client-side predicted in games like Fortnite nowadays, including things like switching weapons?
I'm assuming that once you have the rails for it (IIRC Fortnite is all GAS-based) there's practically no reason not to execute everything on the client first (IIRC there are some exceptions like playing an enemy player death animation which can be real confusing if rolled back) and let the internals reconciliate if necessary, including things like switching weapons, opening doors, drinking a potion, and other operations that might be not as latency sensitive? You gain the immediacy of the game reacting to you and not having to wait any amount of ms?
there's practically no reason not to execute everything on the client first
This is entirely wrong
There are lots of reasons not to.
Predicting Damage and Hit FX, depending on your game can degrade the play experience.
For example, Damage Numbers
Or health bars
It is a worse experience, to see nice big red numbers, only for the Player you shot to not die, because your hit was rejected.
Seeing a player magically regain health might cause you to think they are cheating
Yeah, totally fair. I called out the death corner case there, I remember hearing about that one exception in particular, makes sense.
Generally speaking, you only want to predict what you need to.
To make the experience feel responsive for Players inputs
A hit result is not an input
Firing a Weapon is an input
The hit is a result of that
Even then, you might choose not to predict because prediction is difficult.
For example.
We dont predict the throwing of projectiles
Like grenades
Players literally dont notice the difference
Especially when you author your animations to assist in hiding the latency
Like the hand throwing anim, covers the location the Grenade will spawn at with enough time that it just looks good enough
Blizzard doesnt predict throwables in OW for example.
They did a talk on Network stuff and they did a whole section on prediction and they mentioned this.
I'm in dilemma with slow moving projectile atm.
Right now, at least visually as I have not work on damagem. The client will spawn the projectile straight away for responsive feedback.
The server version will lag behind so the client may hit something on their machine but in server the projectile may miss.
Let's say I want to favour the Client under certain treshold (75 ms for instance).
In theory, it would be satisfying for the Client as they hit what they hit in their world. But visually the projectile will miss in other people machine but the enemy is hit and play the impact animation despite the projectile not landing on the enemy.
What can I do to address this?
@dark parcel In the UT prediction code, they actually adjust the Client Predicted throwable to match the replicated master from the Server over time.
So eventually, the Prediction matches the Server
👀
This can be helpful in situations like that
Thanks, I would look at it
@fossil spoke all very helpful tips, much appreciated.
150+ for example
Why not just use clientside hit detection with server sanity checks?
My attempt to reconcile makes me think the projectile will just rubberband backward or snap somewhere. I gotta look at the UT code
It feels a lot worse to miss on your screen when it should have hit than to be hit on your screen when it should have missed
Its all tradeoffs
Unfortunately there is only so much we can do
Someone has to lose
And by that I mean, someones experience has to change
Yeah but while it's satisfying for the shooter, other players will see the projectile missed and say. But you didn't even hit it!
Its all about what you are willing to accept on behalf of the players.
Gotta pick one if you have prediction
For the damage, I can do client hit with time stamps. Send to server, rewind in server and check if the hit is valid. But it doesn't address the visual part.
Visuals for who?
Yeah I am fine with the trade off, just want to ask what you guys usses
For the other players
By the time they see it the server should have made a call
We opted not to predict at all.
The only person who can be unwound is the predicting client. They can hit and have the server say "nuh uh"
As far as we have feedback for it, Players dont notice the difference
since they and their actions are in the future WRT everyone else on their end
Even at higher pings
With 200 ms, the fireball will come out 2 seconds after they cast
Kinda feel unacceptable to me
that's 2,000 ms
0o
2 seconds?
Opps
Thats a long time lol
Well RTT of 200 seems noticeable
Thing is, are you expecting a large majority of your player base to be at that high of a ping?
Not really, but it gives me clearer picture when testing
You have to weigh up that against the cost of development and the end result
@sinful tree Dude I appreciate you, made my night. Gonna study this and keep it in mind for next time!!!
Works perfectly!!
Yeah, thx guys. Will look at all the trade off and see what gives the best experience.
You should look into the UT code though, you might be able to apply some interpolation to the slave (predicted) after the master (replicated from Server) comes down.
Which helps line it up after the fact
For smoother hits
While maintaining prediction instant feel
Is the proj available at the launcher?
On github
It will be in AUTProjectile I think
Will also want to look into AUTWeapon
Will do
ofc AWS does it under the hood, though I was wondering how it was done from scratch (like if I would do that in my local area network and all computers could access that DB)
valorant does predicted bullet... so you can use wtv you want depending on your game
I have no idea, Im not a backend/DB expert.
Thats offtopic for here.
can I get a sanity check on my understanding here for multiplayer replication regarding event dispatchers & functions?
You're not able to replicate Event dispatchers, but if you have functions which call those dispatchers, and those are called on the client and/or server (whichever is appropriate), then clients would have those same delegates fire on their game. Right?
If I'm trying to oversimplify or being unclear lemme know just trying to make sure I have it right in my head
Event dispatcher called to object that subscribe to it.
Just think of it this way. In my machine, if I am not subscribed to an event dispatcher, it's not going to be called
First understand that each machine run their own instance of the game and their own script.
Calling event dispatcher will just call it on the machine the code is executed.
Okay, that makes sense. I wanted to make sure I wasn't like.. way off with it 🙂
I mean saying replicate event dispatcher sound very off
I'm sure that gets infinitely more complicated when the world is not in the same state as the default load of the level, but I'm guessing that's a different problem
Every player have their own world
what are Subsystems used for? why use it over the base class?
It's your job to make them communicate in a way that their world seems to be shared
yeah I think the words I was using there are wrong, but in my head I was thinking, regardless of replication, will each instance be able to receive notifies locally
One way I see is encapsulation.
You can just create a subsystem for your specific system or use case.
Like loading screen or save system where you need a GI object like life time.
Instead bloating your main GI you just make a subsystem and place your logic there.
Encapsulation, separation of responsibilities. Ease of access.
There are many reasons.
ah makes sense. for some reason i thought there was one subsystem per system, but this makes more sense
You can make as many as you like
There are also different subsystem types
You should read up on the documentation.
They are very useful
alright i will, thanks
Let's think of the perspective of player 2.
Have player 2 ever bind to the event dispatcher? No? Then when player 2 call the event , it will not execute since the dispatcher never get binded.
Player 2 have no business with other people event dispatcher
It's completely irrelevant, as the player 2 wouldn't know any delegates from other machine.
the docs are rather lacking, like always.
can i assume that all subsystems that inherit from UGameInstanceSubsystem will automatically be initialized without adding it as a member to my GameInstance?
You'd just need to set up a database server that accepts connections on a certain port on a computer and communicate to it what you want to read and write. Different database systems handle it differently, but they're all basically the same in respect to how unreal sees it.
Wdym as a member to your game instance
Docs very clear on how they are initialised and how to get the subsystem
Don't overthink it
alright
i get confused easily, and i do overthink things. ill just trust that it works
I like to think of them a bit like components on the engine level.
if i use the Server UFUNCTION specifier, even if im not RPCing, then it will only be called on server instances of the object right?
ah ROLE_Authority is what i need
@agile meadow very different usage?
yeah found out that doesnt work for this
apparently i need to do a check in ShouldCreateSubsystem
and i just found that there is a nice dedicated macro for that
What are you trying to do
i want to have a server instance log some stuff
clients dont need to use it
seems right
@agile meadow this is for compiling, how are you gonna test in pie?
no idea, thinking about that now. i had to look up what these even were since i dont know much about if/else directives
i should probably find a way to not do it at compilation
You can chose to not include when your game is ready but for testing I wouldn't worry about it.
Just have the server to do the logging with switch has authority branch
The function would be called during the game.
E.g. button press -> route to controller -> server rpc -> get my logger game instance -> write to text file
Nah, and this is just simplifying it. Though I don't think overcomplicating logging is worth the time.
logging inside of unreal?
Ideally you want data base if you plan to keep the data in one place.
yeah thatll be for the future when i actually have a server
and thats where i will also keep my Trie to filter stuff.
do i need to do this? no. it could be fun though, it could be!
Anyone know what happens if you try to spawn a BP actor on the server that isn't loaded on the client? Will it just not spawn on the client?
I think it will automatic load and spawn on client.
Hi. Got question about FastArray (FFastArraySerializer), if you have one FastArray within a FastArray, would it work properly? Or it is not recommended to have FastArray property within FastArray?
I've just encountered were I've got inventory array and within each item want to add attributes tarray as FastArray due to it having a lot of bits in a single net frame.
Was wondering if FastArray within FastArray would perform well.
i wonder whats the nested fast array for
fast arrays have overhead and use more memeory that regular Arrays, so its not always the best solution
Well fast array seemed like a good thing for inventory. And works well, now just want to reduce bits and best lead for the issue is attributes which is a regular array, not fastarray.
So that's why I was wondering if it's okay to do the nested one.
Each item got a different attributes, rather then keeping a list of all the attributes within and managing values, figured to try getting array struct which defines the amount of attributes. Works well, only thing is the bits now.
No it won't work. Fast array only works when it's a member of an object
If you do what you've done there, it'll just serialize as one gigantic blob
Or potentially just like a regular TArray/struct property
You mean with the second TArray, right? Or something else, that I've done extra to make it gigantic blob.
It works, but it’s there a way to choose what loading screen to show? I mean is it possible to choose what loadscreen to show?
FFastArraySerializer can only replicate the array property, and it can only be a member property. It can't be embedded in another struct or another array.
Tl;DR, fast array inside fast array does not work
Okay thank you
hey have you solved this multiplayer problem with World Partition specially in build Version.
in Editor everything works perfect. having same problem here.
World Partition Problem with Multiplayer Build
I'm able to host and join game and everything works perfect in Editor.
but in build Not able to Join WorldPartition Level
And can join all other regular levels works perfect after build also.
Something is going wrong in Build. Specially with World Partition Level...
Hey guys, quick question about using reliable RPCs vs RepNotifies... I have a multiplayer card game where the player has 3 different arrays to describe where their cards are: in the draw pile, their hand, or the discard pile. I was syncing this over the network with RepNotifies, and then when the clients get notified, they are updating a widget that represents their hand accordingly.
The issue is that I want to have animated events for when the player activates a card, or discards a card, or burns a card. I can't really think of a great way to do that only using RepNotifies. Would there be any significant downsides to just making the whole thing work through reliable Multicasts that fire when a user draws a card, plays a card, et cetera?
im conflicted about where to ask this but, (roughly) how can you replicate chaos vehicles and implement client prediction for them?
i just tried multiplayer in the default unreal vehicle project and they dont replicate well by default unless im missing something, alongside having delay on inputs since there appears to be no prediction (aside from movement, movement seems to work fine but turning and even the chassis rotation dont work)
id be also fine with a client-authorative system if that's easier to work with and doesn't have many issues besides cheating risk (game isnt competitive, meant to be played with friends)
it's also worthy to mention i own smooth sync, got it for free years ago on the unreal marketplace lol
so i was wondering if i could just use that instead of making my own client-authorative system if i were to go with the second option
Hey everyone! The replication of the pawn that the client possesses is facing an issue. When the server possesses the pawn and flies, everything replicates correctly for the clients. However, when the client possesses the pawn and starts flying, it only appears to move for the client. For other clients and the server, it stands still. I would appreciate it if someone could help resolve this issue. All necessary checkboxes for movement replication are enabled.
You can do that through a repnotify
First state:
Hand Burn
AB C
2nd State:
Hand Burn
A BC
You see that, you know you burned B out of hand. Play the animation.
You could have parallel multicasts but it is very much doable with repnotify
show your code, also explain how the flying is being done. CMC?
The flight control is taken from the Unreal Flying BP asset, which is available when selecting project creation.
show it
also show how your inputs get to the movement component or whatever is doing the moving
Yeah that won't work networked as it's set up
Currently, only Possess and Unpossess are replicated from the client's side. However, I don't understand how to replicate the movement.
If you wanted to modify that to "work" in a multiplayer context you'd need to make sure your inputs make it to the server.
The server would then do the moving.
It'd look more like this.
Tick -> if has authority -> move based on speed values (same as before)
Input -> run on server event (passing over the input values)
Run on server event -> set the speed values
Alright, I'll give it a try and get back to you.
Basically keep in mind that replication is SERVER TO CLIENTS ONLY
and the only way a client has to talk to the server is through run on server events
?
Something like that?
Thank you so much! Everything works. There's just a 0.2 second delay. Is there any way to fix this?
what is the equivalent node in UE5 to the "get current player ID"?
Hey, thanks for the reply. Yeah in that situation what has happened is pretty clear, but there are other cases like a card being played (thus moved from hand to the discard pile) vs a card moving another card to the discard pile without the user having played it. In cases like that you can't really tell what has happened just through the state of the current lists
You would need a lot of different lists to track all the different things/states that could happen to a card, and it seems messy versus just sending a reliable RPC like DiscardCard(). I guess either way is workable but just finding it hard to reason about the tradeoffs
Get Local Player Controller?
You can have rpcs but don't rely on them for the game state. Using them for cosmetics only is fine.
that gives out an object reference instead of an integer (id). but maybe i can make it work.
That tutorial looks sus, what are you actually trying to do?
prevent a multicast from firing on the client that basically triggered it. as some actions i want to perform directly without the server/latency, and just replicate it to others
You could use IsLocallyControlled
What's the context of this code, the pawn?
a character, but oh, is it really that simple? i spent 2 hours on google
Is it bug that the onbreakevent of a constraint is not firing reliably? I have seen two mentions on the forum. So looks like I am not the only one. I'm on 5.4. Pretty annoying to work around this in multiplayer.
Are RPCs marked as reliable the only ones guaranteed to eventually complete when there's packet loss? Is it fair to say that regular property replication makes no such guarantees?
regular property replication will complete, eventually
you aren't guaranteed to get intermediate states
If it's state, use property replication
I have a repnotify variable in blueprint. Its function doesnt trigger at player connection, is it normal?
I mean, it triggers only if server changes its value. Doesnt it also supposed to trigger at initial?
has it ever been changed before player connects?
No, should it be?
Oh, it triggers if i change value once before connection
Cant i make it trigger initial even if server dont change the value?
just do the same thing at BeginPlay maybe
What's it replicating, if nothing has changed though?
if it's some sort of setup code
I did it now, thankss
Yeah sounds like a beginplay/construction script type of thing
Note also that sometimes repnotify fires before beginplay
Maybe the paint will start to drip..
Hi! I have a question.
How can I achieve to have the deck of the cards to stay like the selected box in every instance of the clients? Like, I want every client to be in front of the deck, not in the right, etc.
I thought about calling in the StartGame function of my game from the GameMode to the function of my PlayerController:
void ATPlayerController::AdjustDeckAndPilePosition(ATDeck* Deck, ATDiscardPile* DiscardPile)
{
FVector PlayerLocation = GetPawn()->GetActorLocation();
FVector DeckOffset = FVector(-150, -10, 12.7);
FVector DiscardPileOffset = FVector(-150, 10, 12.7);
FVector DeckLocation = PlayerLocation + DeckOffset;
FVector DiscardPileLocation = PlayerLocation + DiscardPileOffset;
Deck->SetActorLocation(DeckLocation);
DiscardPile->SetActorLocation(DiscardPileLocation);
}
But this changes the deck in all instances. I call it 4 times (for each player controller) and it ends with the last position of the deck. I have only one deck spawned in the gamemode so I don't know how to keep the decks synced in the game with the same cards, but with a differente location and rotation
so whenever i attach too my vehicle whilst walking, the character instead of snapping to socket rotation maintains its world rotation, if i stand still and attach it works just fine. any idea how i can fix this?
Why not have the deck as an actor and place it once? If there's additional information about it, you could replicate it through the gamestate (like the amount of cards left in the deck?)
when im only one player, my textbox works perfectly, but multiple PIEs makes it act incredibly odd. if im on standalone, both clients will work. if i use either of the server options (Play as Client or Play as Listen Server) then this bug happens, but only when i have 2 open
any thoughts?
im getting multiple different versions of my textbox or something, and they interact in different ways
Yea it looks like more than one copy of the UI is being created and added to the screen.
if it were a replication issue then it would happen when i only had one client right?
UI and client interactions with it have nothing to do with replication usually.
On what event and in what class are you creating the UI and adding it to the viewport?
Isn't it what I'm doing? Like, I'm not sure I understand you.
I have this function that spawns the Deck:
void ATGameMode::StartGame()
{
TObjectPtr<ATDeck> Deck = GetWorld()->SpawnActor<ATDeck>(DeckClass, DeckSpawnTransform);
Deck->InitializeDeck();
TObjectPtr<ATDiscardPile> DiscardPile = GetWorld()->SpawnActor<ATDiscardPile>(DiscardPileClass, DiscardPileSpawnTransform);
if (TObjectPtr<ATGameState> TGameState = Cast<ATGameState>(GameState)) {
for (TObjectPtr<ATPlayerController> PlayerController : TGameState->GetPlayerControllers()) {
if (TObjectPtr<UTHandComponent> HandComp = PlayerController->FindComponentByClass<UTHandComponent>()) {
HandComp->DealInitialCards(Deck);
HandComp->SetDiscardPile(DiscardPile);
TGameState->SetGameModeState(EGameModeState::DealingCards);
PlayerController->AdjustDeckAndPilePosition(Deck, DiscardPile);
}
}
}
}
In here then I call for every player controller the AdjustDeckAndPilePosition(Deck, DiscardPile);
I place the actor once don't I?
in my default Character pawn class
this is on begin play
which, i remember being told to not do that earlier. i can move it to the HUD
Is there a single deck for all players or does each player have their own deck?
it's a single deck for all players that I want to change in every client only the position (visually only) but the deck to be the same, like, only one with the cards, etc.
ok after a bit of finagling i initialized my UI in my HUD, and managed to still make all the stuff in my character work. now the problem doesnt seem to be showing up anymore
kinda weird it works like that
idk why
Understood, thanks for the tips.
Trying to figure out the patterns for the game so that property replication that's delayed or out of order in a lossy environment doesn't permanently bork the game state, but that it eventually heals once all of the requests have made it. The out-of-order part is tricky.
make sure its location is NOT replicated
It shouldn't bork the game state
it IS the game state
There's state that reacts to state, e.g. a certain property being replicated triggers things to be made visible/invisible on the client that received the replication, this visibility state not being itself replicated and being custom to who you are in the game, stuff like that. Second order state of sorts.
how can I achieve that? isn't the location replicated by default when I apply bReplicates = true?
Should be handled by bReplicateMovement
If it's 2nd order state it should just be a function of the replicated state
if it's path dependent then thats different
You are typically best off making as much as can be stateful and driven by state, the rest is where the difficulty lies, stuff like smooth movement etc
I have deactivated the Replicated Movement but it stills updates the location
Why does the game mode care about the deck position
anyone ever had this before?
deck and pile position can just be done on client
I've spawned the deck in the game mode, then in the game mode I called the PlayerController->AdjustDeckAndPilePosition(Deck, DiscardPile);
to adjust it
why though
What is deck and pile position a function of, the game phase?
either playing or not
I've done it there because it's where I spawn the deck
don't know where I should do it if it's not there
What if the RPC goes across the wire before the deck shows up?
It's just race conditions all over the place. If the deck is a replicated actor let it just set its position based on locally controlled pawn position on begin play
now workssss!! thanks a lot.
I'm new to multiplayer and I read the basis and see examples but I'm not familiarized with the structure sometimes and I do messy things while I'm practicing. thanks for enlighten me with the thinking :)
hey so i have an actor i want to spawn from a server call which is essentially a pickup that you can drop onto the map but
What I noticed was that when a client drops it, the values i pass through don't stay but exist on the server
anyone know why on linux unreal engine i receive the packets from my udp server but on windows i dont. on both platforms wireshark shows the packets but the game doesnt see them on windows only.
This is bugging the crud out of me
It’s a custom tcp/udp server client system by the way does unreal use winsock or winsock2?
going back to linux, this was the fix "if(SizeUdp > 0 || UdpSocket->HasPendingData(SizeUdp))"
That made it work under windows instead of using Peek I added HasPendingData and it said okay let’s go
@bleak lily code?
Hello, can someone guide me on how to do the replay feature in a multiplayer context without needing the client to exit the server's session?
What do you guys think of Druidmechanics multiplayer c++ course?
what happens if a client calls a client rpc? just a regular function?
Other ways for Replication are so-called “RPC”s. Short form for “Remote Procedure Call”.
Oh nobody else maybe interested in this but I made an Inventory in NPP and it actually works.. just to learn it's a bit useless practically.
Initial Inventory trading system with responsive Multiplayer transactions.
It's real time but a bit silly practically.
Problem is that NPPs inner State structure isn't really the most optimized one for Inventories.
i made a custom structure seems to work fine but the issue is just having to tick anything with inventory, but it's very fast for the user
im testing voicechat with loopback by Launching the game and this is the sound i get, i have no idea what could be causing this, does anyone do?
(you can hear my friend on discord, but the glithced sound is supposed my voice loopback)
There should be a pin in this channel if you scroll a bit. Doubt a lot of actually done this.
Like this means all my shops and chests and everything will be ticking in their own simulations was my only issue but good practice 'cos now i know how to do an Ability component.
You didn't change the way NPP works though and that's not really suitable for Inventories.
I did a custom structure which was tricky I had to add things like overload operators etc. and was surprised it worked in the end. I didn't have to change NPP, it wasn't too bad. I didn't face any issues in how it handles the data. Just having all chests ticking is not ideal practically.
Also transactions between 2 Simulations or even 2 Instances of a Simulation are pretty annoying with base-NPP, as each Instance runs its SimTick and then "shuts off" and can only be altered by writing to the pending state.
Oh I totally cheated using RPCs for the transactions so i'ts a bit silly for this reason too.
I'm not saying you can't make it work. I'm saying it's unreasonable. Bandwidth and CPU costs are probably too high for this to make sense.
Yeah then you are already somewhat violating the whole setup
Yeah its' stupid but now I can do abilities on this easily. It's not suitable for Inventory at all.
Honestly they're good but very long and there's other courses pre-requisite to this based on your existing C++ knowledge like 2 atleast, his C++ for Gamedev course and UE5 Ultimate C++ Developer course which is 60 hours + 75 hours = 135 hours to do.
Also then you may decide to use Gas Instead an that's another 70 hours course on top of all this or you can do that instead of the MP course.
And to be honest I've seen many people who do courses do not make actual games 'cos life is too short and they're not full games as such so practically there's many missing things in courses when it comes to larger games. I did the UE5 C++ Developer course and a bit of the MP course ages ago.
So it's unavoidable to do youtube tutorials or courses or 3 hour long unreal streams but you gotta spend a good % of your time developing really.
Violated is a strong word.. I just used an RPC to write to the pending state. I totally agree it's silly in terms of overhead.
Do the math.. 200 hours of courses would take atleast 400 hours to do.. then 400 / 8 = 50 days = 10 weeks full time employment.. otherwise make a full blueprint game in 10 weeks and release. Or wait for the next course after this.. Course developers have nothing better to do so there's too many to do..
I mean, you are supposed to use the ProduceInput method, which is your RPC, to do this. By using your own RPC you skip the whole InputBuffer.
I did use ProduceInput but fed it using an RPC like instead of pressing a button to move the RPC loads that data which ProduceInput picks up..
I didn't violate any rules but it's very silly.. I used 2 RPCs to make this work but it works the same way as any NPP actions do, it thinks the client is adding inventory etc. instead of initiating a move for example. It was just for learning I do not recommend this.
thank you for the advice, i have tried making projects not finished though. But i want to watch some courses, finish tom loomans course, then this multiplayer c++ course by stephen, and learn something about gas, (shouldnt i learn something about that if i want to make a shooter game) and then make my dream project.
Why not just use ProductInput in the first place? It's an RPC already.
Tom Looman's new or old course? The new one is very expensive. Your plan is really long term Tom Loomans course (40 hours) + DruidMechanics Unreal Multiplayer (65 Hours) + DruidMechanics Gas Course (106 hours) = 211 Hours for these 3 courses.
I have 82 courses on Udemy right now which is pretty hard to do practically but many are blender couress
i have already gone through some of the course, and its the "Professional Game Development in C++ and Unreal Engine" course
wow thats alot 😄
i have some ue and zbrush courses
Tom Looman course is $350 full price.. way too expensive.
i found that alot of the problems i get in blender i could search up, and i also have a freind in with many years of experience, and has industry freinds
yea it was expensive, but i couldnt resist, hes very good.
also i have a small job on the side of my school
oh and i got it cheaper actually
Well if you pay that much atleast it gives you incentive to complete the course.. honesty I do not htink it matters which course or tutorials you do as long as you have some sort of a foundation and start making things at some stage to solve problems yourself.
i got a discount from a link
of course
I only buy Udemy courses when they're $10
lol, i do that too, i bought stephens course on discount
only 14 dollars
Those courses are totally worth it if someone bothers to do them.. I just did the normal C++ developer course and I do multiplayer already 'cos I taught myself. As long as you do some sort of foundation then it becomes self learning after this. Initially it's very confusing so courses are good to do.
You do not need all those courses to make your dream game and even if you do all of htem there's many missing things you'll have to figure out or learn elsewhere. However once you get that confidence and know where to find information and how to solve problems then you're on your way and can just focus on your game.. do not need all those courses really.
okay, i will rember that
im also getting desperate to start the project
but im new to multiplayer sooo
there still some way to go
In the end I own 82 courses on Udemy but I spend most of my time doing videos in Russian translated to English 'cos nobody else posts those things. Just start your project now and do courses on the side to upskill or well keep your project ticking along slowly and then just do that most of the time. Also then you can implement things which you learn but courses are a bit bad for this 'cos its better to just get the course done with than to improvise too much.
For courses you have to set aside whole months.. this is the issue.. I was doing blueprints multiplayer initially which was kind of limited so I did one of his C++ courses and this took me more than a month and then I just focussed on my game full time after this.
Most of the things I need aren't even in courses or those are outdated 'cos Epic keeps releasing new features daily and some of those courses are in UE4 even and some of these technologies will change drastically like Gas will probably be obsolete 'cos it's bloated and there should be better ways.
alot of advice, thank you 🙂
Because I didn't know this.
Is your goal to learn NPP/inventory, or to produce a predicted inventory system
not sure if predicting inventory transactions even needed NPP
Well it was for learning and it works but this wasn't such a great idea 'cos everything must Tick and I ended up having to do RPCs anyways. I could use this in real life by just making things tick during the transactions but it's just overengineering. I can probably get the same results without prediction. Oh 🤦♂️ I can't just disable ticking because then the whole simulation falls apart so it's totally useless in the end.
Yeah it doesn't. Predicting inventory is silly 'cos everything must tick. It was totally redundant in the end but it does work smoothly as I had imagined.
hey there im trying to hook up a way so when anybody joins a multiplayer lobby they get given a set game mode on random
so far i got this
this has some oddities. a replicated PlayerList but it's a list of controllers that only exist on the owning client or server anyway?
is this specifically a lobby "gamemode"?
also a game mode is just for the server and you have one game mode at a time
I was basically just seeing if it was worth recommending arc inventory to them or not 😄
I have the start game function of my card game to spawn the deck and the discard pile. it initializes the deck and I don't know if it's also the right place to deal the initial cards.
void ATGameMode::StartGame()
{
TObjectPtr<ATDiscardPile> DiscardPile = GetWorld()->SpawnActor<ATDiscardPile>(DiscardPileClass, DiscardPileSpawnTransform);
TObjectPtr<ATDeck> Deck = GetWorld()->SpawnActor<ATDeck>(DeckClass, DeckSpawnTransform);
Deck->InitializeDeck();
if (TObjectPtr<ATGameState> TGameState = Cast<ATGameState>(GameState)) {
for (TObjectPtr<APlayerController> PlayerController : TGameState->GetPlayerControllers())
Deck->DealInitialCards(PlayerController);
TGameState->SetGameModeState(EGameModeState::DealingCards);
}
}
Then the call from the Deck->DealInitialCards() executes this:
void ATDeck::DealInitialCards(const TObjectPtr<APlayerController>& PlayerController)
{
if (TObjectPtr<UTHandComponent> HandComponent = PlayerController->FindComponentByClass<UTHandComponent>())
HandComponent->DealInitialCards(this);
}
The problem that I have is that instead of dealing the cards from the client representation of the deck, it deals the cards from the server location of the deck. I don't quite understand how to make it work.
yeah don't use TObjectPtr for local variables
that's just for UPROPERTY fields
though I'm not really sure what you mean
like the "representation" of anything is up to you on the client really
how should i set it up
im basically making a prison escape multiplayer and im wanting two roles guard and prisoner and im using seperate controllers for each
like, in the server I spawn the deck, and in the clients I move the location to each one see it facing it. but when I execute the HandComponent->DealInitialCards(this);, the deck location it's the same for the 4 (I assume that it's getting the location from the server one). I need to deal the cards based on the client view of the deck
as a parameter of a method should I use it if it's not a UFUNCTION or should I use the raw pointer?
raw pointer for everything but UPROPERTY fields
and yeah I think this is a bit specific to your game. not really having any luck decyphering what the actual issue is
well, thanks anyways :) I'll try to figure how to make it work
Probably just decide this in the gamemode who's who and then spawn that actor. Getallcontrollers, then spawn random from the pawnclasses.
this is what i have now i just cant get it to set the controller class for that player
wait wrong one
this is the correct one
You don't set the playercontroller class, the pawn / character class is guard or prisoner, this is what you have to spawn or possess.. you just need to get all the controllers in advance and a for loop, you can have more types of pawns as well.
i use two different player controllers
These are pretty hard to see without a magnifying glass but you seem to be not getting all controllers or anything like this.
i have something working
Yeah actually this should be okay, you can zoom before screenshots to get better answers. You can't expect people to actually see this.
The scrollwheel has been invented
Aren't you already doing this? Save the role on the controller maybe instead of hte gamemode.
I still ahven't seen your screenshots properly but you seem to be on the right track. You got the controller, then set the type.. now you have to possess or spawn that which doesn't seem to be in your screenshots so I can't say.
i have it spawning in the pawn now but it only spawns in the one even tho they are both there and i no longer have animations but the animbp is still set up
okay so it own picking 1 role i fixed that out
it just now isnt doing animations even tho they are connected to the player
It's not really visible to be honest can you actually read the text inside the purple boxes?
You should honestly know how to debug this easily before attempting multiplayer 'cos you're gonna hit many roadblocks in this.
You can just print the role or whatever and this has nothing to do with animations so that's not related to your issue. Just check those classes are actually assigned based on what those nodes say by doing print text if nothing else.
animations is fixed
i think i get it working now let me do a check
the only issue i have now is that its showing both of the widgets on both screens i only want it one per person not twice
me very stupid lol this is my first multiplayer game
i may of figured out why ts doing it
UI should be on client only. If you're doing any UI things on the server then put that on client.
i have got that fixed
the only thing i want to also set up is that there is always atleast one prisoner one guard
Place both in the scene in advance and then possess later and the other one will be AI.
the last thing i wanna do is keep the controllers equal in the server so say i have 4 players in the lobby i have two of each controller
I'll try to simplify my question to see if with that someone can help me:
I want to know the client location of an actor, instead of the server location. anyone knows how can I achieve that?
Just log the location as client?
use the switch has authority to filter who can run what
Authority = Server (for the most part)
Remote = Client
If you want to know the location of a replicated actor on the client then you can simply get the location while running on the client.
If you want to know the location of a replicated actor on the client while executing on the server then you'd have to rely on the client to tell the server what the location is unless it is also replicating its location in which case you'd normally rely on the server's value.
If this is still in regards to your deck positioning, you probably shouldn't be utilizing the location this way in the first place. Card positions are normally something that can be simulated and the positioning of the actors can be done completely client side where the server just indicates what changes are coming through and clients can figure out what it would look like on their own end.
how should I be doing it instead? like, I don't get how to simulate the positioning of actors.
In my game mode I just wanted to call to the function of the deck that deals the inital cards to all the players, but the location of the deck where the cards should start doing the movement it's the same for the 4 clients even thought the 4 clients have different deck locations. I guess it's because it's getting the server location, but I don't know how can I get the local one.
In the video (if you look the 3rd client it's the most obvious one) it spawns on the location of the server one
Uncheck replicate movement on the actor. On Begin Play of that actor, set its location where you would like it to be based on some information about the current instance the code is executing on since Begin Play fires on all instances when that actor starts existing.
that's what I done with the deck and that's what make the deck work and be in different places for the clients (the all have it on the second column of the cards)
but the problem it's on where the cards start to move.
the function I use to move the cards do this
GetWorld()->GetTimerManager().SetTimer(MoveCardTimerHandle, [this, TargetLocation]() {
FVector CurrentLocation = GetActorLocation();
FVector NewLocation = FMath::VInterpTo(CurrentLocation, TargetLocation, 0.1f, 0.1f);
SetActorLocation(NewLocation);
if (FVector::Dist(NewLocation, TargetLocation) < 1.f) {
GetWorld()->GetTimerManager().ClearTimer(MoveCardTimerHandle);
}
}, 0.01f, true);
it gets the currentlocation of the card and it's here when the code returns the server location instead of the one of the clients
Are these cards that you're spawning replicated?
yes
Do they have movement replicated?
nope
Are you moving them on begin play to the desired start location on each client before running your timer?
no. but the cards are at 0.f attached to the deck
so whenever the decks move cards should follow and have the same location isn't it?
The original location of the cards would likely be wherever the server thinks it would be rather than where the clients have the deck.
You can check this by logging the location on begin play to verify.
okeyyy, yeah. I spawned 2 cards to debug and all cards in the 8 logs that returned from all clients, etc, have the same location as the server deck (I expressed myself very bad asjdahdj)
I called this code on the GameMode when I spawned the Deck
void ATDeck::InitializeDeck()
{
Cards.Reserve(52);
// Create cards and set textures
for (int8 i = 0; i < Cards.Num(); i++) {
ATCard* NewCard = GetWorld()->SpawnActor<ATCard>(CardClass);
// Attach cards to deck
for (int8 i = 0; i < Cards.Num(); i++) {
ATCard& Card = *Cards[i];
Card.AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);
Card.SetActorRelativeLocation(FVector(0.0f, 0.0f, 0.2f * i));
Card.SetActorRelativeRotation(FRotator(0.f, 0.f, 180.f));
}
}
there I attached the cards and set the relative location. so, on the begin play, which location should I give to the cards? like, every card would have a different Z
anyone here ever used the ProjectileMovementComponent's interpolation? im struggling to get it to function at all. the root component is getting moved fine, but the interpolated visual isn't moving
In your projectile actor
In BeginPlay call
ProjectileMovementComponent->SetInterpolatedComponent(VisualRootComponent);
Override the actor's PostNetReceiveLocationAndRotation and call
if (GetLocalRole() != ROLE_Authority)
{
const FRepMovement& LocalRepMovement = GetReplicatedMovement();
const FVector NewLocation = FRepMovement::RebaseOntoLocalOrigin(LocalRepMovement.Location, this);
ProjectileMovementComponent->MoveInterpolationTarget(NewLocation, LocalRepMovement.Rotation);
}
been doing this, i think i figured out what the problem was
my static mesh's root wasn't being set for whatever reason
since you are talking about the PMC, is there a reason why when someone has above 50 pings, the ProjectMovementComponent sometimes just doesn't activate when it should and then randomly all of the ProjectileMovementComponent just activate at the same time?
i havent seen that and i've been testing with extremely high ping (2000ms)
if you have bad packet loss and you're activating them in an unreliable RPC, that could cause it
nop, since they always spawn but the Movement seems to be taking a while to apply sometimes
where are you applying the initial velocity? and where is the component getting activated?
this is in the constructor:
ProjectileMovement->InitialSpeed = 0;
Then after spawning that actor, I'm calling a function to set the default properties from a DataAsset, so doing that :
ProjectileMovement->Velocity = GetActorForwardVector() * BulletSpeed;
then after this line or so, I'm activating it:
ProjectileMovement->Activate();
where is it getting activated?
in the function I'm calling after spawning the actor
on server or client?
server
ActorType* Actor... = GetWorld()->SpawnActor<ActorType>(...);
Actor...->InitializationSetup() -> setup the velocity for instance
maybe there's a force option that I'm missing or the constructor is not correct:
ProjectileMovement->InitialSpeed = 0;
ProjectileMovement->UpdatedComponent = BoxComponent;
ProjectileMovement->bRotationFollowsVelocity = true;
ProjectileMovement->bShouldBounce = false;
ProjectileMovement->ProjectileGravityScale = 0.0f;
use lerp or Timeline. from A to B. with X, -X, Y, -Y values../ and only replicate 1 Float.
Do you know some good YouTube tutorials to know how to make a multiplayer video game (in the style of Fortnite for example)
no tutorial will be able to show this much
break your game logic into pieces and search for details for each of them
how do i replicate a streaming level ?
i expected it to be reped by default
i guess i need to rep my streaming params and stream it locally
In my character movement settings I have settings established so the player doesn't rotate towards input, my game uses Lyra strafing animations primarily so I always have my player facing forward center. On my server this is no issues, but on clients it rotates the player to face input and then snaps them back facing forward. The client simulated proxy doesn't snap at all, this is only an issue on the owning client locally controlled. I'm not sure what other settings I should replicate or where I could look next to stop this from happening only on the controlled client
This causes insane stuttering issues with the less ping you have. The higher ping I simulate, the orient rotation to movement takes longer to snap back to forward from the server correction
I might have to comb through all my code and see if I set it anywhere in code accidentally maybe but I only remember messing with it in blueprints
loaded Q, but how difficult would it be for a none cpp dev to make a dash movement ability in cpp ?
for mp of course
'none cpp dev' ?
i don't know cpp at all, but i'd be willing to attempt it, is what im saying
should say "non"
im trying to rep a streamed level from server to client
tried to use OptionalLevelNameOverride, on server
and tried to spawn it on server AND client
in both case it doesnt work
I have a dedicated server running on locally on my machine. I have setup everything correctly i.e default server map and everything but the problem I'm facing is as soon as i join the server using open 127.0.0.1:7777 cmd the player connects and then instantly disconnects from server. Here's the logs:
Any solution for this will be much appreciated as I have already searched through internet but no viable solution was found
If I change the default server map to some default map like thirdperson map or OpenLevel same issue happens so this problem is not related to level
Edit: Figured out the issue as I was USing BP_ThirdpersonCharacter as pawn it was not getting included in cooked assets and was not present on server as Its in StarterContent Folder so this was creating a Checksum Mismatch error due to which connection was not getting established
from https://ikrima.dev/ue4guide/networking/network-replication/sublevellevel-instance-streaming-replication/ looks like i need to play with ServerUpdateLevelVisibility and ClientUpdateLevelStreamingStatus
I'm trying to stop the player mesh from going under the ground when they crouch. the capsule height changes correctly for clients, but the player mesh doesn't stay in the correct location. During the timeline, it seems like the player mesh stays above the ground, but after the crouching timeline finishes, it goes under the ground. Do I also have to set the mesh's location somewhere else after the timeline finishes?
This is what it looks like
guys is BeginPlay too early to call an RPC?
There is some offset that the movement component or the character saves iirc. Not sure if one can update that from BPs. I'm not at my PC and also won't get to it anymore today but you could try to look for something along the lines of mesh, base, offset, cache etc.
If this isn't exposed then you can only really make them crouch via the build in functions or you gotta touch c++. The code you have there is already gonna cause corrections though.
Potentially yes
I have a problem I explained it in this post on unreal subreddit can you help me? And thank you very much
https://www.reddit.com/r/unrealengine/s/gp0MRkGUFo
Why do you use an RPC to add the item on the client?
Is the array not replicated?
If you RPC anyway you may as well just call the function on both on BeginPlay, without RPC or Authority check
BeginPlay is usually too early for Client and Server RPCs as the actor may not be controlled/owned by said client yet
Yes the array isn't replicated because it's an array of UObjects so I'm replicating it manually by RPCs
I guess you don't use c++?
Yes blueprints I mean Object blueprint
Yeah I know. With c++ you could replicate them.
But either way. You can't RPC there. You can only RPC after the Owning Actor of the Component has a valid Client as Owner.
E.g. if the Component sits on the Pawn/Character, you'd need to wait on EventPossessed
Ah I see, thank you so much for your help!
do you know any event I can use in the character blueprint that isn't too early for such thing?
Yeah, Possess(ed)
Thank you very much! it worked
Cedric, could you give me a bit of insights for streaming levels in MP?
I tried various ways but i cant find a way to make the leve visible (or loaded) on client
In my style of game the server manages the loaded/unloaded levels, and the client should only receive without managing it separately
edit: finally found how to do it
Hello,
I've a question about replication (I'm using blueprints).
I've implemented an ActorComponent (AC) called "Interaction" to Linetrace for Actors that implemented a specific interface (BI_Interactable).
If the player presses the Interaction-Key the "InteractWith" gets called via the interface - Once from the client and directly afterwards via RunOnServer with the interacting actor and target.
Now I'm testing around with an dialogue system and want to create and show a widget on interaction and get some "problems" depending on the netmode.
If the gamemode is set to "Play as client" it's fine, because I can use stuff like "Switch Has Authority" pretty easy.
But if I use "Play As Listen Server" I've the problem that:
- I can't really use "Switch Has Authority" well, because the host is the server in that case and I need to create a widget for the host as well. (Thought about checking if it has a player controller and is locally controlled, but that doesn't solve the following points)
- Events get called twice, because the first "InteractWith" is called as server and then 2nd call with explicit "RunOnServer" is called as well.
- If I remove the default "RunOnServer" Method on my "InteractWith" I don't find a good way to call RPC's on the TargetActor, because it's owned by the server. Do I have to ping pong between the Pawn <-> Actor to call RPCs?
- In case the non-host player (regular client) interacts with the actor and it sends the regular call + the RPC (RunOnServer) it will create the widget for the client but also for the server, because it has an controller and is locally controlled. (and "Switch Has Authority" can't avoid that as well.)
I'm feeling like I should'nt fire a "RunOnServer" on "InteractWith" right behind the first client call, but I don't know how I would handle events that need to be performed on the server then. (e.g. destroy actor, play some animations, whatever...)
Do I have to ping pong between the pawn/pc and actor then?
Sorry for that text and I hope that I could make my problem clear. I'd be grateful for some advice ..Feel free to DM :D
Yes, you'd need to RPC to the server on a client owned actor or component of said actor, and any communication back to that specific client would probably need to be done VIA RPC on the same actor/component, or be done VIA a multicast or replicated variables on the actor.
For a dialogue system, I'd recommend only RPCing what is necessary - like the player selecting a game altering choice - and before registering that choice you verify on the server whether or not the client can make such a choice at that time. If you are free to walk up to an NPC for example and talk to them just to get a bit of their backstory or details that they may repeat, but it changes nothing of the state of the game, that doesn't really need to use any networking. You could just have the client attempt to speak to the NPC, handle the widget creation locally, determine the dialogue that should be displayed locally, and when they make a choice that would trigger something that needs to be networked, then you'd have some kind of RPC to the server at that point.
make the array a replicated property. its usually bad to use RPCs to change permanent state of non replicated properties. if someone new were to join the server, the inventory wont be syncronized
How bad is DelayUntilNextTick ? I'm running into an issue where I disable UI menu buttons for using and equipping items after they send the server RPC until the FFastArraySerializer updates which fires this delegate which reenables all the buttons to use or equip the next item, however the server executes the entire loop of disable buttons, use item, broadcast and reenable buttons in 1 frame so the server UI buttons stay disabled unless I DelayUntilNextTick then the server's buttons work again
Would it be better to include an authority check and only disable buttons on clients over this delay?
Hey all, what are the pros and cons of using the listen server to act as a dedicated server? Will I run into trouble with network relevancy?
The reason why I’m considering this is because compiling UE source for dedicated server is a giant pain in the butt, and recently there is a compile error in datasmith that I don’t know how to resolve and I don’t even want to use datasmith.
The main difference between liste and dedicated server, listen server render the graphics too. So most of the computation will be wasted.
You will end up being able to support less player.
If you are going to deploy servers in service like aws it's unthinkable to not use dedicated build
You will pay more for no reason
Hey all, hope you all are good. I am currently in a beta-testing phase with my multiplayer shooter game (using AWS Gamelift servers), 14 players joined my PlayTest last night, all was good, the FPS was 180, the ping was 25. But as the match progressed with time, the FPS is getting dropped and the ping is getting increased. After 10mins, the FPS is now 25 with ping over 250. What seems to be the problem here? Where do I look to identify the fault? Just tell me if this a server problem or something wrong with game coding
I think I might be able to use -nullrhi for eliminating rendering, correct?
No idea
i really wouldnt bother trying to engineer a listen server to work as a dedicated server unless its a temporary testing reason imo
what should i do for projectile : replication and Net dormancy
is playerState->GetUniqueId() always 48 byes ? or does it depend on the platform (e.g. steam / playstation network, etc) ?
it will depend on the platform, and Steam is even internally a uint64
which is ...64 bits
it's easiest to convert to a string and not to make too many assumptions about how short the string is
yeah I need to send it to a database which has a max size of 45bytes 😦
is this a db you control?
in a way yes, but there is a whole api that would need to change, plus I still would need some max size
so preferably I would get a short version of playerState->GetUniqueId()
well a steam ID as a string will look something like 76561197978484843, which is 17 chars, I'm sure there's a ToString version that'll also put the platform in front of it eg. STEAM:, so an extra 6 chars there if you want that
I think EOS identifiers are pretty long
but playerState->GetUniqueId() would be unreal's wrapper around the different variants of the platform IDs ?
I wonder if that is always 48, seems to be the case for a local desktop test DESKTOP-[someid]-[another number]
well that's the null OSS
if i add a Pawn weak ptr to a replicated array
is it possible that on client onrep, the entry is added, but still null ?
can the Pawn ptr still not be reped ?
yep
same with non-weak ptr
If/when it becomes a valid actor, you'll get another OnRep
Guys how correctly replicate player movement ? my player is Plane and I am doing it via RPC but something going wrong , was doing it like this but its not best practise when i dont use branch it doesnt work at all
Is this working? Remove the branch that's not required. Rest seems okay. Actually remove the muticast smooth function and just plug the Set Actor Transform directly, none of that is doing anything.
It's not working :/ idk why I join with 2 clients look at each other and move with one via mouse where I am setting Set actor Rotation and after this is called this RPC where in transform is rotation + location but nothing of this is visible from second person idk what's the problem like
:/
Did you remove the branch and this depends on if Set Actor Transform is a replicated property in the engine which I'm not sure about or you may need to tick Replicates Movement if you haven't.
I tried with and without the trick is when u remove branch then it is tryin also set rotation for you as local player and it's lagging a lot when u add branch it's multicasting your position only for other players
:d
For planes I am using pawn which has not replicated movement unfortunately
Idk if it's then helpful
It's nto multicasting.. that does not look like a multicast function.. that branch is doing nothing. That whole function is doing nothing.. you can plug the set actor directly into the Server Smooth
Believe me if I delete branch then u can't fly on local player means you can't because u are setting with your mouse rotation + multicast is telling you where u should be and u get Weird lagss
But ok will try put it in server
Also multicasting is bad for movement. You probably have some other bugs if removing the branch is causing you issues. just remove hte branch and do this properly.
Do an OnRep variable instead of Multicast as you do want this to run for everybody and it's not slower.. you are running as two clients and they are all running this seperately. It doesn't matter if its slower on yoru machine 'cos they'll be on seperate machiens. It's supposedt o be slower means it was working. Faster means it's not working..
That's if the Actor Movement variable isn't replicated.. youc an tick replicates movement which may just solve htis then it will work with just this one function without the multicast or branch. Otherwise you will have to do a seperate variable and use an OnRep to update this on all the clients. If it didn't update on any clients then they do not know where your player is so it needs to be for everybody. If they're too far it won't replicate to them do not worry. Okay Good luck I hope this is clear.
i have no other choice bro as multicast as I use pawn, unreal engine 5 does not support replicated movement so i need somehow find out
and make it work :/
basically this is end of my function for movement where I set what direction is plane flying, I use mouse control, and this I am trying to replicate, then there is also speed
but i first need find out this
when I am replicating just movement from keyboard its working fine which is little bit confusing 😄
but keyboard is using add actor local rotation
and ofc movement function for moouse is on event tick
i had working prototype but it was laggin there was some problem and planes were flying little bit wrong so I am trying fix it
I think you can just tick this and it will work.. you have to tick the replicates movement
i´ll try
give me min
This one tick it on the Pawn and I think it will work with just the Server RPC.
i set this
its working with just server call but i send you video whats happening same problem like before / that lagg i need solve it
i tried record it, small laggs while you watch / another player, its happening only when mouse movement is activated so when i use set actor rotation to replicate, when i disable it and planes use only keyboard movement all is smooth af
maybe u will now understand my issue better
Yeah that's a tricky problem. You can set the position on the client before sending the RPC should solve the lag issues. but then the server will reset the position and your player is ahead at this time. You can try the Mover component instead of making your own. Its a bit dodgy too at the moment. Otherwise you can try the above and see what happens but I think it will be popping when the server RPC fires.
yea like its working but its not smooth and thats the issue
There isn't any good solution to this.
check this is result of solution without mouse movement connected
all good
in time when i activate mouse movement and use set actor rotation its broken 😄
so i think RPC is not bad at all
its like rotators battle there idk
do you see little lagging at first video?
Just use character movement component will be easier to do.
Making your own movement compnent is not easy to do.
Atleast iwth character movement component the replication is automatic and maybe a bit smoother htan what you'll achieve
I have a replicated component. Im binding a component's function to a delegate, only if HasAuthority is true.
The bound function is getting called on client too when the delegate is broadcasted
Shouldn't it be called on authority only?
cant for planes / especially i am using pawn i would need rework a lot 😄
There's Mover Component you can look at which works with Pawns. You can do planes with CharacterMovementComponent in flying mode. It's not great either. There isn't any good solution to this.
Floating Pawn Component isn't replicated and that's not easy to do smoothly. Epic didn't get this right till today. So good luck if you can. Unreal wasn't made for Pawns 'cos Unreal Tournament doesn't have Pawns and neither does Fortnite and all the Car and Airplane Games probably had to make their own movement components or used other engines. There's only rocket league really lol.
Oh your rotation is probably broken 'cso you're setting SetActorTransform which also sets the rotation and then probably rotating this again with the Mouse. You have to do once.
crying while reading all this which already i know hahaha
i need solve it somehow
fml
problem must be there if keyboard movement is so smooth as on the other video ... i need achieve it on mouse too
game days are near i need fix it haha
I have pawns in my game but I'm using experimental technologies which do not work properly. You are just setting rotation twice you need to add it to the transform and then the setactortransform changes the rotation as well. I do not think you're adding the mouse rotation to this SetActorRotation so it's not replicationg it.
idk idk i am debugging all day finding wahts the biggest diference between using WSAD and mouse and one was Add actor rotation and set actor rotation , so I used add actor rotation in mouse movement by doing given rotation - actual rotation and then getting difference and it was not right so my head just exploded whhats then, hmm but that thing with transform is maybe right
Your game is looking good just make it and do not worry too much about lagging 'cos if anybody plays it then you will have time to fix everything later.
Besides this with AI it will work fine in singleplayer atleast. People do not know if its lagging or not they will think they just missed 'cos the game is too hard.
we need make some videos and we need smooth movement there ...
i get
it
but i believe this will be solved
😄
If you do not care about cheaters and want 100% smooth movement this is a trick you can do.. you can just set the position immediately on the client and send a server rpc which does nothing but sets a replicated variable "Transform". Setting this Transform trigggers an OnRep on all the clients except the one which sent the RPC. Then the other clients update the position of this Pawn. So your own player is moving at 100% speed and the rest of them get he updated position. Everything works 100% smoothly unless people cheat. If people do cheat you can probably figure out some other solutions like storing previous transforms on the server and checking if they seem valid but all this is a bit of effort to do and not how Unreal is designed.
Otherwise you have to use Network Prediction like I'm doing but that's all experimental and Epic might abandon it before my game is done.
Oh if you want to use this trick you'll have to send the Actor* pointer to the server and this also needs to be replicated with the transform so a structure would be best for this. Otherwise the other clients won't know which actor position to update. It's a bit tricky but not that hard if you think about this. Actually this is probably what most AAA games would do and the cheaters just do not know this.
I will try this with on rep
Good luck!
in the PIE viewport when i detach myself can i select a world to preview ?
where is the setting ?
If I recall correctly - should be somewhere in the world outliner. It has been a hot minute since I've done it though.
ty !
hey there i have a fully setup steam multiplayer game but for some reason whenever i try create a session it opens the level i want normally but once i make it a listen server it trys to open up another level even tho its not set too
its a problem with setting it up as a listen server it breaks and idk how to fix it
Show some code so people don't just have to guess
this is the code i use to create the session
damn i tried this but not working going take nap sleep maybe tommorow will be better
I just made test transform set it on every tick, but in rep notify put this but unfortunately it was not replicated at all
and when i try create a session i get this error like its just to open up a different level even tho thats not the level set up
and it only does it when i set it up as a listen server
im very confused on why it does this and its the only thing stopping me from being able to continue with creating the game as my whole game relies on multiplayer working and i dont seem to undertstand why im getting this
this is the code im using to create the session im using steam advanced sessions plugins
it keeps trying to open up the editors default map even tho its set to open up the game level and it only does this when i do it as a listen server which it needs to be listen server for multiplayer
now it dosent even wanna open the level
can someone please show me the proper way to run the trace on server properly i know this is the wong way
Have a look at the Red Event Nodes, they tell you exactly where the code is running.
Executes on All
Executes on Server
You are currently running the Capsule Trace on All
WHEN do you want to do this trace?
WHEN and WHERE
Question: I have my Weapon as a separate Actor which I connect to my character during runtime, in multiplayer, how do I reference the specific Weapon Actor's mesh owned by its owner character?
Because I tried using GetActorOfClass, but that just got the first one spawned in, not the one owned by the character
Generally speaking you would want the Character to spawn its Weapons, so that it has direct references to them.
Then im not sure exactly what your issue is?
In Component.h
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<ALegacyWeapon> Weapon1;
class ALegacyWeapon* Weapon;
In Component.cpp
void UEquipmentSystemComponent::ActivateWeapon()
{
AActor* GetOwnerReference = GetOwner();
AHeroCharacterFramework* HeroActor = Cast<AHeroCharacterFramework>(GetOwnerReference);
UAbilitySystemComponent* ASC = HeroActor->AbilitySystemComponent;
check(HeroActor->AbilitySystemComponent);
Weapon = HeroActor->GetWorld()->SpawnActor<ALegacyWeapon>(Weapon1);
Weapon->GiveAttacks(HeroActor->AbilitySystemComponent);
Weapon->GiveSkill3(HeroActor->AbilitySystemComponent);
Weapon->WeaponMesh->AttachToComponent(HeroActor->GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, Weapon->WeaponSocket);
Weapon->WeaponMesh->SetRelativeTransform(Weapon->AttachTransform);
Weapon->ActivateWeaponDual(HeroActor);
OnActivateWeapon.Broadcast(HeroActor);
}```
So can you rephrase your question?
Because the current reference I have is by class, I need to get the reference for the owned weapon during runtime for a cast
this is a trace that appears when i grab a ledge for a climbing system i got it to work right on single player but another movement action is not replicating properly so i figured i might need to do the line trace and that might be whats causing the replication to fail
So like this:
class ALegacyWeapon* Weapon;```
Probably just want BlueprintReadOnly
alright
anyone here tried to use the network prediction plugin with GAS anytime recently? are they still basically entirely incompatible? is NPP even in active dev?
Its unlikely they will ever be compatible. Personally, I havent used NPP, but they have entirely different prediction systems.
AFAIK its not in active development, more of a side project that got moth balled 🤷
So you want to do the trace each frame when in climbing mode, right?
hmm. so it seems like mover 2.0 can use either NPP or chaos physics. anyone had time to play around with mover in either of these systems?
So do that
it runs on event tick when hanging true
ok so what's the problem?
just gate it by HasAuthority to make sure it's only happening on server
if that's your goal
it wasnt working on client in the vid the character dont move
so do i need to add has authority
Well your original question was how to do the trace on server
whether or not that's what you want to be doing is another matter
yea because i seen it another way where you have start and end pins on the server event and hooked the trace that way but i wast sure the right way to do that
when i create a session it opens the level fine but when i open it as a listen server it opens a level that dosent exist like one of those starter levels u get when u make a blank ue5 project idk why its doing this does anyone know how to fix this
do the logs tell you anything?
Check your server map setting in project settings. Pretty sure you need to set your server map there
No
I did it keeps reverting back to the set map not load up the listen server
Want me to show u the maps set up just incase it is set up wrong
let me get a short clip on whats happening
this is what its doing
i now get this i havent had it before
and this
Is there a point in removing delegates from OnComponentBeginOverlap or OnComponentEndOverlap in multiplayer when a client disconnects?
i havent had a problem with doing any of that cause when client leaves they are disconnected from the server so their collisions dont exist
hard to tell what might be the root but i have had the OSS errors before, but im not longer using steam so not sure what exactly the fix could be
i was gonna switch to using epic but my game is going on steam so it needs to do steam
EOS is cross platform
a bit more work to setup i'd say but you could easily use EOS and still have steam
should i switch to EOS isntead then
lmao i can't answer that for you
ill do a switch and see if it fixs everything
persoanlly, i did not want to struggle too much with that side of things so i went with EIK (it's a paid plugin) that helps with the integration of EOS
best part of that plugin is the support, they are always willing to help answer your questions and they are kind of tailored for noobs like me
im gonna have to do full EOS as rn i dont have funds to get EIK
so im using EOS just using epic online services atm and everything is set up correctly but im not getting the epic overlay even tho its set too and it logs in to the account as i had a print string to check if it was successful or not
im assuming you have all your stuff already setup in the epic dev portal ?
that is what im double checking now
not sure if you need that to test , but pretty sure it's needed before you do the auth login
yeah its all set up correctly
i've never used epic overlay so not sure
im gonna enable two eos plugins see if this fixs it
that didnt work i went on chatgpt and changed my ini file so gonna see if this fixs it
Turn off the Replicates Movement tick to avoid the Server overwriting this becuase youre replicating your own transform instead. This onrep will run on the server as well so put that HasAuthority false to prevent this from running on the server. Maybe when it updates on the server as the actor movement is replicated so it overwrites the clients but you only want to update it on clients. ALso you will need a struct to do this properly as you need the Actor pointers. Right now your onrep will set actor's own Transform but you want to set it for the moving actor's Pawn on other clients. I hope this makes sense, to do client side the onrep moves the sender on all clients, so you need to also plug the sender Actor pointer into the SetActorTransform. I can write this for you in C++ if you want. It maybe tricky to replicate the struct in blueprints but it may work.
You'll need to RPC the transform and Actor pointer both to the server then the server puts these values in a replicated Struct which calls the onrep on the clients where you update the actor position plugging in the Actor pointer to update just this actor. Also exclude the server and calling actor so it doesn't update it's own position or exclude them in the replication conditions.
my brain cooked from looking in it since yesterday i almost had solution locally it worked but when I built server/ client and test it on dedicated it jittered again, if you have spare time and want u can send me it in dm and i will try thx 😄
Ok if you can't solve this in a day or two I'll write a plugin for you. Just follow the detailed instructions if you can create a struct and replicate it then problem solved. You can create the struct inside the Pawn and have a Pawn pointer inside this. The server puts the Pawn pointer and Transform in the struct which replicates to clients who immediately update this player position before the server fills and replicates this struct again. So this struct will always contain the latest updated client. Otherwise you'd need an array of structs to store position of each player which is harder to do.
i just kinda think problem is not lying in replication there are 2 rotations battling each other seems like thats why jittering i also did execute movement function only on client side then replicate rotations but also happened makes not sense for me that if i disable connection and dont use movement function / which use mouse and i just play with keyboard it works perfectly i cant come up to real problem
Forget about rotation for now, just get this transform to work then rotation will also work, this is probably because you're updating rotation seperately but you need to add this rotation to the transform as well. That is another issue. Transform includes rotation so if you update Transform it's also resetting rotation.
Take a break then do this tomorrow. Just understand the algorithm I told you, It's easy to do. When you send the transform the rotation will be included in this too so you do not have to do anything extra.
If you do this blindly then you will get nothing but bugs.. You have to just understand what I told you first about how this struct works and who is sending it to who.
On the client he is updating his own location and rotation normally in the movement and then sending the Transform to the server which includes everything, the server just sends this to the other clients to set this Pawn position. This is only updating clients and is not server authoritiative but will be instant. The actual actor transform is not replicated in this and so you should turn off replicates movement on the actor.
Do you thik its possible to try make testing code like this via blueprints only?
Create the struct first and attempt htis then I will fix it with yo in chat tomorrow. It's easier in bp if it works or I'll have to write a whole plugin and expose some things to bp which is harder and you can't edit this.
You need a struct which you add to the actor and this struct is replicated to everybody. Then the pawn just sends it's own transform and pawn pointer to the server in an rpc as normal arguments. Then the server fills this struct with these values and this is replicated so the OnRep can be used to set the position from this struct. See Easy!
i can do c++ but now i dont have mood :ddd
I can't think of other ways to explain this to you so just re-read the above till you can understand this. It's very simple. Read this tomorrow.
i did struct with transform , pawn , i set it rep notify made this and called it every tick like before , but unfortunatelfy its not replicating idk if iforget something
Hi. What's the proper way to send different game configs from the lobby to the actual game level? So far I know that I can send some data through GameMode event OnSwapPlayerController, when saving data for the host PlayerController. But are there any better ways? Like sending GameState info from Lobby to the level or GameMode info?
Q: I have an AI that you can toggle to follwo the player. It works as expected, even if multiple clients are spawned in. However, when it dies, the late joiners only see the body at it's spawn position. I've got it set (bIsDead) on a RepNotify, but it still defaults to it's spawn location to the late joiners. Any ideas?
You can send some parameters as options when opening the level and reading the options in the game mode. You can also tell it the level you want to use by using the "game" variable, but I believe this requires the full path to the game mode you want to use, or setting up an alias in your DefaultGame.ini as outlined in this forum post:https://forums.unrealengine.com/t/changing-gamemode-at-runtime/81504/5
How are you moving the AI?
AI MoveTo
And you have the actor set up as replicated and replicates movement?
I do. It works great for players already spawned in, just not late joiners. They see the body at it's original spawn position.
It seems that it's other spawned items, as well, I noticed, but the dead body is my priority at the moment.
Are you spawning a body, or are you just using the AI Actor (like, just using the same actor that was moving around but is now defeated and dead on the ground)
Just killing the AI actor. They are already in the world.
They ragdoll
It seems to work fine (as far as the location) for late joiners if they're still alive...just when they're dead and then join is it an issue.
Are you disabling anything when you put them into a dead state?
The collision capsule...but now that I say that 'out loud', that may be my issue...
Nevermind...I'm just setting it 'no collision'
It has to do with the ragdoll. I believe it's because when you ragdoll a mesh, it is no longer tied to the location of the actor.
UPDATE: Everything works as expected if the AI pawn is SPAWNED at begin play..just not when placed.
Putting in a small delay before triggering the ragdoll on your onrep will make it work correctly, but that's not the way to handle this... trying to figure it out.
Ah interesting.
If you happen to figure it, do let me know. For now, spawning the AI in from the level BP will work as a workaround.
Disable this on the placed actor:
This prevents the client from loading their own copy first and then it becomes linked across the network. Instead, the replicated version will come down and have the correct position to begin with.
It appears that some of the functionality is broken if that is unticked.
Is there a counter-bool I need to set on the BP if I unset this on the world isntance?
That same option appears on the blueprint itself, but disabling there would ensure that any placed instances are not loaded on the client's end with the map loading.
If you're having trouble with functionality by unchecking this option, that's an indication that you may be using something about this actor in the level blueprint, or you have some other race condition that's trying to retrieve a reference to that actor before it exists on clients.
I'm still exporing what might be causing that - thanks for helping me think through that @sinful tree
hey there i am trying to use steam advanced settings plugin for my multiplayer game it connects to steam perfectly fine but whenever i try do a open level node of my create advanced session node it fails to open the leve linstead it defualts back to the level before im using this code
this is the code i used to add steam to be called
Thanks, this will do for what I need!
Not sure if this is it, but you currently have "listen" in the options of the Open Level node. I believe you need to put in "?listen" Also verify the name of the level is correctly entered or use the "Open Level (by object reference)" node instead to ensure you've got the right level.
i can send a video of what its doing if that would help
this is what its doing
okay so putting "?listen" fixed it
spent 6 hours on this and that was the fix geez i feel stupid
thanks dude
i just dont know if it fully works now intill i have my mate who lives in the same country as me to be able to test if it works or not
You dont have access to a second computer anywhere?
sadly not my laptop cant run my game i tried
You can host the game on steam pretty easily and then test on any 2 computers
It cant run the game or cant run the unreal editor?
At minimal settings it should be able to run the game off steam. Even if you have to make a new empty map just to test basic stuff. Having 2 conputers will make the process much easier going forward. 😄
I have a replicated object that i'm creating on server, and right after i am setting a property on it.
Is there a way to make sure that when the object replicates it already has that new value of the property?
Nope youll need to replicate the value as well
Though you can make the object hidden in game by default or set hidden in its begin play, and then reveal the object when it gets the proper rpc/notify
Thanks
This looks okay. Maybe untick ReplicatesMovement on the Pawn but keep Replicates ticked. Also exclude your own player with Skip Owner. Also put a branch before Set Actor Transform to only do If NOT HasAuthority because otherwise the server will also run that onrep. It should work after this. I posted screenshots of the right settings below, so set these and add the HasAuthority branch.
Ok apparently my problem is another.
The property is replicated, and when the client receives the object, the property is already set.
The issue arises from the fact that the OnRep for that property is not called as soon as the object is replicated
Which confuses me, since the property DID already replicate by that time
In short:
- i have a replicated object with replicated property.
- I create object on server and set the property right after.
- When the object replicates, a delegate is called, and at that point the property value is the one set on server.
- But the OnRep of that property did not get called yet.
Is there a delay between when a replicated variable is replicated and the OnRep is called?
Did you create an on rep function? And is it not being called on the server or on clients?
Oh sorry i see you did make the onrep function
Yup, the OnRep function is getting called just fine on clients, but apparently later in time
Reliable = true?
There is a point in time where the property did replicate, but the OnRep is not called yet
OnRep functions are reliable already, aren't they?
Sorry yeah my brain wasnt on lol
I do think there would be a bit of delay between object creation and the onrep
Thats why youll have to have the object hidden until the onrep is called
What would hidden do to a uobject?
Sorry I thought you meant 'object' as a generic term for a 'thing', like an Actor
Nope
Is there a more specific problem you're having?
I imagined it was an actor being displayed before it's mesh was setup or something
Just the fact that apparently i managed to run a function consistently after a property is replicated but before its OnRep is called
And i rely on that OnRep for initialization
On the remote side?
Yes
Yeah you'll need to adhere to that initialization, so your object is treated as if it doesn't exist until it happens
Similar to how creating an actor will call it's BeginPlay before your next line of code even runs
you can probably sneak in code right after the object is created, but before you've even set it's replicated var
In real world scenarios that might not even be possible, but always safe to force all function calls to fail until your onrep has ran
with an "IsInitialized = true" variable in the onrep or something, then check that in other functions
after maybe 30s of going in a straight lines my client doesnt see the floor static mesh of the level i stream in.
its weird because
- other actors are loaded (maybe its because they are reped, unlike the floor static mesh)
- the server is next to the client, so it should be relevant
Anyone has some good info or tutorial how to handle Procedural Mesh Component collision? I have procedural map generator tha uses PMC as ground, but I'm struggling with collision for client
If you want to have a set time a match runs, and you want to support late joiners (they see the synced time left), then would a rep notify still cover that situation? Or would the rep notify not run because they are joining and the value hasn't changed?
Basically I am trying to avoid making the server send (every second) an updated time value from the game state, because that definitely cannot be a good way to do it.
Or would you just set values to initially replicated and skip the rep notify?
Greetings! I'm working on a simple little multiplayer tag game to learn Unreal, and am trying to figure out replication, and was hoping someone could point me in the right direction.
I'm trying to track the "it" status as a boolean on my PlayerState, to then change the player between two colors (altering materials on my character), where ideally other players will also see that that player has changed colors (denoting the "it" status). I'm using a debug input to trigger this, but so far I keep encountering the issue where the other player doesn't see the color change. I know this is a replication issue, but am struggling with how to navigate it. I've tried using RepNotify (PS is calling a custom event that triggers a change to a material variable with RepNotify on, OnRep function casts down to character to change materials) but my problem persists (color only changing for the player who hit the debug button). I'm sure it's some simple thing I'm missing here.
Thank you for any help you can render!
How are you retrieving the character?
Current setup, on PlayerState:
i have a interaction system setup that works with mutiplayer but when multiple people interact with it nothing happens, if one player looks at it it works perfectly find, is there a better way to do this maybe?
Are you setting those replicated variables on the server? The OnRep looks like it should be working correctly.
This looks correct for how you could do a multiplayer interaction. What does your interact interface look like on the actor?
this is a actor that on interact you pickup the phone, works perfect but when 2 players look at the phone you cannot interact with it, looks like it cannot handle mutliple players looking at the same object, hopefully i explained it right
on the interface i call the interact and a look event so look event just means if the item is a interactable item it gets highlighted but same problem with interacting it doesnt highlight when 2 people look at it but works fine with only 1 player doing it
Maybe this is the issue? The two things I posted are the entirety of this current system, aside from the debug input to trigger this event. Is there something I should have set up to run on server? Like, at the Game Mode level?
Variable replication only occurs from the server to clients so any variables that you want replicated to clients must be set while running on the server.
If you're doing a debug key press, that key press only triggers on that instance which may not be the server, so it would only be setting that value on the instance of the game that pressed that key, meaning no others would know about it.
If you want to let the server know that you pressed that key, then you'd have to send an RPC to the server (An event marked as Run On Server) and do so on a replicated actor or component of such an actor that is owned by the client making the key press. Once running on the server, you can then set any replicated variables on any classes you desire and they will replicate.
Other events like overlaps can trigger in more than one instance, and you will likely want to use a Has Authority node and ensure the Authority is the one executing the code.
Well, in the example you provided there, you have "Can Pickup" on a branch.... Are you setting that to false immediately after this code that you've shown? What does your look at interface look like?
so i tried setting a collision box setting to to true but when outside that box im still able to interact with it for some reason
but on both things when 2 players look at that object neither of them can interact with it
so if i straigh pull a print string out from the interact it only prints when 1 player is looking at it and interacting, when more people use it nothing happens
Again, need to see what the look at logic looks like. The interact interface does not have anything apparent that could be blocking it apart from the Can Pickup variable possibly going false immediately after your code there.
Thank you for the extremely detailed, informative answer! This is definitely what I was looking for!
I set my "IGotTagged" event on the Player State to be "Run on Server" for "Replicates" and it now seems to work (albeit with a short delay between the button-press and the color-change on the screen of the player pressing the button). Regardless, I think I'll call that good enough for now, thank you very much!
you see the overlay material go away when the other player gets close so the same with interacting because focused and interact event are on the same interface
That seems like you may be doing your trace on tick for all characters... You probably only want that executing if the character is locally controlled.
i do call that trace on event tick ye
how do i implement that if you dont mind me asking
right click, type locally controlled, branch on that
might have to use it somewhere else still the same issue
How can i make it to locally controlled instead of 1 for all characters
It's not about 1 for all characters, it's just that every client executes that tick function for all characters, thereby, every character that exists in the game was performing that trace. Now that you have that branch and islocallycontrolled, that ensures only a locally controlled character will execute the intraction trace function.
which should only ever be a single character on any instance of the game.
Can't run the game already tried
if I make my game without considering network delays (high ping) then how hard it would be to fix it later on?
Will i have to rewrite all the code again?
That's something I gotta fix too
Continuing my little Tag experiment: I'm working on the event that triggers when the two players collide, to check which of them are it and/or in the cooldown after having tagged someone, and to make appropriate updates as a result.
I seem to be encountering an issue where when the character tries to get the player state of both themself and the character they collided with, both of these checks return with the same value (being the player state of the player owning the actor calling the event). Simplifying this, when Player 0 (server) tries to get the player state of the character they collided with, it comes back as P0's player state, which is clearly incorrect.
This is all on the player character.
Thought process:
- Check for collision
- See if it was another character that we collided with
- If it was, get their player state, to check if they're It (since I'm having "It"-ness live on PS)
- Get my own player state, to call the event to process all this, passing along the information we just got from the person we collided with
But again, it looks like when I try to get the PS of the other character, it's returning the current character's PS instead.
Thinking about this more, a Blueprint Interface maybe is the right tool to use (haven't done much with them yet), but I'm still curious about why this Cast to Player State isn't working the way I'd expect it to.
Interfaces won't change anything here. The reference is either valid and the right type or it's not. Putting an interface on the playerstate and calling it from the same pointer that fails a cast won't work.
My idea had been to circumvent casting to the other playerstate by instead using an interface to pass along the current player's information and have the receiving player process it (as opposed to the setup above, where it's the current player processing it, and attempting to retrieve the receiving player's information).
Right. But interfaces aren't a solve for casting. They're both just communication tools. If the playerstate is invalid or the wrong one, the interface won't be able to do anything differently than a cast will.
It really depends on what you're doing and how important it is to gameplay.
An example would be client prediction of things like shooting and movement. If you don't have client prediction of things that a player would normally expect a fast response, then the player probably won't enjoy the game as it'll feel sluggish and slow to them. You probably won't have to rewrite everything even if there is some lagginess to it with poor network connectivity as not everything will feel terrible with a bit of lag. At the end of the day, there's only so much you can do for players that have not so great internet connections that will always have high latency.
On begin play, I'm hiding the player mesh above the legs for the locally controlled player (playing as first person). For the host it works, but not for the client because it seems there is a delay before the mesh is loaded or valid. If I put a delay and then hide the mesh, it works... but from what I understand, people have said it is bad to rely on delays. Is there a way to see when a client or their mesh is loaded?
I would suggest using OwnerNoSee instead
Only owner see etc
as for the mesh being loaded it depends on how this is created... is this a mesh referenced by their pawn?
I was doing that, but I want to be able to see the legs. I was setting it up where I created a second skeletal mesh of just the legs and clothes attached to it, but figured maybe it would be too much for every player to have a second pair of legs, 1 for owner no see and the other for only them to see
then I was thinking about just hiding the mesh above the spine bones
It would be easier to have two sets of skeletal meshes, one for third person and one for first person
I'm not really sure how to just hide parts of the skeletal mesh but that would be alright I think?
Hide Bones by Name
I forget if it just zero's out their scale or not
this is how it looks like
which is what I was trying to achieve with having a second skeletal mesh for the legs and clothes, but was thinking this might be more efficient, and the locally controlled player just hides their own
the client sees the host as the full body mesh
So do you think it's an error in the player state reference? I'm still not sure why it was returning itself instead of the other player.
Anyone implemented custom NetDeltaSerialize? Looking for examples
I'm not sure if my setup is correct, But It seems I need to handle packetloss and sending large data as chunks
I managed to handle the packetloss but can't figure out how to send large data as chunks, I don't understand how the OldState and NewState works
I believed that I only get the last state acked by the client as OldState but it's not always the case, I still get the NewState as OldState in the next NetDeltaSerialize call even tho the data with that state didn't reach the client yet or was lost
Collisions can happen on each character, and of course, on each instance of the game
For a multiplayer game of tag, you would only care if the collision:
A) Occurs on the server
and
B) The collision is happening with a player that is currently tagged as "it", as you only care to change the state of anyone if a character who is "it" has collided with someone, not any of the other character that are not it.
To ensure that you're running the logic on the server, use a Has Authority and use the authority output of it on the collision event.
To ensure that you're only running additional logic that relates to tagging someone being it, check on your collision first if "self" is the one that is it. If they are, then you can change the state of both playerstates of the character that detected the collision (self) and the one that they collided with (other actor).
after maybe 30s of going in a straight lines my client doesnt see the floor static mesh of the level i stream in.
its weird because
- other actors are loaded (maybe its because they are reped, unlike the floor static mesh)
- the server is next to the client, so it should be relevant
UEnum property replication has some typical issues?
UPROPERTY(VisibleAnywhere, ReplicatedUsing = OnRep_MontageTypeToPlay) EMontageType MontageTypeToPlay;
UFUNCTION() FORCEINLINE void OnRep_MontageTypeToPlay();
void AArmaCharacterBase::ServerReload_Implementation()
{
MontageTypeToPlay = EMontageType::E_MagReload;
OnRep_MontageTypeToPlay();
}
void AArmaCharacterBase::OnRep_MontageTypeToPlay()
{
PlayMontage(MontageTypeToPlay);
}
void AArmaCharacterBase::PlayMontage(EMontageType MontageTypes)
{
switch (MontageTypes)
{
default:
break;
case EMontageType::E_MagReload:
PlayAnimMontage(Weapon->GetMagReloadMontage());
break;
case EMontageType::E_BulletReload:
PlayAnimMontage(Weapon->GetBulletReloadMontage());
break;
}
}
my issue is the montage only play once on client, and on server it plays every time when i reload
logically it should on client/server both, since i am using OnRep
why *FORCEINLINE *
its my habit
That is a bad habit and you should remove it
but also, a value only replicates if the Server thinks the client has a different value, and you only get the OnRep if the value is different to what you have locally.
Ok, and is it related to the issue?
you're correct, we can't do much for players with high latency but Idk why I can see my game breaking even at an average network emulation of 30 - 60 latency in ue editor.
Is there any free plugin or something for prediction and smoothing the gameplay on a high ping?
i am calling on rep manually on dedicated server, i guess it should not be teh issue in my case
that default state don't effect anything and no need to care where it shold be end/first
i tested using uint8 MontageType and it works fine
switching on digits
but i want to use a logical type related to montage type, = EMontageType
Unless you have a "none" type, one of those will be the default, so a client will never play it
This feels like it should be unreliable multicast instead
yeah i don't have the none type
Unless you want players to suddenly trigger montages when they get within rep range
Well that's at least one problem then
so i have to have the none and set it to none first and then reset to the state i need?
normally you don't replicate animation stuff directly. you replicate the overall state of the weapon and the clients manage their animations locally themselves
in my design i am using registered C++ AnimNotifies for reloading weapons
when the montage ends it calls the notify to actually update ammo
and it calls an event to do this from the equipped weapon, weapon checked if the event instigator is server then update ammo, else return
so it means, montage play on both sides, server/client but the ammo update response only validated from the montage that server play
update:: adding none state doesn't solved the issue
void AArmaCharacterBase::ServerReload_Implementation()
{
MontageTypeToPlay = EMontageType::E_None; MontageTypeToPlay = EMontageType::E_MagReload;
OnRep_MontageTypeToPlay();
}
i guessed it was already EMontageType::E_MagReload; so setting it back to the current state don't replicates... that why setting it to none and then back to EMontageType::E_MagReload; could solve the issue
but it doesn't
and i am dealing with dedicated server, where it doesn't call onrep automatically, i have to manually call it
yeah, the onrep calls playmontage only once on client.
LOGS:
First reload attempt:
Server : Character : OnRep_MontageTypeToPlay
Client : Character : OnRep_MontageTypeToPlay
Second reload attempt:
Server : Character : OnRep_MontageTypeToPlay
void AArmaCharacterBase::OnRep_MontageTypeToPlay()
{
PlayMontage(MontageTypeToPlay);
LogValidity("Character ", "OnRep_MontageTypeToPlay");
}
void AArmaCharacterBase::LogValidity(const FString& ThisName, const FString& ThisMessage)
{
FString RoleString = HasAuthority() ? TEXT("server") : TEXT("client");
UE_LOG(LogTemp, Warning, TEXT("%s: %s on %s"), *ThisMessage, *ThisName, *RoleString);
}
i set it just like this but i dont know whats the trick its not replicating at all lol added has authority
ensure that it isn't running on the server or your own client, print the pawn and authority. It maybe overriding if those are running it. Make sure you put those settings from the screenshots or it won't work. What can I even say about this screenshot its just two nodes. You have to debug all this and maek sure you did it right.
jambax do you have any knowledge of level streaming meshs not displayed for clients (but other reped actors in same level are)
this is set skip owner, rep on player should befine too
maybe i need test it via server not running localy two clients
but i doubt
and its executing like this
Also for debugging you can add another branch to check that pawn != self this isn't necessary if you set those settings from the screenshot but you can try this just in case.
No that shouldn't matter. Two clients is better and works fine. It looks okay to me I can't really say. It should work unless you did something or some bp limitation? Check the Pawn names to see who's exectuingt he onrep and the value of the transform and if the server is setting this.. lots of print nodes or debugging 'cos it all looks okay.
Oh also has not authority before sending the server rpc or the server may be executing this on himself.. you have to ensure none of this is happening in the wrong places or it will just override the value. So do some debugging to figure out whta's happening. I can't say this from the screenshots but put this check. Server rpc shuld be sent only by the client, and onrep should exclude the client and server is what you want.
If it's not replicating at all you'll have to check if server rpc is getting called etc. etc. but that should alwyas be called. Make sure the value is changing. Okay I'll talk to you about this tomrrow.. Good luck!
i had to delete changes and go again something broke
solved for now
UPROPERTY(ReplicatedUsing = OnRep_bWantToOnRepReload) bool bWantToOnRepReload = 0;
UFUNCTION() void OnRep_bWantToOnRepReload();
UPROPERTY(Replicated) EMontageType MontageTypeToPlay;
void AArmaCharacterBase::TryReloadWeapon()
{
if (HasAuthority())
{
if (!IsValid(EquippedWeapon)) { return; }
if (EquippedWeapon->CanReload())
{
MontageTypeToPlay = EMontageType::E_Reload;
bWantToOnRepReload = !bWantToOnRepReload;
OnRep_bWantToOnRepReload();
}
}
else
{
ServerTryReloadWeapon();
}
}
void AArmaCharacterBase::OnRep_bWantToOnRepReload()
{
PlayMontage(MontageTypeToPlay);
}
so it is confirmed that UEnum has typical replication issues with On_Rep method
really? I am using that for animation atm. What kinds of issues you face?
before setting it again to some state, UEnum property needs to be resetted, i sets it to none before setting it back to the state it was currently in
thats not working on clients
so i use now a bool property as a helper to call that onrep on all with a replicated uenum property
thats works fine
another option to use int++ instead of bool
I will keep in mind if I run into the same problem, thanks
If this doesn't work then because you're using the same struct variable for all the players so the players are also overriding this in the server rpc if two players send this in the same frame. Now you'd think the struct will be updated and replicated but when this gets overriden in teh same fframe it may just send it once I do not know.. probably.. so an array would definitely work but then you hav eto do a whole Tarray of this struct on the player and you do not know how many players might join so then the server rpc has to fill this by creating a new struct for every pawn if the pawn pointer doesn't exist in this TArray or update the existing transform. TMap would be easier than TArray but that doesn't replicate easily so finding rows in this will be hard. Ideally you'd add and remove pawn structs to this when players join the session in the gamemode etc. but you can also just add new pawns in the rpc but you'll have to do a for loop to check every entry. You can probably just leave any pawns that leave the session int he array and figure a better place to add remove them later. You could probably sell this if it works even if it's not very secure.
after maybe 30s of going in a straight lines my client doesnt see the floor static mesh of the level i stream in.
its weird because
- other actors are loaded (maybe its because they are reped, unlike the floor static mesh)
- the server is next to the client, so it should be relevant
UE5 general is rich, he has more space for more brain
Yeah UE5 general is rich and has the most spare time and the most airflow between the ears. Scanning rocks or talking to metahumans on his phone.
Blueprints discord is an indie developer and owns a car, C++ lives in his mom's basement and the last was never heard from after or his Multiplayer game.
for my fire logic i am using this method uint8 = ~uint8; for replicating shots , so what it actually does in my design?
UPROPERTY(Transient, ReplicatedUsing = OnRep_RepShot) uint8 RepShot: 1;
bool AWeapon::Fire()
{
if (CurrentAmmoInClip > 0)
{
CurrentAmmoInClip--;
FireTrace();
RepShot = ~RepShot;
OnRep_RepShot();
return true;
}
return false;
}
it changes and replication works correctly
i just want to know is i am destructing it in a live scene?
and what advantages is this supposed to have over a multicast RPC?
i like onrep so much
i can do RepShot = !RepShot ? TRUE : FALSE; which works too, but RepShot = ~RepShot; seems cleaner
or this RepShot = (RepShot == 0) ? 1 : 0;
This is a huge help, thank you very much!
I can't seem to find any documentation on the GameNetworkManager, but i'm hoping someone can fill me in on whether I can override what seems to be the default behavior of spawning one? I don't have any networking in my project so if I can get rid of it I'd like it.
If your game is single player why do you care that it exists or not?
There's any number of reasons to not want something to exist in a project if it's not needed, do I really need to list them all? It's there, I don't need it, I couldn't find any documentation on it, so I'd like to know if I am able to eliminate it from my project somehow.
Are you using C++ at all?
Yes, I have a mix of c++ and blueprints.
It looks like the GameNetworkManager is defined on the WorldSettings and is luckily public, however its not exposed anywhere to the editor.
Its instantiated in AGameModeBase::PreInitializeComponents()
So if you override that function
Before you call Super
Set the GameNetworkManagerClass property on the WorldSettings to nullptr
It will cause it not to spawn.
What the consequences of doing that are, I have no idea.
Its not likely that its expected not to exist.
So you could end up causing problems doing this.
But thats just a guess.
lol yea I don't want to do it without knowing the consequences. Just seems odd that it's forced to exist when the game is not networked... And there's so little info online about it from what I could find. Oh well, guess I'll leave it.
Its really just a settings class
Gotta save those bytes
Well uhhh - it does say it is only needed for sserverss in net games. Trust the comment if you dare.
Seems like a problem for future, hopefully more knowledgeable, possibly more wreckless, me. lol.
@thin stratus @pallid mesa
I have extended PredictedMovement to include DebuffMovement and DebuffCharacter, for net predicted buffs and debuffs that modify movement properties
If you have time I would love a code review 🙂
When the snare is applied or removed there is a single correction that I don't feel at 175ms
https://github.com/Vaei/PredictedMovement/tree/debuffs/Source/PredictedMovement/Public/Debuff
I die a bit inside every time I see how much boiler plate is needed just to do something simple like modify max move speed lol
Don't be fooled, CMC is incredible and we're truly lucky to have it. But yeah the monolithic nature of CMC makes it really painful to learn.
One of the biggest things I've learned in my current job is having predefined states is better than being able to set specific values from a game design perspective. It keeps your game feeling cohesive and allows players to familiarise and build muscle memory. So the best thing to do is tuck it away in a plugin exactly like this.
In fact I'm thinking about making a plugin to expose CMC or any other actor for designers to work with. A pretty UI that's easy for them to interact with and images to demonstrate the effect properties have etc
Aren't the "pre-defined" states just a way of packing up "specific values"? For designers, I feel like having the flexibility to experiment/prototype different movement behaviors without needing an engineer to pour hundreds of LoC or more just to do basic stuff that won't cause net corrections is such a missed opportunity. Haven't looked at the Mover2.0 code yet, but hoping its way more flexible than what the current CMC is, because I've wasted so much time customizing that thing at this point.
You can change the values tied to the states if that wasn't clear
The debuff functionality I added just now can be used for buffs too, so that's any speed gain or loss covered. It supports multiple levels too.
Generally having a sprint and walk on top of that is a great starting point. It includes stamina as well. I go a step further and add stroll for patrolling AI or "stacked" penalties that put you into a walk state
The question is how many of those things can you do without needing to write c++? The repo you linked has separate characters for each of the Sprint/Prone/Debuff, and the debuff is just a single hard coded type.
One thing I really dislike with CMC is they used the term "walk" instead of "run" or something more generic (move wouldn't be appropriate either), which feels like they didn't anticipate people adding a walk state lol
I will probably make a flattened branch with the sprint, stamina, debuff, prone in a single class. But not until the repo feels very complete because updating it would be a pain
The way it is now is not how it's intended for you to use
I will add Walk also
Let's clarify one thing though, a net predicted character movement that lets designers add their own systems to prediction in BP will never reasonably exist
The point I guess I'm trying to make, is that Movement is such a pivotal part of most games, and having the CMC require heavy c++ customization to add the usual suspect type modes that any game might want to include overall makes it seem like a really difficult base to use for any Game Designer. They basically need to be tied to a gameplay engineer to customize things, this usually ends up being lots of one off pieces being added (similar to what your repo has) and with each new request, requires more c++/engineering time. Would just really love if Unreal shipped with a more pluggable and designer friendly movement system by default.
Yes of course you need an engineer for net predicted movement, it's fortunate designers can even be involved in the creation process, which is thanks to blueprint
But engineers don't want this exposed to BP because the performance cost is too high and characters are critical
Making sub ticked calls to BP functions isn't a good idea
Agree with the last point, but I could imagine a system (maybe Mover2.0 is more like this) where each movement mode is implemented with some kind of UObject base class. Then you could have some simple rules about how movement transitions between these modes and allow designers to override it in blueprint. For prototyping, designers could implement full movement modes in blueprint and since it's prototyping the cost isn't as problematic. Once you decide, "yea we like this idea, lets make it more performant", an engineer could then basically just translate that into some c++. I think it would also be awesome if there was some kind of value modifier system similar to the root_motion sources but for changing things like friction, crouch amount, walk slope, acceleration, turn speed, etc with prediction built in. I think just having those two features would go a long way helping people make what they're trying to make a lot easier.
Basically if we had a version of GAS that actually worked with movement the way people always think that it does, that could solve a lot
Yeah mover is on the right path. Our designers don't really need us to prototype with CMC though. We give them ways that aren't expected to go into a shipping build
I seen so many people want to make a simple Sprint ability, then realize it's never going to work right unless they write a bunch of c++
@grand kestrelis Mover predicted (heh) to be easier to integrate with GAS or is it just another prediction ecosystem?
I think it will be the same story unfortunately
Could use a little sanity check of my understanding here:
Say I'm replicating two properties A and B and I'm always updating them in that particular order on the server. Am I correctly understanding that I'm not actually at all guaranteed that the replications my clients receive are in that particular order, only that they will eventually be delivered? My understanding is that duet to packets being dropped or perhaps packets being suddenly routed differently, there's no guarantee that A will always replicate before B, and I should never build my client-side logic to expect that?
You shouldn't expect those to be replicated in the order you set them
If you really need ordered properties then replicate a TArray
Is there a structure I can use to include a TArray and something else? E.g. say I have "currently equipped weapon + a TArray of all of my weapons". I can get clever and cram them all into one TArray, but maybe I can do better?
You'd just make your own struct to do that
Gotcha. There's nothing in UE's replication that says "nope sorry you cannot have a TArray inside of a struct if you want to replicate the whole struct"? As in, there's no limitation around TArray needing to be the top level container for replication to work?
I don't typically make structs in BP if that's what you're planning; just try it
If I did it in C++ I would implement the serialization myself
