#multiplayer
1 messages ยท Page 455 of 1
Yes, it is
ok interesting
I'm pretty sure it's kept
"Persist" might be the wrong word. But you do get the chance to move data from old to new playerState
because now I am doing this very ugly hack of storing a lot of data in playercontroller and transfer the properties through the onswapcontrollers event
The PlayerState has functions for that too
OnOverrideWith
And OnCopyProperties
They are both more or less used for the same. I actually always loose track of what is doing what
yeah, I searched for OnCopyProperties but it wasn't blueprint available
but the OnOverrideWith is
the consistency!
(Slowly learning to do more in C++ as well ๐ but for some things blueprints just seem so much faster to use)
Can someone check out my code?
Well first off, limit your BeginPlay to Client only if that's the only one sending the rpc
Currently your timer runs on everyone
And then I have 0 idea what you are doing in that SyncLocation
That looks kinda horrible
You are passing teh PlayerController
Then you get all PCs
And filter for the passed one
What?! :D
I want to see and then correct the position of the player which sends its location according to the version on the server
You pass the PC, why do you need to search for it afterwards?
It's like "I have a red pen. Let's get all pens. Go through them and pick the red pen."
You had the red pen to begin with!
I pass the PC so that I can identify which player is it that is sending the it and can find it on the server's version
When passing it becomes the Server Version
How else did you think would this work?
A PlayerController, similar to all other classes, is a entry in the PCs Memory.
When you send a replicated Actor over the net, there is no way that what the Server receives is the Client#s PCs version, as they don't share any memory.
They are connected via a unique ID
So what you actually send is just the underlying ID
And that gets matched to the PC on the Server. So you already have the correct one
Okay got it
but I want to match the location of the server's version on the client which is sending the location
Do you want me to rectify my code first and send again before we get to that part?
@thin stratus Oh I see now, copyproperties is a function
damnit now I've used playercontrol while I could have just used the playerstate
is this better?
The fun part about refactoring is that you always know you will screw up somewhere
@flint plaza Kinda yeah, but you need to remember that LERP is for Static Values.
So static location to other static location.
You are however grabbing the ActorLocation
Which is also set
So this is constantly adjusting
You need to save the start location before executing the timeline
Also, in what actor are you doing this?
Pawn
Why are you passing the PC
And get the Pawn from it
If you are already in the pawn
Oops ๐ค
I'll fix that as well
how can I get the controller that I need instead of that?
Why do you need any controller?
You are on the pawn
All you do is get the pawn from the controller
But you are already in it so it's redundant
but I want the pawn that is sending the location
if I did get pawn on the server, wouldn't it get the pawn which is being controlled on the server itself?
Why "Getting" the pawn?
You said you are executing this in the pawn
So that code there happens on the Server Version of the Client's pawn
So let me get this straight
for example there are 2 players
1 playing on the server (listen server)
and other client
if I send the location from other client
to the server
will it be executing on the same pawn as the server on the server?
2 Players, ListenServer and Client.
Let's say only the Client has a spawned pawn (Server is just watching atm).
Client sees locally their own Pawn replicated. Server sees the Client's pawn.
If you call a ServerRPC on the Client, inside of their pawn, you'll remain inside the Client's Pawn but on the Server side.
These two Pawns (Client and what the Server sees) are two indipendent spawned actors, connected via a unique ID.
Modifying non-replicated values on server or client, will only change them in their version.
Awesome! That is something I would have never known.
1 follow up question: what if, in the current scenario, instead of the same pawn, I wanted to get another pawn?
Idk if pictures help you
But you could imagine Server and Client with their own little bubble as world
With more players, there are more bubbles
A multicast on the Server version of the Client's Pawn would then be an arrow to all client bubbles
Something like this basically
More or less
what if, in the current scenario, instead of the same pawn, I wanted to get another pawn?
That depends on what you need that for.
Getting a specific pawn is often not that easy.
You usually need another players pawn cause you interact with it
May it be via an Overlap or a LineTrace.
That way you usually get other player's pawns
You could technically also use GetAllActorsOfClass Pawn
But then you have no idea who is who
Correct
The booleans at the top are weird
Just get the Length of the resulting vector
And check that
Well, usually "BReplicatesMovement" takes care of sending the update to the client
But that is not interpolated
The pawn doesn't have normal movement
it has a hovered movement that I replicated myself
still doesn't work ๐ฆ
hey guys, is there an easy way to package a dedicated linux server executable? I know this can be done for windows. Also, if not, are there any metrics on windows dedicated server performance? thanks!
@buoyant hazel yeah, you could try connecting directly to each other, but it's very likely you'll run into issues with strict NAT etc.
hmm how could i do that
i just dont want my game on steam i rather have my game on itch.io
first player: open mapname?listen
second player: open ipoffirstplayer
thats the core of it, ideally you dont want your users to type console commands ofc
so you could save the started sessions in a database online and query it when needed
@fluid flower Is this the sort of plugin that could help with that? https://www.unrealengine.com/marketplace/en-US/slug/simple-upnp-plugin-resubmission-for-release Or is there a simpler way to achieve a NAT punch through?
not sure! I haven't dived deep into that issue yet because I'm focusing on Steam atm. I hope someone else here can chime in ๐
@fluid flower so is there a different approach to connections/matchmaking when using steam? is there some sort of package available for this?
when you use steam, the engine uses the steamworks api. And that api has NAT punchthrough built-in. So you simply call the create session and join session functions and it will connect you most of the time.
ahh, interesting
We've personally never had any NAT issues with it yet
the steamworks one works great, with the downside that you can't use it without steam
yeah
but that is only for having a player listen server, correct?
you can have multiplayer operate with a dedicated server infrastructure independent of steam or whatever else
yep
are there any services for hosting ue4 dedicated server instances?
Any hosting service will do
I mean for scaling. Also, Im still curious if you can create a headless linux build, because i only see information for windows builds available
but Im sure i could have missed something
You should be able to build your dedi for Linux using the regular cross compilation process
As to scaling you'll need your own tech
alright. ill do some testing
We are currently using Gamelift
^
@ivory portal Thats amazon right? is that just a layer above ec2? how do you like it?
It is quite a big step at start
but after you get the hang of it, it works
It is quite limited in terms of user profiles etc
and with that I mean, none exist
I couldn't even set it up ๐ฆ GameLift, I might give it a go in the future again
it is purely matchmaking and hosting
Are you guys happy with it so far?
Yeah, the price is good and the SDK works good
nice
just lack of documentation (or just so spread around) makes it hard at start
do they have a breakdown of prices, it's something that's hard to predict for me since its so much dependant on the game type/instance type etc
Yeah, on their website you can see the prices
I'm currently using frankfurt with spot prices
and linux servers (so 10 min intervals)
and its like 0.145 Euro/hour
cool, what type of game are you building if you dont mind me asking
yeah it seemed to be a lot more expensive indeed, I wonder how MS competes with their Azure stuff
I am having trouble replicating the spawning of a static mesh component to the client. on the listen server, both players are holding said static mesh, but on the client neither are holding anything. any idea?
(nvm)
there anyway to always replicate a value's state even if it doesn't change? i have clients set a bool variable locally to true, and do some prediction.
but at no point does the value change back to false (on server its false) call a repNotify that undo's everything.
i know everything works fine because the rep notify fires when the server tells client its true. things just get wonky when clients locally set bool to true because server wont replicate false state each update.
any ideas ?
are you using bp or cpp?
Yes indeed, we went to Linux after seeing the differences
The one thing with the whole Gamelift implemtation is a bit wonky at the fact that they put the code in GameMode, but that changes when you change your map (if your map uses a different gamemode) so I've put it in GameInstance at the moment
I have a question: Here's a bit of code that toggles a widget on/off for each player, and tracks the state of the widget via the PlayerState. It seems to be running as it's supposed to, the variables are getting replicated correctly and the functionality is there, however, when I run this on my Client, there is a very noticeable delay until the IsPlayerHandWidgetOpen variable on the PlayerState is updated, somewhere between 0.5s and 1s. How can I improve this?
(click 'open original' to see the full resolution, discord compresses horribly)
This is going to be a question where I already think I know the answer to... to build a dedicated server, you will need to use the github version of unreal or can we do it through the official launcher?
For developing:
Use the launcher version, in play settings you must have "Use single process" turned off. The big issue, is you don't have blueprint debugging on the server this way. (Dedicated) (You will be doing tons of print strings if you need to debug)
For shipping: You have to use the github version
Hello,
what do i need for implementing multiplayer in my game? Do i need to pay? I've heard about a server they have for this.. i don't know? Because paying for a server if its my first game is not possible if its expensive
@craggy hedge Hey. Making your game multiplayer can cost $0 if you so wish. In UE4 there are 2 models, dedicated server (Where you buy/rent a dedicated server, which will host your games, can get extremely expensive real quickly) Or Client/Server model, which means that one of the clients a.k.a players, will act as the server, this costs nothing, but comes with some drawbacks such as, that one particular player that is both the server and client, can easily cheat and such, not to mention that if he lags, everyone else lags, if he disconnects, the game shuts down (You can obviously write code to prevent this from happening, but by default it would happen)
So i need to pay for making a normal multiplayer?
Whats your definition of normal?
No, you dont have to pay anything
its free
But it comes with the drawbacks i mentioned
You said when another player hosts server?
yes
Cant i host the server and everybody else is joining me?
Yes you could
Players should not be able to host their own servers or rooms in my game
Just connect to the game and start the multiplayer matchmaking
How much do dedicated servers cost?
Ok
Keep in mind
How do i know what it needs to have on specs for beeing good enough for the game?
If you want your game to be played everywhere in the world
on top of paying for a dedicated server
you would need multiple
Like how much for like 100 players for example
Oh fuck
Are there sites where i can buy servers in multiple locations?
Ok so until developing a multiplayer game i need to develop smaller games and get some profit
Shit this wasnt my plan xD
But ok thanks for the info
You can still develop a multiplayer game
Dont worry so much about dedicated servers
People would still be able to play the game multiplayer
And you'll learn a lot
from the experience
Are there tutorials atleast how to setup the dedicated server then? :/
Yeah i will try
How would it affect my pc if i would use it as the server for like hundreds of players for example?
So i host and evertybody else joins
Eh, thats hard to say, your pc would have to be on all the time, and if it ever dies, your game dies
And can you tell me which specs are important on dedicated severs, i see some on google now but idk if SSD is needed, or which kind of hardware is the most important
That I can not answer, I actually want to know an answer to that myself ๐
Yeah obviously, but how much performance is taken per player or something or could it handle infinite?
Oh ok
The great thing is, switching between client/server model, and dedicated serverl model, is extremely easy
So you can develop the game the same way with both in mind
And decide in the end ๐
Later i want to make a big open world survival game
Like H1Z1 Just Survive
Im saying later, not yet dont worry xD
Once you become a millionare right?
Yeah that was more of a joke, but I hope you arent planning on taking that task on by yourself
So I have a strange bug.
On PIE, My character stands on top of a floating platform.
But if I turn off "Use Single Process" in the play setttings, which spawns a separate dedicated server that is detached from the editor, my character can no longer stand on this platform.. However, I can control the character as normal.
Oh, I should point out. This only happens after using servertravel
If I start the game in that map, all if fine, no matter HOW I start the game
If however, i start in the menu map, and then server travel, with "Use single process" turned off, then, and only then, my character will fall through the platform
I guess I should point out my platform is moving, which is based off a Character type
So,
I can tell, it WANTS to block, but it only blocks for like a quick second, and then the player falls through anyways
So, it would appear the block is happening on the client, but the server doesn't see this, and tells the client to forcefully move the character
I am looking for guidelines about how many collision spheres on a character are too many in a multiplayer game?
When an actor becomes network relevant (for example, getting closer to a distant actor), does the actor call a function when becoming relevant?
Is, for example, BeginPlay() called?
Since the actor has been re-created on the client?
I'm in need of a bit of assistance. atm I can apply damage to things as my character but only from the server, if I try on the client it give's me 0's. Any clue how I can fix this?
@elfin veldt only the server can apply damage and that is the only way it should be
also if a client tried to apply damage it would only show up on that client and not affect the actual game
if you want the client to have authority over the damage they do then you need them to tell the server to damage something for them but that is a really bad practice
okay, then I feel like I'm misunderstanding some very basic things
if i want two players to be capable of damaging each other how would I go about it?
Well, UE4 has some damage function for you, like "ApplyDamage" or whatever it's called.
Every actor has that and every actor also has the "AnyDamage" event.
And the ApplyDamage event has to be called on the Server.
Same for RadialDamage and such.
So if an attack is launched by a Client pressing a button, you have to ServerRPC over to the Server and let it deal the damage.
@elfin veldt
I've got the advanced steam sessions plugin to work, but when it gets the players name, it caps it at like 20 characters
is there a way around that?
i get the player name from the player controller -> get player name
@thin stratus i know you probably hear this a lot, but your network compendium was really helpful
i really liked that it was straight to the point, and not wordy at all
(: Glad it's helpful!
I'm not quite sure I understand. Is Apply damage not already being called on the server?
No, it's limited to servers
So that clients can't/shouldn't call it
It doesn't automatically call it on the server
ahh, i get it.
a big thing i didnt understand when i first started multiplayer is that you need to be aware of who will be running whatever code youre making
for example, when a character spawns
the server and all clients will be running begin play
on that actor
so you can use the Switch HasAuthority bp node or a branch with the IsServer node
or you can use the IsLocallyControlled node
but its important to pay attention to who will be running code as you make it
so for example if you have an input event like a key press
and directly try calling ApplyDamage on that exec chain
it wont work if the key was pressed by a client
I think there is a bigger picture you have to take.
It's not really about "Who calls what?", because that's just a sideeffect.
What you need to understand is, that Replicated Actors are existing once per Game. (in most cases).
You gotta picture a bubble for each player (including the server).
And if you have a replicated actor, that actor exists once in every bubble.
And the RPCs help moving from one bubble to another.
E.g. your PlayerController exists in your own bubble and once on the Server as a copy.
If you ServerRPC, you go to the Server Version of that actor.
Some Actors also only exist in one bubble, like the GameMode only exists on the Server.
Something like this
@thin stratus is the multiplayer lobby kit on the marketplace the one that used to be called multiplayer lobby system
has a different name but its in my library
yeah i got that for 4.18 over a year ago and helped me learn a lot about multiplayer
id recommend that one to anyone trying to learn
Yeah it's a lot different in 4.20 now
also handles all the "backend" stuff and lets you focus on gameplay logic
I would recommend not touching the pre 4.20 version anymore
The new version properly utilizes Seamless Travel and concentrates more on the "how to move data from lobby to game and back."
And cuts away the actualy gameplay part for some VERY basic test gamemodes
sounds like a huge improvement lol
i reworked the 4.18 one to support dedicated servers for my last project but the menu layout is still the same
but all im really saying is thats a good learning tool
To prevent people sharing . sav files with unlocked items, is loading / saving on launch using PlayerState->GetPlayerName() as the SlotName a valid way to go about this?
This way if online with steam, it SHOULD always load / save only to the steam username
Unless it's trivial for people to edit the .sav files to change the name
Not really a multiplayer issue
Sorry, just thinking through steam and regarding people seeing skins in game
you would need to validate that through steamworks
But generally, if people want to do it they will, PC platform has 0 security on file editing.
It's pretty much impossible if you don't reward the stuff on server side in the first place.
It's all P2P so I guess I'll just not check at all
Even if you stop them from sharing, if aquiring the skins can be done offline, you can just grant it to yourself anyway.
Yeah ListenServer setups aren't really worth worrying about
I find it incredibly impressive that people manage to figure out how to do that, like how can they find the line of code that unlocks an obscure skin? Or is it simply setting some memory address that enables it?
Most memory address stuff
Probably quite trivial if they know what they are doing, especially since there are many ue4 games that they are familiar with
Thanks a lot
Saved a lot of work and headaches
Will leave it all local and not try to prevent it
If you want somewhat safe save data you basically need to store it on servers and don't let clients modify them directly, but only through your safe deidcated server.
And there will be a good chunk of people who don't cheat.
Take Risk of Rain 2 for example.
The game has characters you can unlock
All offline stuff
I could unlock them by cheating, but that's really not fun at all
Yeah I'm not conncted to any backend afaik
Ok so it's only really the people who really want to cheat will do it
That's cool
Great example
People were sharing modded .dlls that allowed for 16 player lobbies for RoR2. I don't know how they managed to do that.
Part of the fun of these kind of rewards is the challenge of getting them, just wanted to prevent it. It seems risk of rain 2 is completely peer to peer, correct?
The most funniest thing ever was how Assassin's creed two was cracked.
They brought up the "You have to be online." shit
A server was validating some codes whenever you reached a new mission.
What did they do? Made a custom Server, let someone legally play through the game, record all traffic, and simulate that with the custom server.
people will always find ways ยฏ_(ใ)_/ยฏ
๐
wow
Yep ok I'll go ahead with the mentality of "they'll do it, don't worry about it"
Instead of preventing
Which could cause split saves, and lots of problems for legit players playing offline etc.
Or is the game Buy2P and customizations are achieved through playing?
No store
It's just for fun, the items don't matter
It just would be nice to think all players earned them by playing
Don't worry about it then
Point is, if you don't make money by selling items.
Then why care in the first place
๐ very true
If you however build up the game on a customization basis, then yeah you need to prevent them from cheating
By the way while you are here eXi, do you think Risk of Rain 2 did anything special to network the extreme amount of stuff happening on screen in later rounds?
Not sure how much you have played but there can be literally thousands and thousands of text widgets spawned per second
And it appears that they are all replicated
Not to talk about hundreds of AI and individual projectiles
I'm quite impressed that I haven't experienced any side effects from latency or anything playing on a peer to peer network
I was at like 70-80 min runs with 3 players
So I know how much shit can be on the screen
It's not UE4 after all
So it can be really cheap on bandwidth what they are sharing
- the graphics are already pretty forgiving
Or is it ue4?
xD
That's true, I'm just thinking purely on the amount of data / individual RPCs that have to be sent
It's Unity.
I think it's Unity
Just seeing that UE4 can hit the bandwidth limit of 10kb/s with a few default characters walking around (unless you change the limit)
Code the game. Check the bandwith. Cut down whatever calls too often with too many bytes.
I find it crazy to see all this additional stuff on the screen with no problems over p2p
Risk of rain is AFAIK?
ListenServer != p2p
Oh is peer to peer where no one is the true host and they all keep state?
Sorry
What numbers should you aim for for server out netbandwidth?
Still yep over the listen server I'm impressed with the amount of stuff sent per second
Yeah RTS like P2P is something we don't really see today anymore
I'm going to run some tests soon with UE4 spawning loads of text actors like that
But as far as I can tell you'd need to call an RPC every time you deal a specific type of damage to spawn an individual widget
That could be like thousands per second
Technically yes
We have something similar in Hoverloop, but not that many of course
Do you notice saturation / slowdowns or am I treating RPCs as more expensive than they are?
Unreliable in this case of course
Can you get away with thousands per second?
Well they are unreliable to begin with
They are dropped for more important stuff
You don't need to always see the numbers on your screen
And if you really need to, you could simulate most of it locally
The client also knows what the bullet/spell should deal
Ahhh true
So you'd just simulate firing of the other client on your machine with an "is firing" repnotify or something
Thing is, with enough time, you can do a lot of stuff in UE4.
And do all the cosmetics on your screen
It just might not be fully accurate
But with a game like ROR2 it doesn't need to be really
10.000 pedestrians walking randomly around during runtime at 60fps. Every pedestrian avoids other pedestrians as well as obstacles. Part of the traffic system I made in @UnrealEngine for HALVR. #ue4 #gamedev https://t.co/yp91sgwG7k
226
1606
Just as an example
Not multiplayer, but 10k AIs
Damn impressive
Yeah hehe, she did a good job on that. But did also only work on that client, so enough time to optimize the hell out of it.
So if you have a enough time (and c++) at your hands, you can do risk of rain 2 amount of enemies and Ui stuff
I'd assume you'd need custom movement to ensure it's all blazing fast
Default CMC is very expensive in comparison for many actors
But very inspiring stuff, I'll aspire to get there one day
These aren't even Actors.
... Wow
But I can't really tell much, NDA.
Of course!
That's cool though
Super barebones
I wonder if the UI stuff would also need similar work or if tons of widgets can be spawned in worldspace
Will test soon as a fun project
IF, UMG is the bottleneck
So I'd have to use slate?
You'd see yourself using Slate in the end.
Ok
I mean for simple text I'm sure it's doable
No experience with slate though have to look at the docs
At the end of the day it's spawning a camera facing number and destroying it after a few seconds, challenge accepted!
have to look at the docs Good luck.
Yus. :D
Well you wouldn't spawn camera facing numbers
You spawn a UMG widget that gets posititioned on the screen to match the projected world location
I assume RoR2 stuff is also screenspace
Ohhh ok, so worldspace stuff would be more expensive / overkill?
I'll try first with UMG and profile
So it's all 2D but just in screenspace
Interesting
I had seen those fancy 3D widgets and thought it'd be that
But I guess that's more for very specific stuff or VR
You can set a 3D widget component to be screen space
Which does the math for you
But that is kinda weird to use for damage numbers
I guess... maybe it can be utilizid
But it kinda dislike how annoying it is to access that component if it's meant for you own ui
If it's just a simple fire and forget widget, spawns on bullet impact, destroys itself then I shouldn't have to access it again- will look into it
Thanks for the great chat
Learned a lot (have your mp guide eternally open in a tab)
Appreciate your great help making it much easier to understand mp stuff in UE4
Many a thanks btw @thin stratus I think I understand now. at the very least I've got it working.
Does anyone know where _Validate functions are processed and kick players if they return false?
reading a generated.h with one of those should provide a clue
I think it's handled somewhere quite low level in the replication system IIRC
@glacial pollen Yeah. I am testing a new Gamelift implementation but... needs to be compiled with Target=Type.Server
so out of luck ๐ Downloading the 4.22 now
Let's see if 4.22 is really faster compiled
Hey, I seem to be having some issues setting the materials on a replicated actor. It gets spawned from the PlayerController with a RunOnServer Event - this in return calls an event inside the Actor's BP which sets the mesh and material based on passed variables. The mesh is getting replaced correctly, but the material isn't .... any ideas? o.O
I also tried setting the material directly in the RunOnServer Event that spawns the Actor but no dice either...
Hey is anyone familiar with utilizing WebSockets with an UE4 game? We successfully did a HTML5 export, but now want to set up online matchmaking via the web
@celest geyser rep notify in the actor's BP. had this problem last week
use the rep notify function to change mat
@slender yarrow Where can I find that? I have 'Component Replicates' turned on on the StaticMesh component, and these are my settings in the class defaults
well for example in my game, I spawned the players for the first time from the gamemode when the first enter the server. I then set a rep notify variable the lives on the actor bp FROM the gamemode. That activates the rep notify function on the actor bp which changes the material on all so all clients can see
rep notify is under the replication options on the variable by the way
hm, I tried swithcing around the replication settings on my variable to no effect ๐ฆ
ah, let me try it from the PlayerController when I spawn it
aaaaaah!
and I set the material in the function!
that worked, thank you! ๐ ๐
๐
These are still unique to the instance of the actor, correct? Meaning when I set the repNotify variable on one instance of the actor, it doesn't run the OnRep_Function on all of them, correct?
well it does run on all so they can all see the change, but it will only change the mat for that specific actor.
youre welcome
So i have a question for anyone: I have a little shop menu pop up where you are able to buy killstreak rewards. This is obviously a client UI. Im wondering how I would be able to buy a killstreak from that UI on the server? I cant visualize a way though because the UI is absolutely deadlocked to the client and theres no work around to have it be able to talk to the server. How does one approach this?
I feel like the click events on the UI are the only way to trigger setting the required variables for this.
@slender yarrow communicate from the widget to a server rpc in the player state where the server can validate and activate the reward
Hey is anyone familiar with utilizing WebSockets with an UE4 game? We successfully did a HTML5 export, but now want to set up online matchmaking via the web
@graceful cave ok so to the playerstate. I will give it a try
for a round timer, should it just be a replicated timer that the server runs or a timer that the server runs (but doesnt replicate) and a multicast that kicks off on the clients when the match starts or a client joins? seems like replicating one less thign is always good
@vital steeple have the seconds value as a byte and the cost of replicating it is basically nothing
just a byte variable for seconds then another for minutes?
naw should be 10-20 min
if they go to 255 then they deserve the timer to stop working
thanks for the recommendation, thats simpler
i'm having an issue where a local function call is being called before my replicated server call is completed.
In the lines,
playerRef->AlterHealth(baseDamage, instigatorRef); playerRef->UpdateHealthUI();
the first line is a replicated server call in the player while the second line is a local update to their UI. My issue is that the second line is sometimes being called BEFORE the 1st line finishes running. Is there anyway I can make the 2nd function wait for the server call?
So I have an idea that i want to know how possible it is. I want to figure out how to make time stopping a thing in my multiplayer game. I was wondering if you could desync the time stopping character from the server then resync them, if that would allow you to move while everyone else was not moving.
or maybe there is another way
Okay, this looks fine....
Wait, wtf is this? Simulated proxy? On a player controller?
If I check the controller directly, i get the correct answer:
1 player, dedicated server. BodyPartComponent is a part of Mech_Base which is owned by my player controller
hey could i call someone who knows alot about multiplayer and blueprints?
any idea why i can only fire weapons on server side?
ok i explained this badly
the server player can fire and the bullets are spawned on both the client and server but if the client player fires, the bullets are only spawned on the client
Well then your not telling the Server to fire the bullets on the Clients behalf.
Or at least, your not telling the Server that the Client wants to fire a bullet, the Server should then decide if that Client is allowed to.
Anyone know if I can replicate the bUseControllerRotationYaw variable on the PlayerController? Basically my pawn is always using the movement component for yaw unless it's the server or the client's owned pawn.
@fossil spoke any ideas?
I'm spawning an actor in gamemode, and the client thinks its Simulated_Proxy.... but its single player... with a dedicated server...
How many bytes is a FVector_NetQuantize ?
Or what is the range assuming it isn't static?
The size of the object itself is the same as a normal FVector (it inherits from it); it's the serialization size that is affected. Like the docs say, each component can take up a maximum of 20 bits in the serialized version.
Yeah, there's also a header on the serialized version to provide that number, however, so you'll have to factor that in
// written (size = Log2 (MaxBitsPerComponent)) to indicate how many bits are actually used. ```
Does the real serialized size depend on the contents then?
I'll ask again, and hope someone pings me in the morning:
I have a dedicated server, with 1 client.
The game mode spawns an actor, with the client's player controller as the owner.
If I call get local role, on the client's actor's begin play,
I get Simulated_Proxy....
In a single player game....
If I call Actor->Get owner, i get players controller...
If I call Actor->Get owner -> Get local role....
I get Autonomous Proxy...
What can be wrong?
I've tried turning off single process,
turning off auto connect
possessing the actor (character)
Spawning the actor on gamemode, or on the clients player controller on the server side.
The really weird and final point I would like to note:
If direct my output from Simulated_Proxy, to code/blueprint that runs under Autonomous _Proxy... it works... I can make calls to the server's copy of the actor, and the players controller...
If it works why am i here? Because this shouldn't be happening, and it makes coding/blueprint confusing, I have to remember, that for the main character, to treat it differently than everything else I was taught how this is supposed to work.
PlayerControler: Role is correct
Another players actor : Role is correct
Client only spawned actor : Role is correct
My own actor : Apparently is another client's, even though i've tested with a single player...
Hi ..in my multiayer project vehicle movement lags idk how to solve this issue
Any suggestion or ideas
On steering and also on accelerate there is a lag on the vehicle movement
Like jittering
@next warren How did you implement replication ?
Vehicle replication is no small feat
I m working on thd sedan template project..
The vehicls replicated
When the person presses f he enters the car then he posses the vehicle then on accelerate or steering movement there is a lag like jittering
In vehicle game when i simply play with run as dedicated server there is no lag or jittering... in this project i m getting the jitter or lag
Will u give sme suggestiin or ideas or workflow bro... @bitter oriole
@next warren My question is how the vehicle is replicated
Replicating movement is very involved
Why it doesn't work well depends a lot on how you did it
1.I created a wheeled vehicle bp
2.then i simply replicated the sedan in replication category
3.then i implemented some of the controls for throttle and steering
So you just ticked "replicate position" ?
S
S ?
Then it's normal that it doesn't work well, because outside PIE where the two players are connected directly, network lag destroys this
Think about it : you move on a player, tell the server you moved
Then the server replicates movement back to you
But when it replicates, it is a position / rotation (transform) that was older than now (basically as old as your ping time)
So it goes back
Vehicle movement is way more involved than clicking replicates movement, which only really works for initial location of objects
There is no much tutorials for vehicles so i m not able to get the ideas
In vehicle game demo it works well on playing run as dedicated server
It won't work over a network
Multiplayer vehicle is hard. Here are the main ways to do it :
- Client-authoritative, where you keep your regular physics vehicle, tell the server where you are, replicate the location with the "Skip owner" condition so that you're unaffected, and add some interpolation on remote clients to smooth out the movement. People can cheat very easily that way, so beware.
- Server-authoritative, where the server is told your player input, simulates it entirely there, tells you its own version ; while the player also simulates locally. This is known as rollback + replay, if you want to know more there' a great udemy course for UE4. This prevents cheating, but it also prevents using physics vehicle.
Right now what you have is client-authoritative, but bad
If you want to fix it, it's quite easy, but beware cheating will be impossible to prevent
Thanks for taking ur time to explain my doubts
I will try to apply ur ideas in my project
Will u send some of the youtube tutorials link for me i searched for two days still i m not getting good videos
If you're going to keep client auth, what you need is extremely simple :
- a RPC call from player to server on tick to send the current position, rotation and velocity ;
- three replicated variables that have "skip owner" as a replication condition ;
- on non-locally-controlled vehicles, on tick, set position / rotation / velocity to the latest replicated value
The last part will need smoothing at some point but it will work much better already
For the second approach (server auth), you'e going to need a much more involved course, and C++
The vehicle game demo project will it support multiplayer
I played it with run as dedicated server there is no lag in that project
If that supports then i can simply use that vehicle bp
There are no built-in multiplayer vehicles in the engine or sample content. There is at least one plugin for (client-authoritative) physics vehicles on the marketplace
And you need to test your projects in the real world for multiplayer. Run two games locally, one as host, the other connecting to it, with the engine packet lag simulation enabled
And test on real networks with multiples machines once you're pretty sure it works
If it wouldn't be such a pain to setup server-authoritive movement (specially for vehicles and such) I would push out something just for learning.
I'm still somewhat sure that it's possible to create a generic movement component that allows extending via BPs.
But would need some new variables types
hey guys how would you implement relative team/healthbar coloring, e.g. when my team always be blue, while enemy team always be red
Check team ID in player state for each player, blue if same as local player, else red
Is there a way to check if the window has focus in BP ? I have an edge scroll function that gets called on tick, but I want to only fire it if the window has focus
by window what you mean? your game screen? or umg widget?
Hi guys I'm barely new with this multiplayer stuff and I'm trying to find the server session as a client, so I wonder if when I run the game with the checkbox "Run dedicated server" checked, it creates a session automatically?
Sorry for my English, it's not my first language.
Ok, thank you!!
@humble comet My game screen. When I test in PIE, I only want the edge scroll function to run whenever the PIE window gets focus
so that when I switch between different PIE windows for testing, my screen doesn't scroll off into infinity on the unselected window ๐
@celest geyser FSceneViewport::OnFocusLost() there must be something like this in this case
hm, I can't find anything corresponding for BPs :S
yeah, seems like there are no corresponding bp nodes for this ๐ฆ
I'd really love some help on this issue. I'm trying to get a Projectile, which is using a projectile movement component, to work in multiplayer. The spawning is working fine, although it spawns 2, but it's movement is wrong - https://streamable.com/kd9bn
This is where I spawn the projectile, it's only done on the server - https://gyazo.com/c1f59ce01a107a583ce5845c1efb975e
And the Initialize() function called when spawning the projectile - https://gyazo.com/b2a27db058b97f016c35b39caf585e53
@bitter oriole i m not finding any multiplayer tutorial for vehicle
One video found that too they are not doing anything simply replicating the bp(self)
Youtube channel (unreal tek) topic replicated vehicle @bitter oriole
@next warren Simply replicating won't really work.
Like I said
I pointed you toward two clear options ๐
@next warren There's a pretty good (apparently, I don't use it) plugin on the MP : https://www.unrealengine.com/marketplace/en-US/slug/blue-man-vehicle-physics
It's client authoritative, so cheating, but right now that's the only way to have physics anyway.
Can someone please help with this one?
@past rain the fact it spawns two is your first problem
Yeah, the functions are being called twice, even though Im telling it to only run on the server
which is what I cant figure out right now
Show me the event
Do you mind doing this over screenshare?
I'm at work
Use share x
You can do partial screenshots and it's auto copied to clipboard
Which you can paste here
Already got one of those, this is the event - https://gyazo.com/ce21b47055efcbe48ebe4bb48f08369c
When the player presses left mouse button Fire() is called
shit
That whole function should be auth
So the if statement at the top simply tells the server to run this code
but then the client runs it too?
Only the fire function
You need to control the entire function on server
Unless you like cheaters in your game
Fire :: if auth :: spawn
like this?
Would I remove the Role < Role_Authority?
Okay let me try
see if its called twice
Okay now it spawns once! so thats an improvement
however, the velocity is wrong
It just goes down to the floor like in the video, rather than where I aim
(Works fine for the server, but not on the client window)
Make sure it's replicated
All the components
Including projectile comp? (Not sure)
They dont have replicate
but this is the blueprint for the projectile https://gyazo.com/01502bc3eece2b865f29668eed3968df
Do I have to somehow Continuously update the movement to the server?
I mean, it does move, just on a fixed direction
which I did not set
No
Projectile movement comp does all that
If it works on server but not client
It's not being replicated
Make sure the mesh and collision is set to replicate
Because the movement components move the collision cylinder
And the mesh should be somehow attached to that
Directly or through another parent
The only replicate variables the mesh and collisioncomponent has is this - https://gyazo.com/f712bcbf10cb39fbb62975d222dbe06a
Im looking at Epics shooterGame example, and their projectile rocket, which uses projectile movement component, dont have these on, so they are irrelevant
I have the relavant replicates on
When you spawn do you set the owner?
For the projectile?
Okay, who is the weapons owner?
If you say the character, then tell me who is the owner of that
The point being, you should be able to follow the chain of owners down to a player controller
Why is match-states an FName and not an ENUM? Also, why does the documentation miss any mention of the different match states ๐
So the server can know who owns it
@ivory portal I would wait for unreal to release their new cross platform multiplayer stuff
Just get basic multiplayer and work on the rest
Yeah this is a bit messed, the owner of the clients weapon, is the server weapon
Unless you need to release this. Year
That cant be right
Projectile-weapons-char-playercontroller
YOU CAN EVEN JUST DO:
projectile-playercontroller
Weapons-playercontroller
Char-playercontroller
I do that, but I have a complicated attachment system, and it depends on attachment points to determine "parent" which is irrelevant of network owner stuff
Okay what about this
The most outer owner of any actor should always be a player controller
I need the playercontroller in teh weapon class, because I do the ray-tracing there
If I have the owner, I cant find a good place to initialize the controller
if that makes any sense
No it doesnt
The controller is given to the player
That controller is the link between the server and client
Any other actors are owned by that controller one way or another
I just mean I need a reference to the player controller in the weapon class, so I can use functions
Simple
Function:
Role < Auth(
Get player controller 0
Do x)
Why does this work? Because the client cannot see other controllers so 0 is ALWAYS its own controller
ohh
Now if you said role=auth, then it would matter
Because the server can see EVERYONES controller
To solve that is also easy, just pass the controller from the client during your rpc server call
So the server knows which controller to call back on
so I could simply use UGameplayStatics::GetPlayerController(GetWorld(), 0);
to get to the player controller
locally
Yes, BUT USE role= anotumous proxy
(I have a weird bug right now where I get simulated proxy) on an actor, but anotumous proxy for it's owner
So I might not know what I'm talking about xD
No one has answered me, so I can only try to help at this point
You're being very kind
The ownership is correct now
The character owns the weapon
Its a bit different now, but still wrong
Just goes to that exact spot no matter what
again, only on client, not on server
checking
remember, at the end of the owner chain, needs to be a player controller
Trying to log the owner's name in players begin play
crashes teh editor
So.. no one?
Just check where you spawn the character
Player is spawned instantly
I havent gotten to coding the game mode, I only have a blueprint version of it
default pawn is set to the character
okay cool
so the owner of character SHOULD be the player controller
i promise the crash, is a one liner
this is the crash
without debugging symbols
it is
But logging the owners name sholdnt cause it to crash?
Its already spawned in beginplay
Let me try logging it someplace else
You will want debugging symbols... eventually
its shouldn't crash there, and you need to find out why
you can't ignore stuff like that, and hope it goes away.
Logging it anywhere crashes when I want it to log... so I guess getowner = nullptr
Also, try getdisplayname
for some reason
then check for nullptr
But I am guessing
a proper crash log would tell you if its a nullptr
without having to code it in constantly
Who is getdisplayname a function of?
its a blueprint thing
not sure what it is in c++
UKismetSystemLibrary::GetDisplayName(Object)
Also: GetActorLabel() . You don't need to use that namespace.
Please note that GetActorLabel() only works in development build. Here is the official documentation for the same: https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/GetActorLabel/index.html
Hope it helps
Returns this actor's current label. Actor labels are only available in development builds.
Display name is correct
and checking if getowner is not nullptr, makes it not crash
So my character doesnt have an owner
How exactly is that possible?
because, you need to stop thinking, that your function is only called once
I bet
if you did
controller not equal null :
do this
controller equal null :
break point here
it would hit
For example,
Server, client 1 client2
Server spawns Actor1 for client1
Actor1 begin play : Server, client1, client2
role: Auth, Autnomous, Simulated
client2, will CRASH if you use get owner on Actor1
because its null
Getowner is nullptr in singleplayer too though
wait
I might be dumb
one sec
nope not dumb
Character dosnt have an owner in singleplayer either
Even single player, is still networked
hmm
If the char, is owned by the server,
and you call get owner on the client
crash
So I need to setowner in the constructor/beginplay?
I'm not sure why your default pawn does not have an owner
Are you using gamemode, or gamemodebase?
base
Also, get into the habit of using role = whatever, on begin play
so you know who is running
also, if something doesn't run, when it should you will know the owner is not set
I'll keep that in mind, but as you said, the owner should be set, I do that in the gamemode bp
ummmm.
Should I try switching to gamemode instead of gamemodebase?
you can't set the owner for the default pawn, as the built in code, will do that already
Well apparently it does not
Sure, so block it
not in this case at least
by overriding
SpawnDefaultPawnFor
inside of that
spawn actor, and link the input player controller, to the owner, of the spawn node
and output that spawned actor
also, break the transform apart, so it doesn't complain
Should I do that in the game mode c++ class?
nah
blueprint?
simpler to test in blueprint
do quick tests in blueprint, to make sure it even works, before you pull your hair out, because you missed stupid piece of code, and thought it didn't work
Yea
Set Default pawn class?
change your gamemode
I never used gamemodebase
good to know that override is in gamemodebase
let me make a new game mode
change that to your custom char
IF THAT DOESN'T WORK. Then you have something really wrong.
Default pawn
do I remove the playerstart thats placed on the map?
by finding playerstart :p
so do u want me to try and log the owner now?
yes
log the owner in gamemode, when you spawn it
and log it again in begin play of actor
also, do role checks in there
(in blueprints its : GetLocalRole)
Okay, now shoot
the only thing that changed, is the fixed spot where the bullets go
but they all still go there no matter what
oh wait
NO
WAIT
wait
wait
my bullets go
where the servers crosshair is
not clients crosshair, but the servers
server is also a client btw
is this because I do the linetracing server side only?
no\
its because, you do mouse movements on the client
and you don't tell the server
That is meaning less
Where are your auth checks?
Where is the RPC call to the server?
I thought that was done automatically when its the character
at least the WASD movements are
Character Movement Component, has replication built in
AddControllerPicth input, is NOT a part of the CMC
You're right
so do I create custom functions, and in those functions, make sure we are the server, then call the AddControllerPitch functions?
yes
Okay brb
OnMouseMove :
If client : call serverMouseMove
ServerMouseMove: add pitch input
in one, because mouse input is basically ticked
no need to run the function twice, just pull from both events
If Im doing these functions myself, how will I get the Val (-1 to 1)
this is what i have so far https://gyazo.com/41438d35c4f6bd690e89969df17c2bcd
how can I check each projectile variable on collision?
OnOverlap/Hit -> get actor -> Get variable
Thats basic blueprint stuff
@past rain Yes, that looks better
Cheating in blueprints, one function call, for both mouse inputs xD
I looked at how the pawn functions moves the mosue
and they do AddControllerPitchInput(Val);
AddControllerYawInput(Val);
adding those in didnt work for me though, cant move mouse
Look for auth checks
is locally controlled?
Also, make sure, that in char has UseController Pitch/yaw/roll enabled
default settings I think?
yea
I personally, have trouble, depending on what I am trying to do
you have to play around with those
Also, rotate controller != rotate actor, UNLESS use controller xyz is on
Also, rotate actor != rotate controller, if use controller is on!
Anyways, lunch is up. I gotta go. I might peek in later
evo
just wanted to thank you for all the help so far ๐
Im trying to look at Epics shootergame example, they used https://gyazo.com/10224c70f3953674883e602b5db92342
So how tf did they replicate mouse movement
I dont think replicating mouse movement is the way to go, if we just locally linetrace from the client, and tell the server of that position
should work no?
@glacial pollen pls dont leave me ๐
I just checked, and the issue is that since the fire function is only run on the server, Hitlocation (the line trace) is run from the server perspective
Not from the clients
thats why all my shots go towards the servers crosshair
Ahh
Yeah, When i shoot from my client, my hitlocation is that of the servers
Well the issue is
You can't trust client
Line trace should happen in the server
Or people make aim bots
Okay so how do I get the clients starting location?
?
Actor-getlocation?
so I need the start point to be the client that is shootings position
but this is server side, and the server is a client too
so it wouldnt work
when a second client shoots
You miss my point
Server=player1, player2 right?
So
Auth, autonomous, simulated roles
EVEN THOUGH PLAYER1 IS THE SERVER
It's STILL AUTONOMOUS
AND AUTH
For player 1
At least how it should be
The role of e.g; the pawn owned by the listen server will be authority on the listen server, rather than autonomous
You basically have three net roles for actors
Auth, autonomous and simulated
Auth = server
Autonomous = remote client for owning player
Simulated = remote client for non-owning player
If you have a listen server, the "server" owned pawn will be auth on server side, simulated on client ; the "remote" owned pawn will be auth on server, autonomous on client
That makes sense, so if Im doing the line tracing server-side, Im still not getting how I'd do it so that it uses the clients information
Haven't followed the conversation before so feel free to refresh me ;P
Okay so
When player 2 shoots, the projectile goes to player1 (server) crosshair
The hitlocation of player 2, is the hitlocation of player 1
no matter where player 2's crosshair is
Does that make sense?
small video showing it
Thats what happens
I want each player to have their own hit location
This is my fire function
Right, this is very much expected given the code.
Educated guess : GetCrosshairHitLocation uses the player controller (well, its HUD)
It does
But on the server there's only one viewport, and that's the server's.
exactly
So of course it aims there
The solution is easy : do the trace on client first, and send it over to the server
Your Fire() method would take a vector parameter
where would I calculate it client side? Fire is called from the player