#multiplayer
1 messages ยท Page 703 of 1
when do you delete the characters?
and how do you prevent that the game mode spawns the characters?
Well you create instances, fine, but are you sure the character you play with is actually the one you have spawned?
yes game mode has default pawn class none , character is deleted and also player start is
i just dont understand why I have this problem inside editor when I press play
and why not when I run game via icon
inside folder
then is no copy there
hm I have no idea, you will need to debug^^
^^ any time
Guys, anyone would help me via sharing my screen? ๐
Im still don`t clearly understand what have to do -_-
Is changing ownership to the player's pawn for any given actor an idiomatic way to get RPCs working on the actor rather than on the player controller/pawn? Are there any side-effects I should be careful about? Is there a way to "return" ownership to the server after finishing the RPC?
Hey guys, so I got two questions, would really appreciate some light on them ๐
-
is RestartPlayer a networked function? Im somethings getting issues on my Client upon respawning, not sure if its that node's fault or not, but yeah. Sometimes the client is unable to move when spawned, whereas the server can move. Am I doing anything faulty? Also, is the RestartPlayer function compatible with setting up a random respawning system? Because right now its just restarting the player in the place it spawned in, but then I guess I gotta control the initial spawning in maybe the level blueprint, gamemode or something?
-
If the listen server starts its server and lets say, a client joins after 1 minute, will an actor thats using a Event BeginPlay be off-sync for the server & client? This actor in particular is firing missiles based on repeating timers. When testing earlier online, the event of the actual firing wasnt multicast so that might fix the sync, but the question is still something Im wondering about ๐
guys i have problem here cast to player state always fail.... can someone give me a tip ?
It's either Custom Players Controller is null or the Player State is null(debug your code so you know by inserting a breakpoint).
If it's the former I would use Get Owning Player function instead. If it's the latter you would need to call an event dispatcher that sets the player state inside this widget once Player State is replicated and that's using a RepNotify. I'm not sure if the RepNotify is exposed to BP though
can someone tell me why the last node doesnt work
im trying to make it so people cant see the pawn anymore
and I want it to be networked
Last node ignores collision, it doesn't make your pawn invisible
You should be using SetActorHiddenInGame
visibility channel is only for raytracing
it doesnt effect visibility ?
also using a replicated variable? is it always necessary if youre already running stuff on a function thats a server rpc
i was trying to replicate a light switch and it wouldnt work until I used a repnotify variable
Well I'm not a collison guru, but visibility channel doesn't mean what you think it means
Well a RepNotify variable is simply a replicated variable with a callback that tells you the variable value has changed. So technically there is no difference in how they replicate. All you have to care about is that you change the value on the server and not on the client.
im trying to make the actor invisible on the server but not the client and I cant figure out where to set the actor visible again
anyone pro in networking ?
GoVisible is executing on client which is bad. It needs to execute on the server
Also it doesn't make sense to go visible again immediately right after that. But if you really wanna do that then just call SetActorHiddenInGame(false) right after.
Im making a game where you need to be invisible to other people but visible to yourself
I deleted the go visible thats in the server call and added a small delay
that seems to have fixed it
ty for this info though, i didnt know the rep variables trigger callbacks
Has anyone used TurnBased built into Unreal? Any success?
What's the quickest path to build a turn based game in Unreal?
RestartPlayer is a game mode function. So it executes on the server, and as long as your pawn is replicated(which I assume it is) then you're good to go.
What RestartPlayer does is it calls FindPlayerStart, which in turn picks a PlayerStart and spawns the player there. So if you want to change how your players are spawned in these PlayerStart actors, then override FindPlayerStart in your GameMode class.
I will try ๐
Also make sure your custom PlayerState class is being set in your GameMode class
Wow, thanks a lot! So in the FindPlayerStart I can essentially getallactorsofclass (playerstart), pick a random item from an array and run that into the return value?
Correct
If you want to make sure players don't spawn next to each other, I think you want to save an array of all player starts and add and remove to that when needed.
Well I just looked through the source and it looks like it already does that for you ๐
Thats awesome!
it is done
WizardCell do you know why I may be getting this stutter? How could I improve the replication?
@fathom aspen man i am 23 ๐ i feel so bad that u are so smart compared to me I am newbie here
You would probably want to look through the network settings in your CMC @mellow stag
u are working with ue or just its your hobby ?
ahhh fck still doesnt work can I send here 2 pictures of blueprints so maybe u can see if its problem there :D?
Heh, age is merely a number, don't make that frustrate you. I just started learning Unreal years ago ๐
Well I make a living using Unreal ๐
Yes
Ah I just got job also with UE thats why i am learning as much as I can
because I am still at university
this is my first programming job ๐
so here on fist I have editable text in widget i am trying to cast inside custom player state and edit name ( which is replicated)
I'm too. That's why my learning pace is a bit slow. I've also been off unreal for like two years ๐
But yeah you gotta get your hands dirty with this engine so you get better at it
and here is widget 2nd its lobby when I have READY button I am clicking on ready so I can print names of players
but I am printing default value "player"
its like server doesnt know about change
Is there a way to make the integer-setup more flexible? I.e adding one extra player start to the map would break it right?
and I have to say that use of get owning player helped with casting no more cast fail
Ok you're setting a replicated variable Player Name in your widget class, but your widget class is client only. Replicated Variables should be set only in the server.
That's why it's printing the default value of the variable, because the variable isn't being set the right way
I'm looking at the CMC replication settings, is the net update frequency at 100 fine?
You can use a "Random" node which will return a random value from the array.
I really have no idea. I don't do CMC stuff, but you can play with the values there and see what best works for you
ahh so I need custom event run on server and there set it ?
but it is possible in widget ?
Widget's are client only
i kno but i am typing that name inside widget and also I need print it in widget.... So I need set and get it there
Just make the RPC on the PlayerState.
You can then call the event on the playerstate from the widget.
What you would have to do instead though. Is you would have to call a server RPC on your PlayerState and provide it with Player Name and simply what the RPC does is that it sets PlayerName as the provided one.
ah true
moment
and only server event
or also multicast ?
does rpc mean multicast and also server
event ?
Just server.
I'm experiencing jittery movement on a connected client's character when they move "through" a "disabled" Actor that has a StaticMeshComponent which is invisble and shouldn't have collision. I do this to hide said actor and deactivate it's collision:
Mesh->SetCollisionEnabled(ECollisionEnabled::NoCollision); Mesh->SetCollisionResponseToAllChannels(ECR_Ignore); Mesh->SetVisibility(false);
The Obstacle is set to Replicate, as is the Mesh (via SetIsReplicated()). Do I need something else?
I suspect the collision is set correctly server sided but not replicated correctly to the client or something like that
and do you do that both client and server side?
collision properties are not automagically replicated
I thought I'd be clever and do this:
if (GetLocalRole() < ROLE_Authority)
{
Destroy();
return;
}
Because logically the client shouldn't need to know about the actor anymore
or so I thought
Might there be an issue if I just destroy it on the client, but not on the server and it's sort of replicated still?
Thanks, that worked flawlessly!
Um.. I might have solved it ๐ without this part it appears to work flawlessly again now. Could have sworn it didn't work before. Hot-reload isssue perhaps? I restarted the editor a few times since
Nope, I didn't solve it. But it only happens with blocks that are destroyed on the server. The visuals are replicated but the rest not. Should probably be easy to solve with an OnRep thing. Thanks
Do me a favor and don't use hot reload: http://hotreloadsucks.com/
I would absolutely love to use live coding, but it appears not to work with UE5 and Rider (at least on my machine), or I just haven't figured out how to set it up correctly
Ah if you're using UE5 then you don't have to worry about hot reload. LC is on by default I guess
I could be wrong, I don't use either one hehe
Yes, but errors ensue. Probably works with VS. But Rider for Unreal I believe is still in an early stage, I use the EAP currently
But I'm still new-ish to the entire UE / C++ thing. Might just be a layer 8 error there ๐
It is on by default from what I recall (UE5). To use live coding you don't compile with Rider. You compile with UE (it'd be in the bottom right). You can also use the shortcut.
I forget what the shortcut is though.
me too. I use this little buddy all the time:
And Rider is โค๏ธ
The release is in a month >_>
We heard it here first ๐
I too absolutely love Rider for my daily C# / .net core development shenanigans.
I mean It wasn't a secret ^_^ we were planning to release it at GDC, but... some stuff happened...
Nope - I'm going with it being a secret and we heard it first.
Makes it more special.
Well I should start considering moving to Rider then ๐
first photo i am calling custom event in player state and second image is custom event that is running on server and I am setting name , on the third I am printing names
so I dont understand whats the problem if I am retard or smth else
What are the odds it's not being executed because it's unreliable?
Make it Reliable, and see if it's being called/executed
||Debug||
and also its annoying to always build server side after compile , I am using dedicated server on my pc ah ๐
unfortunately reliable didnt help 
Well you can use the PIE dedicated server feature for such cases
u mean inside editor ?
Yes
sometimes I do but .... sometimes I need anyway to build it dont know why I am just amateur so problem is on my side on 80%
whatever
we learn by mistakes
๐
Did you try debugging your code?
I just tried to print hello betwen custom event and seting name in state and its executing because I am printing hello
so dont know where the problem is....
so i think this is correct
Executing doesn't mean it works as intended.
That's why you gotta debug your code.
Debugging let you inspect values at runtime
Ah correct, I totally forgot about that
๐
I think yes. You need to run in editor
hmm its interesting i am spectating server and i dont see that something is running but print works wtf
this wont work i just dont see anything
i just have there a lot of clients.. and noone from client 3 is matching
i dont understand u
how ?
yes
You would have to set a breakpoint
Have you read this?
Show the code where you do the attachment
yep I set one breakpoint and opened call stack and there no stack do display i dont understand
ah I am done ๐
I dont understadn I made points and everything over server and I cant make names
You shouldn't be doing attachments on client. You do it on server and it replicates
๐ I want help u but I cant I cant make mine also .. ๐
i am done
i dont understand...
Try printing out the value you have in Setname
i am trying or which you mean ?
not in state ?
Well explain what "works" means?
I am printing get player name behind set and as u can see I have your name there and it prints same
so
yay my name though ๐
My blueprint for printing it from custom state variable must be wrong
this
I was trying to print saved names in next widget
this must be wrong
Well you're getting it wrong.
Both are "after" there
There is no before there
Once you're inside that RPC you have a name that has to be set. At least that's what you're printing
If you really wanna see "before", then print the the replicated property, before it's before it's set
so mistake is in widget where I am trying to print it ๐
hm I am confused I was printing this
and this must be wrong
but this is in next widget
I just put name
then hit join
and i am in this widget where I can click on button
and try to print all names of joined players
and here I am trying to get it and its local
maybe because of this it doesnt work
ohhhhh
iam retard
oooooooooooooh my gosh
i just created custom event , runned on server and try to print it with it
ah
you can see how big newbie I am
๐
Well it's supposed to print out the names if you really click the button after they have been set. PlayerState is replicated to all clients, and GameState is replicated to clients. So It's all good...
but it doesnt print it ๐
well i just tried to make server custom event and call print there and still i am printing default name Player
I finish... ๐
its like instance isnt editable
I suggest you read Cedric's network compendium if you haven't got to read it yet
i have i am in half but i didnt have problem before with this i was also savings player score and so on
and now I cant save name in widget....
dont understand
See #2 and #3 pinned messages from the top
yep
but it doesnt make sense
what is happening in my blueprint
I have same game mode same player state on map
because I am going from entry map where I am putting name to Lobby map
both have own widgets
in lobby map I am printing names...
it has same mode , cclass etc
it looks like lobby widget is connecting to not same customplayerstate
Well make sure CustomPlayerState is the PlayerState Class you use in your GameMode class
Also make sure your entry map level has the right GameMode class set. If you want to make sure that's the case override the GameMode with the correct one in World Settings
all that things are okey I had diferent game modes but now I changed to same , but still there was same player state class.. iam going to relax now ๐ i am trying to do this almost 4 hours i am done
Also for your knowledge, Player Name won't persist level travelling if you don't tell it to. That's why I suggest you get to know how networking works in Unreal. Again read Cedric's Compendium(#3 message in pinned)
Okay.
so i think problem is that somehow custom player state on map 2 isnt same as custom player state on map 1
and thats why i am printing default ๐
Wait are you travelling to a new level?
I thought using event on server side is everything done
I am in Level 1 (start menu) and after filling name and clicked join I execute console comand to my server IP and (open ) level 2 (server)
Ok you didn't say that
oh i know i see it now.. i am retard
At least I didn't see it
i cant set server value if iam not on server
i am in server after execute
.... no ?
omg
Well it goes back to what I said
Info in the PlayerState don't persist if you don't tell it to
There's a function called CopyProperties in PlayerState that does that. You will have to use it. Also probably you will have to use another function called OverrideWith
That's why you should read that Compendium ๐
Yes. Info don't persist by default
You will have to use either the GameInstance class or the method I said above with the PlayerState
gameinstance is good
i can save player name there
then after server opens
i will save from instance inside state
and its done
yep ?
Well no, it's not a good practice
so i am gonna read compendium
PlayerName is a player specific info. It should reside in the PlayerState
you are patient with me ๐
Nice now you get the drill
Well I'm good at controlling my nerves
sometimes
but I will save it in PlayerState and never use instance again ๐ but i know I am gonna read
thank u man
ah
๐
I love u
What is calling the ServerRPC?
When i use it in "server" - it`s destroying only in server
On the other hand, when i use it in "client" - its destroying in server too, but in my side its still exist
Is the Actor you are trying to destroy replicated?
Hit Actor 0 goes from function "LineTraceBeChannel"
Yes
Why is the variable marked as replicated if you send it via RPC anyway?
Replication goes from Server to Client. If that variable would actually be used properly, the Server would be the one setting it, which means there is no need to pass it along.
But if you pass it along because the LineTrace only happens locally, then why marking the variable replicated?
Im new a multiplayer and other RPC stuff, so i haven`t answer for you ๐
Input Action
So you press a Key, you Trace, and you send the Traced Actor to the Server and want to destroy it?
Yes and no
In theory that works, but you should RPC right after the Input, and let the Server perform the LineTrace
Because otherwise Cheaters could destroy whatever they want
But let's assume you don't care about that
You don't need the variable (HitActor0) to be marked as Replicated
The only thing that must be given is that the Actor you hit is replicated
So in its Blueprint, the Replicates checkbox is checked
Otherwise, sending it via the RPC will result in a nullptr for the Server
Cause they can't connect the instances via netids
Hmmm
What Actor are you tracing?
StaticMeshActor
A StaticMeshActor is not replicated by default
So this can't work
You would need to make your own Blueprint with a StaticMeshComponent and set the Replicates boolean to true
Then it will work to send it via the RPC
Can i change it`s parent to Actor without any issues?
StaticMeshActor is a default engine class
Are you inheriting from that or why are you asking?
CanvasPanel is part of the Palette
Top left, just search for it
Also #umg
In what world is that a #multiplayer question :D
No, actor which i wanna destroy inheriting from StaticMeshActor rn
That sentence doesn't make sense. You might be mixing up some of the terms. Is the Actor you are tracing one that you made your own Blueprint of?
yes, it has own
Then on the right, there is a lot of settings
But you said you are tracing the StaticMeshActor
I thought you ask about it
No that's the Parent of your own BlueprintClass
So you are tracing your own BlueprintClass
Yes
Remove the replicated property of the HitActor0 variable
And ensure that what you are tracing is 100% that Actor by printing its name
Also, you should add print strings to your ServerRPC to ensure it even reaches the server
Right, then try to check if the RPC even calls on the Server and what the Actor pin is
It basically double checks. You can keep it but it's not really changing much
HasAuthority almost equal to "Run on server"?
No, it checks if the caller is the Authority over the Actor or Remote.
But since you move the call to the Server with RunOnServer RPC, you kinda can't get the Remote pin to trigger, unless maybe a cheater tries to call the function manually. But replicated Actors can't be destroyed locally, so they wouldn't gain anything from it
Well They can be destroyed locally, but that wouldn't replicate to anyone else.
Only the Server has the "AUTHORITY" over that
Well, look
kinda weird thing
I add stuff for destroying, like, you know, changing material during destroying etc, and add a string to see what actor we are looking rn, but as i said in server-side its destroying properly, but in client-side its changing material, but when i wanna trace this actor, the server tells me that: "Server: "
so i guess it`s a nullptr as you said
And this only after changing material to basic, before that server knows about my "actor"
The Server probably destroyed it and that's why it can't find it anymore
The strange thing is that it doesn't seem to destroy it on the client?
Yes
I would suggest you try to reproduce this once more with a very clean setup, without any material changes or so
Because this is a very simple thing and it should work if you marked the Actor as replicated
(which you did)
Just for sanity, can you open the Blueprint where you have Replicated checked and set NetLoadOnClient to false
And then try again
Just wondering, although it shouldn't make a difference
Right, figured as much
after destroying it, the mesh in this BP still alive, but without collisions
*if it`s important thing
I would assume it's pretty buggy collision
For the Client
Because for the Server there is nothing blocking you
yes
Yeah that's expected if there is an object only on the Client
Stupid question but are you placing these actors by hand into the scene or are you spawning them runtime?
runtime ๐
Coooould you show me how you do that?
Because I have a feeling that you spawn it locally too
Which would mean your client has a second instance of it
could we go the voice chat just for sharing screen?
Na, sorry, it's late for me and I can't be loud anymore. Wife would kill me .P
Just screenshot it quickly
@tender acornWhy are you not just spawning a replicated actor on the server?
@tender acornWhy are you not just spawning a replicated actor on the server?
They do now. I already helped in DMs and I assume they wanted to post the solution along the problem but then Discord died.
https://www.youtube.com/watch?v=RfVHSXCEcsY Getting this weird stutter replication issue if you aren't the host
@thin stratus Can I ask how can I pass information about player from player state when I am in start screen not connected on server and type there name then I join to the server and want print all players in lobby but my informations won't stay there
Guys, if anyone would get the same problem, this pictures showing you how you DONT spawn actors
That`s it, smth was wrong when i tried to send
Hey guys, is Event Begin Play replicated? I got a missile firing actor that fires missiles on a timer on BeginPlay, and its out of sync online. The firing rate is different, so Im guessing the EventBeginPlay for the client who joins after the server is different than the server's... Or maybe I have to force the timer to the clients somehow ๐ค Some google searches lead me to adding a ref to the counter in a gamemode.. Do you guys have any recommendations? ๐
maybe problem is in physics I had some.problems with it what type is missile?actor or what I think some types of blueprints can't replicate physics
Too much assertion of dominance in that video.
It's a multiplayer projectile, so should replicate fine. Thing is, the firing is off-sync. When the client joins the server's misssiles might've fired already.
So the problem is most likely within the timer, but Im struggling to figure out how to work around it. One thing could be the WorldDeltaSeconds, which I think wont be replicated properly just out of the box? So I tried using this instead (as show in picture), but now the missiles never fire ๐ (Was trying to multiply by 1 to see if changing the value would help, but no. Using the default pin there didnt help either)
and what type of object is missile
hmmm so I guess I can t help then :D if physics is ok
Yeah I think physics are okay, its more of a timer problem I think, since its off-sync (the actor that fires the missiles fire them off-sync, which is ran by these timers)
Thanks anyway! ๐
for better understanding if u have 3 actors there u fire on 1 but on other 2 u see it delayed?
right
Somewhat, yes
Its a missile launcher that fires missiles into the air. When the client joins, the missile launcher is firing X amount of time after the server's missiles have already been fired
Missiles should be fired on server only
Hmm, but if it fires on server only the clients wont see them though - however, same thing happens if I just make it a multicast too. Havent done this kinda stuff before, been easier with basic linetraces & replicating damage & traces that way ๐
@dark edge @real ridge Here's what I've got so far:
Hmm, the rotation needs to be fed to the server/client properly aswell, doesnt it ๐ค
Havent been replicating that
On a scale between the server and client agreeing that the missile spawner exists, and the server and client agreeing on the path of each individual missile, how much do you need their two views to agree?
As close as possible. When the missiles hit the ground they explode and damage the players. Having missiles fired in all different rotations on clients and server thats gonna be pretty bad
Okay then it's just a simple as a replicated missile spawner spawning replicated missiles.
On the client side, the spawner should just be sitting there looking pretty.
Yeah ๐
Start out without multicasting anything. This should be no rpcs. The spawner is a replicated actor, which spawns replicated actors, the missiles.
Im reading this article regarding time, which could be one way to tackle the time incident, unless there's a way to go about it without making custom classes: https://medium.com/@invicticide/accurately-syncing-unreals-network-clock-87a3f9262594
When implementing real-time network multiplayer in a game, one very important tool is a reliable network clock.
You're making this way harder on yourself than it needs to be. Just have the spawner, on server only, spawn missiles, which are replicated. The thing that is replicated is the fact that the missile exists. Assuming the missile movement is already replicated with whatever movement component you are using, it'll just work.
Hahaha yeah you're saying something there! I feel a bit under depth tackling this hehe, but is this what you had in mind?
This is within the artillery itself - but if its only spawning on the server the client doesnt see the missiles
All replicated actors spawned on the server are also spawned on clients
Hmm, in that case Im not replicated properly, because they only spawn on the server. I mean, the projectile (missile) is replicating itself, but its not being spawned on the clients
@low helm
It likely is spawning but movement code isnโt setup right so itโs not in the right place
Hmm ๐ค Yeah I'll have to sleep on this one ๐
If it has "Replicates" on, and it is spawned on the server, it is spawning on the clients. Problems could include - it's not where you think it should be, or it gets deleted somehow.
I'm doing a souls like and local prediction of the roll ability (sending direction to cast it from client to server) but sometimes if the player is a small amount of distance error from where it was cast on client ir breaks everything.
Is maybe sending the position it was cast on client and on server waiting for it to match (with a small error tolerance) the right way to fix it?
Obs: on video it 400ms and 20% packet loss just to show the problem
this is really strange
It looks like a problem with TargetData "AbilityTargetDataSetDelegate" and packet loss.
is there a good way to detect if a player is returning back to a server they left? i can think of a few options (eg storing this in player state which im saving on leave and loading on join) but i wanted to know what you guys think
You can use รฉpic services identity
if i have a replicated property and set it on the server via assignment (eg myThing = myNewThing) it automatically gets replicated right? or do i need to call a function after to replicate it
It is replicanted If you add on the replication list
https://www.youtube.com/watch?v=RfVHSXCEcsY Getting this weird stutter replication issue if you aren't the host
almost certainly want the client to have authority over their own rotation to an extent here
otherwise they will have to wait for the server to send them their own viewmodel rotation like what I assume is happening here?
@nova wasp How would I fix this? Sorry a bit confused
have the client's machine control their rotation
instead of just reading the server value
Would that be a simple change?
probably?
Let me ss my blueprint rotation see if you notice anything
you may just need a switch on authority somewhere for all I know
or just have it use pawn control rotation
hello there, I know it's late
I'm wondering, when I compile my server, should I include only the main level? where I need to include the menu level?, the menu level is where we choose the player.
normaly the player only joining main level and level that the player is spawn no ?
no, I'm sure he means the input event that sets the control rotation. send a screenshot of that rq
Ok ๐
I literally just do this and it works without stuttering
that can go in the pawn or the controller, but the pawn is a bit easier for dealing with replication
Interesting
I guess it could go either way, depending on your controller's relationship to pawns
what's that for?
It's in the BP_Character_Player It updates the chars rotation
Yeah that's it
replicated actors have their transforms replicated as well
so basically you were setting it multiple times and it was correcting itself
I am setting up some very basic IP based multiplayer widget. Everything seems to go well (the logs show that the connection is established) but the client that joins the game, doesn't "start" the game - it gets stuck in the same level it was before
what's the best way to model a multiplayer game with cards?
suppose player A trades a card with player B, can we trace out an ideal scenario?
should I create a full blown class for my cards? (will need a string to represent it + anims, images for it etc)
and when I transfer a card between players, do I send just an int over the server, and then tell the client to take care of the rest?
I would say so, cards seem to be a central entity in your game, at least I'd have some data object
That depends on what the client needs to do with the information recieved
@prisma snow when I get a card from another player, show a cool animation, show it in my hand (i.e render my List<Card> neatly), + it has an associated sprite etc
Not want to be condescending or anything, but are you familiar first with Unreal's replication system? I feel like your questions are more general than geared towards multiplayer. You can "architect" your game in a number of ways, which is semi independent of how to replicate over the net. Generally speaking you'll have a copy of the objects in both client and server, do the important logic server-only (to avoid cheating etc) and send the results to the clients
I have 2+ years of experience of hardcore game dev experience with Unity + multiplayer ๐
And yes, it is more of an architecture question than MP, just needed to think out aloud
When a resource card needs to be traded, I am probably only going to send an int over the wire, but will handle rearranging of List<card> on clients @prisma snow
Hello everyone,
I am making a multi-player (listen server) ARPG with melee linetraces.
It is working well but I don't really like the flow right now:
Client press button - > server commit the skill (check if can launch, stamina, mana, etc) - > back to client for linetraces on the weapon - > apply point damage (server). There are a lot of back and forth between the server and the client... Is there a better way of doing something like this?
Or maybe it's the normal way and I'm overthinking haha?
Yeah, do everything on client and server at the same time, predict the result locally on client and then roll back changes if needed
That'd be a more usual way
Because I need to linetrace on the client side right?
I am not able to make the linetrace on the server, it does not follow my markers on my weapon
Hi there! I have a problem, i spawn a weapon(replicated actor) and try to SetOwnerNoSee, but nothing is changes. Where is my mistake?
Server function
SpawnWeapon_Implementation(TSubclassOf<AKT_BaseWeapon> InWeaponClass)
{
const auto LWeapon = GetWorld()->SpawnActor<AKT_BaseWeapon>(InWeaponClass);
LWeapon->SetOwner(PlayerCharacter);
LWeapon->Mesh->SetOwnerNoSee(true);
}
If the server is unable to do basic checks - might as well be purely client side and just tell the server the hit result
Assuming cooperative play
I have two makers (empty scene components) linetrace start and linetrace end, when I play an animation for whatever reason the server do not see them move, but the client do. It only follows the player movement on the server.
If possible I would like to do as you say, on both server and client then change if the result is different, to remove the lag
Ohh ok, nice :D
Given how Unreal's replication works, generally speaking you can architect your game almost as if it was standalone, the replication can be handled in each class. For example, if the deck of cards was an actor (AActor), it could automatically replicate its state (variables) to all clients.
I'd say that a card game falls very well into Unreal's default tools so you shouldn't need anything out of the ordinary. I'd look into this if you haven't already, it is a very good resource to learn UE's networking:
Hey, i am working on a multiplayer game that should run on a dedicated server, but i don't know any "providers" other than playfab (but playfab needs your creditcard information and i don't have a creditcard yet. But i have paypal). Can anyone recommend me a "provider" i can upload my server build on? I will switch to playfab eventually, but for now i just need a server to test the game on
Nitrado
isn't this a minecraft thing?
AWS?
guys I have CopyProperties in player state for copy my properties when travelling to another level and also OverrideWith when connnection problems but How to call them ? I tried it in widget by casting to player state and this function doesnt appear
i mean this I have level where I put player name and then save it in player state then I click connect to server and I am in lobby where I have to set READY BUT ๐ I dont know how to pass info from player state on first level (not on server) to second level where I am connected on server
its propably easy know anyone ?
I'll try. Hope it's easy to setup
generally, you'd want a base PlayerState class holding all data that gets transferred between levels and CopyProperties implementing on it, with both your lobby and game PS inheriting
its not seamless travel because I am traveling from client map (local on pc) to server ( i am connecting by execute command ip ) so i dont know how to pass info there
yea
that will just not work
so I have to use instance to save name ?
and then load name from instance to player state on server ?
or
server doesn't have a client instance of PS to copy the data from
when you do a hard travel
so there is no way to make it like this
any c++?
I must create instance and there variables which I will put inside player state ๐ , full blueprints
I thought that some legit way "exist" for this
generally, there is a good c++ place to put the sending PS data to server on hard travel in
so I can try
APlayerState::PostNetInit, its also the first place where its safe to send a server RPC from a PlayerState
so with c++ is chance
the easiest is use instance but i dont know if its right
because instance will be local for player
and will not delete after login on server
generally, a subsystem is a better way to go about it
doesn't clutter the GI, and can also take responsibility for say, loading saved player setups from a hard drive
we have significantly delayed BeginPlay (procedurally spawn an entire level before its called), so our PlayerStates even on hot join - hard travel get fully populated good 10-15 seconds before the game actually starts
you do have an alternate approach though, if the amount of data you need to send is not large
sending it via the login url string
of u too smart for me because I am newbie I try to read about all this and watch some videos thank u
if all you need to send is a name and few bits of data
u can use these servers for whatever, also stranger suggestion is also valid
it can be added to the login url
then server would parse that data during Login/PostLogin
Now I am connecting by Ip I have local dedicated server 127.0.0.1 so you mean add it somewhere there ?
you can google the syntax
i never used it so i don't know if off the top of my head
just be patient with me please if I am asking dumb questions XD I will do
but generally its ?data appended to the url string
But on the nitrado website, when i go to "products" and then to "gameserver", i havo to choose one for a specific game like ark or minecraft
@winged badger can you help me how to cast inside player state from game mode ? I want set there name from instance
after login on server
in on post login
i dont know what use as input in object
you should not be doing mulitplayer yet then ๐ฆ
I guess you could contact them, we used nitrado in the past for our game
somehow I need to learn ๐
best way is trying
at the end of the day you'll be given a series of machines @split sentinel in which you can distribute your binaries
alright, i'll try to contact them and ask if i can upload my own game there
not upload, but use their hosting services to host your game
in our case we contacted them and they made a deal for us
other services have matchmaking, but nitrado doesn't. How is it supposed to work with nitrado? With a server-browser ingame?
Hi all, guys
Anyone working with multiplayer project based on ALSv4(Advanced Locomotion System), and if its so, i wanna your help ๐
i know i can cast there over get game state-> player array -> for each loop -> array element and inside object but i want only 1 player not all
You have player controller reference on postlogin event
It has a reference to its playerstate
Let's say I have an actor component that has an array of UObjects. For them to properly replicate. do I need to have an outer of the UObjects set to owning actor of the component or can I leave it at transient? (UE5.0)
Wondering about it, because I'll be moving the objects between different actors/owners (e.g. player drops item on the ground, so now pickable actor is owner of that uobject).
If so, what's the proper way to change outer of an UObject? I can think only of UObject::Rename and duplicating with NewObject, unless there are better ways.
If it matters, only server will be creating and marking objects as garbage.
@pallid mesa i called the support and they said that they don't do that anymore ๐
aww buggers :(
@winged badger and @fathom aspen thank u for help I did it finally
I had to use instance for hard travel from client to server then RPC from server to set state from instance and thats all... ๐
Now I want ask the easiest way to print player name and status is what ? for example
Jaroslav Ready
Maroลก Unready
Peter Ready
Loko Ready
structure ? or save it inside player state also or instance and then print it and append somehow ?
^
Hey, so my latenight testing yesterday was never going to bear fruition haha, thanks for the assistance! I wasnt even testing on the server, just simulating in the map itself. So, with a mug of coffee in my hand - when playing online the impacts & explosions are very closely matched, which is great. However, the client cant hear the missiles firing anymore, and client cant see the trajectory of the missile actors until theyre within 20 meters. Its almost like theyre not replicating until theyre within a range of the player or something? Is that a thing?
and its possible to print it way I show ? in some table ?
name + status
name + status
from array
I don't see how this is different from what you are doing already
Save name and status in PlayerState and print them whenever you want
yes but I need to customize print because now i am still printing last added name only
not alll
Append
also if its done over loop
how to add in append new line ?
i kno i use append to connect name + ready but then i need make new line and print second name + status ๐
You want to print to screen, or to a widget?
If you want to print to screen then that's already done for you, if to a widget then that's a whole different story
on widget
like this
yea thank u my friend
Good afternoon guys. โ Im doing this setup to fire missiles from an actor which are running a multiplayer projectile plugin for trajectory. The missile hits on the ground are replicated pretty well, but the sound of the actor firing the missiles doesn't play, and the missiles don't load until they're within 20m of the clients, at which point it's too late ๐ This wasn't a problem before, when they spawned normally, so it must be a replication issue. The missile actor and the firing actor is set to Replicate.
Anyone know what I could be doing wrong? ๐ค
Yes, From long distances objects will initially fail to replicate
You would need to increase their net cull distance squared
@low helm Hmm, so I increased the value and now I see them when theyre spawning, and I can hear the missiles firing on my clients. However, the missiles disappear before colliding. Is there an issue with setting the net cull distance too high?
I set it to 6249999872,0 ๐
No thatโs not the problem
Itโs a normal feature of replicated movement for something to not arrive in the right place or in the exact right time
Hmm, its actually fine before I swap windows - replications and all looks fine on both windows, but once I swap to the server to doublecheck, and then swap back, the misssiles begin to despawn on the client once I swap back to it
I'll have to test it online and see if it's fine there ๐ค
This is a complicated problem with about a dozen potential solutions
You may want to research Netwerk interpolation
Because servers donโt send movement information as much as you think
The clients have to do a lot of guess work as to where a projectile should actually be, especially a fast moving one
Sorry in advance for the long text ๐ I have trouble replicating scores. This is how I currently implemented it:
- In my GameMode, when a player scores a point, I add a point to their PlayerState. This score is a replicated int32 property.
- After incrementing the score for the player that scored the point, I call a NetMulticast Method UpdateScores() * on the GameState which then triggers a BP Event, so I can update my UI using Blueprints.
- In the Widget I bound the Event from the GameState to a custom event which updates the score text. The Custom Event in the widget gets called, but the PlayerState seems to not update.
- I also update the scores when a new round starts. At this point the player state seems to have updated and the score count at this point is correct.
- If I play in Listen server mode, the score gets updated correctly and in time, on the client it does not until the next round begins.
So it seems like even though I added a small delay of .2 s before updating the text, the score has not been replicated yet.
Is my approach unnecessarily complicated? I was thinking it would be simpler to just use an event that has the score in a parameter, so I don't do "1. Update Score in PS" "2. Use GameState to tell everyone the Score was updated"
Just have your UI self update on Tick, or with a replication event for the player state's score.
Oh right, that would probably work ๐ Is there a way to set the tick rate so I don't update it way often? I can't seem to set it in the WBP properties
No idea, no need to
Yeah, this seems to do the trick. Cheers mate
Hi there! I have a problem, i spawn a weapon(replicated actor) and try to SetOwnerNoSee, but nothing is changes. Where is my mistake?
Server function
SpawnWeapon_Implementation(TSubclassOf<AKT_BaseWeapon> InWeaponClass)
{
const auto LWeapon = GetWorld()->SpawnActor<AKT_BaseWeapon>(InWeaponClass);
LWeapon->SetOwner(PlayerCharacter);
LWeapon->Mesh->SetOwnerNoSee(true);
}
Owner no see is client side, AFAIK
It seems to be true. And only owner see is also only a client side?
Is there any overhead to have a TSubclassOf as an RPC parameter? Or is it a common practice?
My character can jump and look around but cant move as it just jitters me back into place, im using a dedicated server
Happens both on PIE and standalone
How to sync anim montage over network (like a dark souls tumble) on bad network without jittering every 2 seconds?
Is disabling network corrections while animating recommended?
The red number on log is distance between where client started the animation and server did
I'm wondering about something I'm seemingly having issues with. I set a replicated FString property in PlayerState on the client side in the PlayerController in BeginPlay(), and it seems not to get replicated all the time, if ever? Setting it via Server RPC it works very reliably. Are you not supposed to use replicated properties in PS for one-time/e.g. set directly after joining on the client?
as far as I understand it, replication roughly works either like this:
- server changes a replicated property
- it's repicated to the clients eventually
or
- client changes a replicated property
- the change is propagated to the server
- the rest is as above
correct?
Just to double check, if it's C++, did you add the string to ReplicatedLifetimeProps (or something like that)?
Yes
Does anybody know if/how ENUMS are packed for the net?
I assume bools are packed automatically
Mmm then I am clueless, that seems fine
I'd check that all involved objects are instantiated etc
So no matter what i do, even if i move the character in the editor the location gets snapped back to a very specific location
In my understanding the replicated variable propagate from server to client but not the other way
does it snap back always to the initial place?
yes
That would explain it
Hi, im making a game and im hosting a server, and my friend is supposed to join that server
"D:\epic games\Epic Games\UE_4.26\Engine\Binaries\Win64\UE4Editor.exe" "D:\UnrealProjects\PuzzlePlatforms\PuzzlePlatforms.uproject" /Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap?listen -server -log i host with this ^
"D:\epic games\Epic Games\UE_4.26\Engine\Binaries\Win64\UE4Editor.exe" "D:\UnrealProjects\PuzzlePlatforms\PuzzlePlatforms.uproject" IPADRESS:7777 -game -log
and we both join with this ^
now this does not work, he joins a different session (in which he seems to be the host)
when he hosts and I join him it works perfectly fine.
can anybody help me? thanks in advance
(We are using Hamachi)
then your character movement component is not working properly. What is happening is that your character moves client-side only, and the server forces it back when applying updates.
I guess you need to rpc to server then set the variable? I don't know if there is a better way (if you want to replicate to every client's)
well that's what i thought too but how would i fix it
i made sure that the cmc is set to replicate
That would be fine, I'm just trying to grok why stuff happens the way it happens ๐ I've used replicated properties in e.g. Player Pawns before without issues, but I'm thinking this worked because I might have not explicitly checked whether the code in question was running on the server or client
if it ran on the server naturally the props would get replicated
the client never changes a value to replicate
Haha yes that happens
For client to server you send RPCs
Perfect. Cheers! Also, I probably should have read this again: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/Properties/ ๐คฆโโ๏ธ
Does Multicast run on server too? Apart from all the clients? If yes, how to prevent that?
{ ... }```
Yes, Multicast RPCs are executed on the server and clients. Not sure if there's a direct way, but I would check for Authority when calling
What @dawn ledge wrote ๐
@dawn ledge how to do this in Blueprint
is this correct?
Looks like it works for me
Guys How can I create session on selected server with specific IP ?
I am just wondering how it works when someone is developing a game and they have server with ip for example 127.0.0.2 and you can connect there and play a game
I am just asking because in all turtorials on unreal engine youtube they are using sessions
but how its really works irl
You can create a session from a computer (server), and the IP will be the IP of that computer. For local testing is 127.0.0.1 (in the same computer). If you want a public IP, it will be the IP of the server.
Other clients can join your session by your public IP then
What you cannot do as far as I know, is to chose your IP
I have done dedicated server like this
and joining via ip
but my question is (if I am game dev) and developing multiplayer game How I make it ? I will use dedicated server
or how
i dont understand
๐
If you want to join via IP; why sessions?
I was just watching this series https://www.youtube.com/watch?v=RKx0K98pxl8&list=PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ&index=4
and I see how he is working with sessions and I have feeling that he has more options with sessions
I am just curious about how its going in real life if I want develop multiplayer game I am working with dedicated server right ?
and also then server is only for joining but all job is made on clients pc they call functions and server does it
It depends on your game, your budget, etc. Many smaller games use listen servers, because dedicated servers are expensive
exists some book or pdf about it ? I really want to read something more
listen server is when another player is hosting game ? yea ?
And if I use dedicated I need to run it 24/7 right?
our friend @thin stratus has an excellent UE4 network compendium. But things like cost of servers etc, you have to look for yourself
if you want players to be able to play at any time, yes
yes I am reading that compendium its briliant... I hope I will be as smart... one time ๐
okey so if I want to try develop game with server 24/7 i need use dedicated server and then I am not working with sessions ?
right ?
or this is wrong
( i hope its okay to talk about stuff like this )
I am really curious and I dont have anyone to ask
sessions is one thing, and the way you handle servers is another. You can have sessions in listen server and dedicated server
So if I am understanding, I can create sessions on dedicated server also (like 2battles in one time with different players) so its like I treid day ago when I made 2 different maps on same server but both have different port one 7777 another 7778 right ?
I guess, that surpasses my knowledge and experience ๐
ah ๐ but anyway thank u but maybe one another question maybe u will know how it works then if I will have dedicated server to host games how I know what part of folders and files must be stored on server to run it.
and one more XDD I did dedicated server but folder has maybe 24 GB what is really really much If I realize I dont have anything there no textures only 2 maps with default characters , maybe I can something delete there or ?
Imagine to have to download game where 24 gb is nothing
and 60 gb are textures
Double checking something before I start writing it. If I'm using the method to client side predict movement actions like sprinting or sliding with a custom movement component in order to replicate the animation states of those actions I still need some replicated booleans on my CMC so that I can pull from those in the anim bp correct?
Regarding this I've come across this article earlier: https://docs.unrealengine.com/4.27/en-US/TestingAndOptimization/PerformanceAndProfiling/ReducingPackageSize/
๐
Is only relevant to owner not a thing for characters? Can only get them to be visible for all clients or none, spawning non-characters works fine
Hello, when I try to set a boolean to decide a random enemy from the group of players it only picks the person hosting the server. any way to fix this?
There's nothing being networked here. Your host is clicking the StartMatch button. You're getting one of the players controllers, in that player controller, you're doing Get Game Instance (which would still be on the host) and setting the host's game instance IsEnemy variable to true.
You already have it selecting a random player controller. The issue is more to do with where and how you're setting the variable. Game Instance is a bad place to store variables that need to be networked as it only exists on each client and no one, not even the server, can access other Game Instances. Further to this, if you did store it on the game instance and were to RPC values back and forth, it could be a potential place for someone to cheat. Your best bet would probably be to move it to the PlayerState if other clients need to know about the value, or in the player controller if only the server needs to handle it.
Im using game instance because it selects a random player in the lobby and we switch game modes for the actual game level so i needed to communicate across that
thank btw i will look into it
Hello
I compiled my project and created a package... but it seem that the server is lisen only on local ip
LogNet: Created socket for bind address: 0.0.0.0 on port 7777
so it's work if I connect my client to local ip
but not from external
it's there a way to bind it directly to my static ip
I'm fairly new to UE networking, but in general, 0.0.0.0 should be open to external connections, at least from your LAN. If your firewall/router/whatever gateway doesn't block it, you should be able to receive connections from outside your network too
Yep, with NAT routers you might need to port-forward
ok well. my other project when I start the server it bind to my IP. I don't know why it use 0.0.0.0 on this project
u want to connect from another pc ?
I add the port-forward to 7777 in my router setting
yes I would like to test it with some friend
you dont have dedicated server ?
yes I have a dedicted server
Does your friend connect via the internet or over the same LAN as you are in?
via internet
so I had also and I could connect from my laptop to server on pc
If you have port forwarding set up, your friend should be able to connect via your public IP if you bind to 0.0.0.0, unless your firewall or something prevents that
I just found it strange that for this project it bind it to 0.0.0.0 , cuz for me it's a local ip
0.0.0.0 is your public interface as far as your machine is concerned
if you have 2 devices at home try to copy game to another then run server on first
open cmd
meaning, you can connect from local host addresses like 127.0.0.1, LAN addresses like 192.168.1.123
type ipconfig
find IPv4 address
and try to connect to this address from another pc
u need this
i think
ok I will try that. thank.
This might just give you your LAN IP, you might need to use the IP Address assigned by your ISP, which you could find out via icanhazip.com or google for "what is my ip"
yea thats true
or he can find it on router somewhere
in my router setting i port foward the 7777 port to my LAN IP
it's there a way to force to use the same port ?
I see that it's change
What is the default bandwidth limit in UE4.26? It was 10Kbps iirc but I think it was higher in later versions :)
100k if memory serves
nice, thank you. I am well under the limits then
You're not limited to that by the way. Those are project settings in ini files. Easy to edit.
Yeah I am aware, but I'd rather keep it low if possible. The Net Stat shows In/Out in Bytes (not Bits) right?
I found it weird since most times, I see bits used to talk about net bandwidth
So I assume it's 100k bits (not bytes)
Not sure about the net stats, but yeah, that setting is in bits if memory serves. Been a while since I've messed with it. ๐ Been so focused on UI stuff the last year.
Haha UMG? Nice. Thanks :D
Genuinely curious btw - if you don't mind; but what actually constitutes a "UI programmer"? Like - is it your responsibility to just wire up the UI logic or do you do slate stuff? Only reason I ask is because I've seen a few jobs with the title and I'm curious about it. Is it kind of like the separation for front-end/back-end in the web dev world?
I just feel like there is a ton of overlap with a regular gameplay programmer and UI programmer personally. So it kind of feels weird to have them as separate titles.
Can anyone help w this?
I think that highly varies by studio. I haven't touched slate until this last week at work. My main job is just creating new UI for new gameplay stuff. I've personally implemented an awards system for the game, but I don't touch most gameplay related aspects. I still have to be able to follow them though because I generally need to know if UI bugs are from my own stuff or from data in a gameplay class. But at the same time I've done a small amount of networking and such.
I did quite a lot of UI work in Unreal, and also am a Frontend dev at work. For me, somebody specialized in UI might be good at UX, sometimes design, and understands certain principles such as component based design systems, component libraries, how to build/architect a presentation layer, sometimes graphics, shaders... as always, it's hard to categorize.
I agree that at the core we are all programmers
Sure - but there is a difference between a UI programmer and a UI designer.
Yeah, I am talking exclusively about programmers
Are you not able to add instanced meshes from the sever at runtime? I am trying to replace an actor with an instanced version of itself but to no avail. ..not by having the server add it..or a multicast..or even have the client just do it themselves
Does anybody know if the order for clients receiving events is enforced
For example, if I have a server send event A and then event B, is it guaranteed that the client will execute A then B
Hum weird I got this error now when I tried to connect with my client to my dedicated server
LogOnline:Warning: NULL: No game present to join for session (Game)
LogNet: Client netspeed is 100000
LogNet: Join request: /Engine/Maps/Entry?Name=Alienware-R4-FAST-E843D7184BEA539370DC899D3BDC9F76?SplitscreenCount=1
LogOnlineSession: Warning: OSS: No game present to join for session (GameSession)
LogNet: Join succeeded: Alienware-R4-FAST-E8
it seem that it join but black screen on the client
I think the problem is the map
my game has a menu map and the main map... if I compile the server, I need only the main map for the default map ?
or I need to set the menumap as default map ?
If they are Reliable RPCs then yes, if not then no.
Iโm guessing youโve already been through RPC?
...RPC?
Using custom events to replicate, โฆ on client (run on client), โฆ on server (run on server), โฆ on all (multicast).
If itโs a replication error
ah ok
also lmao, I think I just saw one of your pull requests
hilarious
but honestly that's the type of commit I would pr too so no shame, typos embarrassingly enough are valid fixes
I kinda wanna submit a PR myself just improving the documentation on some functions
Well considering I'm a detail oriented guy, yeah I hate typos, bad names and stuff
Go for it
cause you know some of them will just be one sentence statements that literally explain nothing about what it actually does
Literally. And some are /*An octree*/ if you came by it already
I kinda wanted to document some of the stuff the other day, but no, enough of this stuff heh
Question about replication. I have an actor being spawned by the server, the actor has a replicated variable that is initialized by the server before I finish spawning it. Both clients can see the actor being spawned but only one of them can see the information from the replicated variable. I tried using RepUsing and calling the initialize function on the client but the game crashed because of the data being passed was null. How can I go about making sure when an actor is spawned both players know what the data is?
Thanks everyone for help, i managed to make root motion over network with predictions looks good finally
This is my current method on updating the player rotation
Although it creates this weird stutter effect when you are not the host
If I uncheck the character rotation setting it fixes the issue but then the character doesn't look up or down
So how could I use that code but make it so it uses the client as priority rather than the server?
I think you only need to run that code on the server, in the case of listen servers I believe it should only run on tick if the actor running it is not locally controlled that way it will update the simulated proxies but replication has been bustin my ass so I could be wrong here sorry
@mellow stag don`t use set actor rotation. Use control rotation
What is that node called?
I can't find it
SetControlRotation
its in the controller
yes
gonna try it out ๐
And do this only on client
How would I do it only for the client?
These objects are spawned by the server but only the client that initiated the loot box can see what data is in the pickup and the other client even though they can see the actors the data on them is invalid check the logs top left to see what I mean
Everything but the data on the actors is replicating properly. Even though the data is both replicated variable and initialized by the server
Show the code that initiates the loot box
initialize function on the client
If the client is doing this(No RPCs involved) then yes you're screwed. Only the server sets replicated properties for them to be replicated to other clients
No the variable is only set by the server
that is initialized by the server before I finish spawning it
I'm not sure how such a thing is possible, but you shouldExpose On Spawnthe property you want to replicate and set it once the actor is spawned(On server)
The server randomly picks a data asset based on some simple logic then spawns the actor from that data asset then passes that data asset to the actor when its initialized. All done on the authority and the data asset member variable is replicated
Im using spawn deferred where I can run function on the asset before I finish spawning but this is a good Idea I'll give it a shot instead of initializing the data
I see, never used that function before, so I can't tell if it's causing your problem(although I'm pretty sure it's not)
It is already replicated by unreal engine
I got it fixed, thanks
yea its a C++ thing. Blueprint does it by default I think
My best guess is because Im working with the Asset manager and these data assets are async loaded by each players controller something is going wrong. I tried to load with the server but nothing ended up spawning. Not much information out there about using the Asset manager in a multiplayer environment, but I'm sure they use it in fortnite so its definitely possible
Is there any good reason as to why this here
UCLASS()
class AMyActor: public AActor
{
GENERATED_BODY()
public:
UPROPERTY(Replicated)
int32 MyReplicatedVar;
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
//DOREPLIFETIME(AMyActor, MyReplicatedVar); <--- Not doing it
}
};
Wouldn't do a hard crash ?
Like the logs will warn me, but that's about it.
I just don't really see why it is just a warning as it seems very error prone
Is it okay to give TSubclassOf parameters on RPCs?
Should be fine, they are assets basically
I probably wouldn't unless the class is always loaded class for all machines. If it's a TSubclassOf some character that is normally loaded by softclass refs, you probably shouldn't. Else it's perfectly fine.
Is there a function I can call to prompt an Actor to replicate property changes immediately?
So if I change a property I want replicated asap...
Not really. Replication prediction happens at end of frame if memory serves. You could modify the actor's net priority, but that's a slippery slope.
What is so important that a replication needs to happen immediately?
in this case it's showing that Simulated Proxy is firing a weapon
it works ok, just wondering if I can improve it a bit
sometimes it doesn't pick up single shots for example
I already have specific RPCs for firing etc which are replicated via RPC, this is specifically the looping fire fx
Like I say, it works ok, would be better if I could set the bool and tell the Actor to replicate itself asap
/** Force actor to be updated to clients/demo net drivers */
UFUNCTION( BlueprintCallable, Category="Networking")
virtual void ForceNetUpdate();
this might do it ๐คทโโ๏ธ
That's not gonna work, no
Simply do not use replication for events
If you need every single data point to pick up on the client yes you actually need RPCs
Yeah I wasn't clear, I actually forgot how this system worked. All the important stuff is already RPC, the replicated bool is just for looped firing sfx/particles.
Tying this visual a bit closer to the shots is what I am trying to achieve
It seems to be working anyway
Although with low second client framerate it's a bit tricky to see for sure
I know for some of those effects people use an incremented counter.
Hi, I'm trying the Unreal's Collab Viewer Template, as it is out of the box. How do I find the IP of my computer so that my client device can connect to it? (over another wifi network)
I'm trying to add some multiplayer to my project but for some reason the client's character movement is fiercely stuttering, especially when I'm changing direction. I was thinking that it might be because for some reason my speed changes don't replicate but I hardcoded the speed in CMC's GetMaxSpeed and nothing changed. What might be the issue for this stuttering ๐ค ? On an empty project movement works just fine when launching multiple clients
Is your movement speed incredibly fast?
nope. 600.f
listen server, right?
yes. movement works fine on server
what I mean with the question is if you only observed this behaviour in a listen server setup
or if you had it aswell in a dedicated server
Actually there's even no stuttering on the client's character on other client and server instances
so it's only the listen server sim proxy that stutters
oh I'm not even trying dedicated servers yet. I'm just starting learning multiplayer
no, it's the other way around. from the listen server POV the client character moves just fine, but from the client's POV his character is stuttering
can you add more clients? and see if other clients stutter?
afaik this historical issue is only for the listen server sim proxy
I'm testing with 1 listen server and 2 clients to test authority, simulated proxy and autonomous proxy cases
so from client 1 client 2 also stutters?
no
or only server stutters from client 1 and client 2?
the server's character doesn't stutter at all
okay then who stutters
only client's character is stuttering and only autonomous proxy client can see the stutter
for simulated proxies and authority roles there's no stuttering for the character
Can you check if your client has the same movement speed as the server? How are you setting the movement speed?
well i think you are not udnerstanding what a simulated proxy is
I actually have some logic for setting max speed but I hardcoded it to see if that was the problem but apparently it wasn't
a simulated proxy is defined as the characters that you see in your screen
(in short)
except for the character that is controlled by the players controller, isn't it?
no, well it's contextual
you need to understand what is meant by that
tldr: the char you are controlling in your pc sees other chars
these other chars u see are sim proxies
except for the one u are controlling
which can be authority or autonomous
so everything u see in your screen that is controlled by someone else is a sim proxy
ok let me rephrase my problem then
I have client A, B and listen server LS. When moving player's character on A I can see the stutter on A. Both B and LS don't see the stutter in movement of A's character in their instances
so it's stuttering only for A and only for player character, not for B or LS characters which are also on the level right next to A's player character
the same applies for B but not for LS
ah so A statutters in A screen?
For me it seems the client has wrong speed data and server is correcting, that would explain the simulated proxies not suturing. I would suggest to print the speed, sometimes you think you set it correctly but you don't ๐
i was thinking about the same thing but i hardcoded the speed for testing purposes
I just asked because there is a historical issue in UE4, in which the listen server sim proxy would stutter and it's unsolvable unless you fine tune the config
i know that I am but i just want to find out what exactly ๐
mh rn i don't know if maxwalkspeed is being used somewhere else
but if you are getting corrections, it should be
k I'll try
Are you sure you are currently using maxwalkspeed and not run or something else?
i guess so i mean I'm using default movement mode and the MaxWalkSpeed is the one that is used in PerformMovement AFAIK
does exist some turtorial or guid how to create own subsystem ? and also questions multiplayer games like Battlefield etc are using own subsystem or subsystems of some platforms ?
okk so I added these loggings and what i've got is weird. While I was running straight client A didn't experience any stuttering and speeds were consistent for both A and LS but as I started turning left and right an obvious difference started appearing in logs so it is something about velocity. I guess I just have to find where exactly speed is changed when turning and why isn't it replicated ๐ค
turnrate? braking force?
which side of the bed they woke up on?
but I'm not changing any of those
guys How can I get info about server for example how many players are there if I am inside lobby ( not connected on server )
I want my game with max 2 players so I want to check if on server are 2 and then connect via execute command
hm I guess for this you need some service to do that, that talks to the game servers. Don't think it makes sense if each client asks each server if there is space or not. Maybe the EOS can help? But I never used that, so no idea.
How ever you could join as spectator maybe and then join a team if there is a slot left
That's just session data.
hmm
Hello everyone, I am making a system to change the player's material depending on the team he joins. I'm using repnotify for this, however if the first player joins, the second player joining the game won't see it's colour. Does anyone have an idea why ?
Also adding a delay makes it work for some odd reason
hey guys
i have a scope material
but it kinda fucks up in multiplayer
the scope shows the view from another player's scope camera
its the picture in picture style scope
how do i fix this issue
Literally impossible to say without understanding in-depth how you implemented your scope camera
a 2d scene capture component
and a plane that is set with that material
so it projects onto the plane as an image
the view static mesh is the plane
Yeah, I think your mistake is that you have a single render target for all players and then every camera renders on the same thing
so how do i fix that
ive made it so that only the owner of the scope can see the static mesh named 'view'
but it breaks when there are multiple players with scoped guns equipped
Did you try the fix I just suggested?
yes that worked
but then how can i have many players having a scope equipped at once
You probably do not want to have multiple camera scopes visible on screen at the same time if only for performance reasons - one is already a large expense
If you really do, you need as many render targets as concurrent scopes
server
client
as you see the client works fine, but the server scope uses the client image
Just disable the capture on other player's weapons.
only setting it up if the actor is controlled by the local player for example
C++ vs Bp if you want develop multiolayer game for market ?
Anyone know why another actor's widget component doesn't show for a new player ?
ok so i found out
it is multiplayer compatible#
bbut sometimes it switches views
the servers sees what the client is meant to see and the client sees what the server is meant to see
and the viewpoints keep switching as more weapons are spawned
every time, it switches to a new one
I am passing an int32 as a parameter to a Server RPC, but the value is changing on the server. What could be causing this?
it switches the viewpoint to the latest camera spawned in
well maybe you should spawn less cameras, and just attach one camera to the current equipped weapon from your local player?
c++ as it has more features^^
nice ,have u some experiences with developing some multiplayer game?
didn't ship one yet, but 'am working on one, so I'd say yes? But its simply a fact that BP doesn't have all features you could have if you use c++ \o/
Yes I want to start learn and try to develop for myself because I want own server own subsystem etc
hard times incoming
own server?
yes
I had a question
Do sessions work in case of joining public hosted servers?
and not LAN?
cause i am trying to add voice chat AND VOICE CHAT ONLY WORKS IF SESSIONS NODES ARE USED FOR HOSTING AND JOINING\
sry caps
hi all. I'm working on rapid fire weapons in an FPS now, rather than RPC per shot I just RPC on trigger state down or up and let each client shoot weapon using a local tick. How might I syncronize a random bullet spread in this case? thanks
did some searching and found a good disussion here #multiplayer message
Are you even doing local split screen games?
You have to keep in mind that this will always be broken in pie
If everyone has their own instance of the game they all have their own render target
But in pie you only have one asset and that is shared unless you play without single process enabled
pie = Play in Editor
Voice chat only works with that because there is a line of code checking if the person is in a session. It doesn't even matter if that's the server session
If you locally join a fake session it will also solve it
Might require CPP though
@pseudo merlin What i did for my system, which seemed to work fairly well. Was I did an RPC that was BeginFire() and EndFire(), and BeginFire would send off a Random Stream - and all I did was replicate the seed between server/client on fire
https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Blueprints/UserGuide/RandomStreams/
Explanation of random streams and how to use them in Blueprints.
Is PlayerArray not available in GameState in BeginPlay? Am I supposed to wait on some other event?
It is available but there might be other playerstates still being replicated
Which might take longer than beginplay
What's a suggested approach to have a consistent state?
Bind to an event on the game state that is broadcast out whenever the PlayerArray changes
And listen for changes
PlayerArray will change at runtime anyway
There should be some built in event for when my PlayerArray is populated with the no.of players in game
This is so inconvenient
Also one question: any function I run on GameState runs on all clients?
if you are asking if you can do multicasts in the GS, yes, you can
no..that's not what I'm seeing when I run a function on BeginPlay in GameState. It runs on all clients
This is in my GameState. Runs on all clients
because begin play runs everywhere in the GS, as it exists on all clients as James pointed below
right right, my bad
Unfortunately networking in BP is extremely limiting
How so?
aka the correct way.. still frustrating
BP will call an OnRep whenever that var is changed
Whether it's on the Server, or if the client changes it locally etc.
In C++ they are only called when a value is actually received from the server
I'll try once again ๐
Let's say I have an actor component that has an array of UObjects. For them to properly replicate. do I need to have an outer of the UObjects set to owning actor of the component or can I leave it at transient? (UE5.0)
Wondering about it, because I'll be moving the objects between different actors/owners (e.g. player drops item on the ground, so now pickable actor is owner of that uobject).
If so, what's the proper way to change outer of an UObject? I can think only of UObject::Rename and duplicating with NewObject, unless there are better ways.
If it matters, only server will be creating and marking objects as garbage.
- I have noticed, that if I have actor with UObjects and I collected them with another actor (e.g. picking up items from container). The UObject gets GC'ed on server, but on clients remains until the first owning actor is destroyed.
The objects can't use the component as the outer - only the actor
Client-side they will be created using the actor as the outer. But they usually cause crashes then when trying to destroy them etc.
this seems easy enough to take care of in Bps though
just update the var only in server context ๐