#multiplayer
1 messages ยท Page 167 of 1
i just dont know what the "own client" thing is for when its not really working
I tried dooing it on a normal event but it still plays when the server does it
Your logic doesnt really make much sense tbh
You come from a Multicast
then Rep back to server (coming from the server)
why wouldn't you let the server run the same logic server side ?
going back and forth is not steps you wanna do for fun
uhh i did play the animation and wanted to do the remaining code on the server because its the hitbox and dmg that comes at the notify
Multicast means its gonna run on both server (already) and all relevant clients
yeye the animation should play like this
yes, but you should have a clear flow on this, and avoid going back and forth
the problem is the "shake cam" event
No, the problem is your entire setup
Hmm
Another thing is ofc how this is set up regarding which animation to play. This could be far cleaner and more maintable code
i didnt knew how else to solve this tbh
In a 6 client scenario, this is what's going on
Client 1 is the server?
Client 1 is an example owner of the character
it could be any client. All other clients would ignore the Server RPC
sorry, its a bit wrong
there we go
Run on Owning client , as the table shows, is ran on the invoking client if its not the owner
5 clients playing a camerashake they cannot see
Anyways, I cant recommend much more than to clean up your logic, get an overview view of the flow, and try to think of a better way to solve this..
Whenever you're duplicating code (like you are, with Play Anim A, Play Anim B etc) you're in 99% of the cases doing it wrong (or atleast hard for yourself)
Client 2 dont see the camera at all, because its not his pawn/view target
Didnt work, so resorted to subclassing and overriding it.
The mess or the code? xD
the mess is the code is the mess
i mean i figured it out meanwhile i got it somehow working xD
you can not live like this
its an old single player project im just trying to get into multiplayer
Bro i have a worse one wait
no
For a Dead by Daylight's generator repair challange kind of a thing what would be the best approach to both keep server as authority for the result and reduce the effects of ping as much as possible?
literally delete all of that
Funny part is i know where everything is
i mean yea some of this is just dead code thats true
no for real just throw it out and start over. That's like a hoarder's house.
don't try to clean it, bulldoze and rebuild
lol
hell naw i have too much time spent into this xD
About one and a half year i dont delete that
I'm considering to send TotalTime, PerfectTime and Tolerance to client to setup visuals and expect on server the amount of seconds passed on clien'ts pc between input and challange start time to decide if it's a fail or success
But would it be any different than just sending true or false from the client?
Doesnt dbd update your challenge and points whenever you leave a gen?
not every second?
So you can make it count and give the points when you leave the generator
Hmm I'm not sure if we talk about the same thing, I mean the thing that pop ups from time to time that requires you to give an input at a specific time
I don't mean the accumulated repair points
(sorry if i got this wrong i am a bit special)
ohh okay then i dont think i can help i am new to multiplayer stuff xD
Ah okay, thanks for trying anyways
np
What in the heck? Kill it with fire. How do you even read that? Actor components and function collapse all of that nonsense.
I can't even.
i mean i learned with this project so i tried everything there
I'm over here with this complaining...
Yea i could never
My locomotion system that ties into all of those repnotifies.
if i start like this
i would sit 2 hours just perfectionizing it xD
and tbh i would take equal as long to find stuff, i tried to make everything clean on another project
for me it really doesnt change idk im a messi person
What happens if anyone else tries to work on it or help you? lol?
They instantly leave , or start a new project
You should strive to become less messy. If clean isnjust as troublesome for you, then you probably have a bad naming habbit for things (and possibly bad design choises?)
Ofcourse, you can ignore this if you're for eternity just gonna solo dev something, Then you do you^^
Yeye if it starts to really annoy me i would clean it up
and one day i will probably do but i need the time and energy for this xD
You'd be off my team instantly ๐
Even if you could understand and track this, everyone else touching it would have a horrible experience ๐
yea i know
My tire model back in the BP prototype days
Oh no. How hiedous๐ฑ
Scrap it, try again
Pretty clean tbh
Id probably collapse some into functions
The top part(s)
ok
void USLMDeviceSubsystemWheel::PreSimulate(float DeltaTime)
{
for (auto& Wheel : DeviceModels)
{
if (Wheel.Collider)
{
const auto SteerSignal = FMath::Clamp(DomainSignal->ReadByPortIndex(Wheel.Index_Signal_Steer), -1, 1);
Wheel.SteerAngle = FMath::FInterpConstantTo(Wheel.SteerAngle, Wheel.MaxSteerAngle * SteerSignal, DeltaTime, Wheel.SteerRate);
Wheel.DirectionWheelAxis = Wheel.Collider->GetRightVector().RotateAngleAxis(Wheel.SteerAngle, Wheel.Collider->GetUpVector());
Wheel.DirectionLong = FVector::CrossProduct(Wheel.DirectionWheelAxis, Wheel.ContactPatchNormal);
Wheel.DirectionLat = FVector::CrossProduct(Wheel.ContactPatchNormal, Wheel.DirectionLong);
Wheel.Velocity = Wheel.Collider->GetComponentVelocity();
Wheel.WheelMass = Wheel.Collider->GetMass();
Wheel.ImpulseBudget = Wheel.NormalImpulseMagnitude * Wheel.FrictionCoefficient;
Wheel.ImpulseAccumulator = FVector::ZeroVector;
}
}
}
void USLMDeviceSubsystemWheel::Simulate(float DeltaTime, float SubstepScalar)
{
for (auto& Wheel : DeviceModels)
{
auto AngVel = DomainRotation->GetData(Wheel.Index_Mech_Drive).AngularVelocity;
const auto WheelMOI = DomainRotation->GetData(Wheel.Index_Mech_Drive).MomentOfInertia;
const auto BrakeSignal = FMath::Clamp(DomainSignal->ReadByPortIndex(Wheel.Index_Signal_Brake), 0, 1);
//Brakes
const float MaxBrakeImpulse = Wheel.BrakeMaxTorque * BrakeSignal * DeltaTime;
const float BrakeImpulseToStop = -0.1 * SubstepScalar * AngVel * WheelMOI;
const float BrakeImpulseClamped = FMath::Clamp(BrakeImpulseToStop, -MaxBrakeImpulse, MaxBrakeImpulse);
AngVel += BrakeImpulseClamped / WheelMOI;
//Grip
const float DesiredAngVel = FVector::DotProduct(Wheel.Velocity, Wheel.DirectionLong) / Wheel.Radius;
const float AngularImpulseToStop = (DesiredAngVel - AngVel) * WheelMOI;
const float LinearImpulseMaxSizeThisSubstep = FMath::Abs(AngularImpulseToStop * 10000 / Wheel.Radius);
const float SlipSpeedLong = Wheel.Radius * AngVel - FVector::DotProduct(Wheel.Velocity, Wheel.DirectionLong);
FVector ImpulseToStopLong = SlipSpeedLong * Wheel.WheelMass * Wheel.DirectionLong * SubstepScalar;
const FVector ImpulseToStopLongClamped = ImpulseToStopLong.GetClampedToMaxSize(LinearImpulseMaxSizeThisSubstep);
const float SlipSpeedLat = -1 * FVector::DotProduct(Wheel.Velocity, Wheel.DirectionLat);
const FVector ImpulseToStopLat = SlipSpeedLat * Wheel.WheelMass * Wheel.DirectionLat * SubstepScalar;
const FVector ImpulseToStop = ImpulseToStopLat + ImpulseToStopLongClamped;
const float RemainingImpulseBudget = Wheel.ImpulseBudget - Wheel.ImpulseAccumulator.Length();
const FVector ActualImpulse = ImpulseToStop.GetClampedToMaxSize(RemainingImpulseBudget);
Wheel.ImpulseAccumulator += ActualImpulse;
const float GripAngularImpulse = -0.0001 * FVector::DotProduct(ActualImpulse, Wheel.DirectionLong) * Wheel.Radius;
const float TotalImpulse = GripAngularImpulse + BrakeImpulseClamped;
AngVel += GripAngularImpulse / WheelMOI;
DomainRotation->SetAngularVelocity(Wheel.Index_Mech_Drive, AngVel);
}
}
void USLMDeviceSubsystemWheel::PostSimulate(float DeltaTime)
{
for (auto It = DeviceModels.CreateIterator(); It; ++It)
{
if (It->Collider)
{
const FVector Impulse = It->ImpulseAccumulator;
const FVector AngularImpulse = It->DirectionWheelAxis * FVector::DotProduct(It->DirectionLong, Impulse) * -1;
It->Collider->AddImpulseAtLocation(Impulse, It->ContactPatchLocation);
It->Collider->AddAngularImpulseInRadians(AngularImpulse);
//Debug
const FVector DrawDebugStartPoint = It->ContactPatchLocation + FVector(0, 0, 120);
DrawDebugLine(GetWorld(), DrawDebugStartPoint, DrawDebugStartPoint + It->ContactPatchNormal * It->NormalImpulseMagnitude * 0.1, FColor::Blue, false, -1, 0, 5);
DrawDebugLine(GetWorld(), DrawDebugStartPoint, DrawDebugStartPoint + It->ImpulseAccumulator * 0.1, FColor::Red, false, -1, 0, 5);
It->NormalImpulseMagnitude = 0;
}
DeviceCosmetics[It.GetIndex()].AngularVelocityDegrees = FMath::RadiansToDegrees(DomainRotation->GetData(It->Index_Mech_Drive).AngularVelocity);
}
}
I could but what's the point of a function that's called in exactly one place
extra BP runtime for.... what?
Can just collapse the whole graph if I don't want to look at it but it's all the same, that IS pretty much the whole thing
I cant imagine the extra bp runtime showing up anywhere at all while profiling
Still what's the point of a function that's called in one place
it's Event DoTheThing, just do the thing
The reasoning would be somethingnlike separation of concerns, and getting a higher pov without having to delve into every little detail
better global view
Just don't go Uncle Bob on me here enforcing 1 line functions
I would guess something like 70% of my functions are only ever called once
Perhaps more
I never make a function unless it's getting called multiple times
it's just an extra "Turn to page 3 to continue the adventure" when reading the code
those variable pins tho ๐คฎ
i love them
maybe rn i would just re add the get of the var
instead of making it 1km long
For sure, it is. Helps keeping the code readable tho. Which has some value. I would makenfunctions outnof every little setter (unless it made sense, like me reacting to it or smth), but splittingnlong chainsninto their exact purpose is meaninful imo
it's logically the same and probably compiles down to the exact same bytecode but it's way more readable
maybe i should make tiktoks of me cleaning code
might be satisfying to match xD
are these the before or after
Now here i see potential
yes
Those are both the before tho
nope
where's the after
Yes they are.
if you zoom in there are changes that make it very anoyying to collapse in 1 function
Pins might be swapped, or the values are different, but its the same thing
so i stayed with 3 splitted
yes you can
from my POV its pretty clean
add more of those blue object getters
so you don't gotta play chutes and ladders to see what you're calling something on
Its not the worst, but quite a stretch from 'perfect'
the good part is that with how i work now, stuff is so splitted in modular parts that i cant make a single screenshot anymore
i guess i glowed up
What's more readable, this?
or ?
or this
yay i win
disregarded
๐ fine
lol
Sure 60k remote i'll take it
You undersell yourself
I work outside of games, super low COL area. I'd take 60k remote working on a cool project over 120k on-site at Joe's Shovelware
Not joking, I'd take that. But it'd have to be a cool project that I believed in.
Otherwise no interest.
i got the same mentality, people around me absolutely wants to get in big studios
for me im more about the "what is the project of the game and the leaders of it"
So Epic disables Replication Graph for console builds because it does not support split screen, yet Fortnite has split screen on consoles and uses Replication Graph.
Where is the lie?
Fortnite uses Iris?
So i guess the lie is their use of rep graph๐
And they prob have fixed support on their fortnite branch. Afterall, its their money printer
As above, I'm pretty sure it's a different (internal) build from what we are getting with any version.
Reasonable. I do the same, altho the COL here is quite high so cant go below necessities
So all i can (have balls to) do atm is part time game dev, and full time my other job
I also dont like the volatility in the market...
Christ, yea this makes it look differently for sure. It is still not horrible, but it is far from a smooth experience when using the "bad" network settings that UE provides
Right that is actually a good point. How common is the bad scenario that Epic provides? Ofcourse there are lots of places on earth that will have a bad connection, but generally speaking in the western world, is it a common scenario?
Gotcha! To be fair, I am going to need to translate that to bad internet in Europe as I have no idea how bad internet can get in the USA
That is crazy
you shouldn't even have rubber banding to begin with in editor
Given you're asking this because you trying to evaluate whether you should bother or not... it depends. In our game, we made shooting as seamless as it could get and not even 9999999 ping will give players the sensation it's not working (although it won't). That to say: bad network emulation means bad, really bad, and it's probably not your typical - nor the typical user audience - of most games, but you do you and it's up to you to decide what to do with it.
In our case, another example - 400+ ping we simply stop replicating lots of stuff, to avoid the bad connection player to compromise the network even further.
Yea for sure. I need to look into this as I reckon it is not actually rubberbanding, but something in the functionality regarding lerping to the server provided transform
delay != rubber banding tho, are u sure it's rubber band?
This makes sense. In that case, I am going to take a look at it for 2 days maximum to see if there are some cheap wins I can do to provide a more stable experience for everyone in the 10 to 100 ping range, and beyond that I won't be looking at it for now at this stage of the project.
Wait
I don't have early context but your game isn't stable for 10-100ms?
Yea exactly. It definitely has something to do with the Lerp, but I haven't looked into it fully yet. The interp time is currently set to F 0.0, which i think is the culprit
Not entirely no. When i simulate the average settings (30-60 ping) then there are some glaring issues that are annoying to the experience
Yea well there's definitely something you gotta take a look at before emulating bad connections and all lol
depends on game, games like valorant or fortnite, as soon as you reach 50/70 ping, you bullets wont go straight away and you feel it
That's because those games weren't made in Blueprints. If they were made in Blueprints, they would run smoothly. ||/s||
the visual part will be executed right away
Yea I will do that first haha
Also, the parts that aren't super smooth is the physics sim being communicated to the clients
can having a lot of subtrees in BTs be heavy for the server ?
No - it all comes down to what you do with them.
idk what optimization i can do regarding AIs
We're using HTN so I'm not really sure whether subtress in BTs tick, but if that's the case, the #1 optimization is avoiding expensive lookups in them. Use Blackboard to assign data you need.
im using regular array for my Item and Cosmetic structs
looking at small scale listen server 4 player co-op game with less than 200 items all together
should I be using FFastArray?
50 items each player?
They definitely used Rep graph in Fortnite when it was introduced.
Maybe they replaced it by Iris though.
Lmao, i set interp speed on Transform Lerp to 0, which meant we were jumping from update to update, creating a rubber banding look. Setting interp speed to 25 entirely fixes this issue for the average network preset, and creates a pretty smooth experience for the bad network preset
Take a look at my plugin if you want a reference.
ty, will do
Anyone know the route to take to have a server event add widgets to client side Player Controller? Im hearing this is not a direct process but im getting mixed information on the approach.
That's because it's a loaded question - depends what it's for
definitely this one looks better
if it's for notifications or something, use ULocalMessage
it is for an interaction widget. the player gets widget, presses button, advances game
One way I know of is to use a Run on owning Client RPC triggered by the server. You can also pass data from the server into the widget that way.
Thanks for the replies. I had been attempting the RPC but I don't think I fully understand it yet. Gonna take more time to research it. I basically have a turn based game like a game of cards between 2 people. Im just trying to figure out the best approach to how players interact with the listen server and vice versa. player 1 makes a move, turn is passed to player 2. P2 takes turn ect
Are the checkboxes for replication client-side predictive & server side reconcilable?
Physics simulation is run on both the client and the server. Updates are sent to the client from the server. The following struct is used to describe the physical state of a rigid body, and is replicated (as defined in Actor):
No - all on you.
What makes Unreal Engine "easier" to write network code then?
Does it?
YouTubers that don't ship games said so
haha
idk, it was like in their marketing or something
Youtubers teaching networking in Blueprints?
lmao
More like "GamesFromScratch" vibes
or engine comparison people
I heard it a lot on the internet that Unreal Engine makes it really easy to make multiplayer shooters like Unreal Tournament.
Fake
Unreal Engine makes it possible, not really easy.
I shoulda been an Electrician apprentice
If I know how to program decently well and understand the problems with latency etc, is there any benefit to using Unreal Engine over just writing netcode from the socket level?
But to be fair and in all seriousness, Unreal abstracts away all the UDP/TCP stuff for you. That's serious business you don't have to worry about when doing multiplayer in UE.
99999 benefits
You don't have to conciliate your netcode with the Game Framework hehe
I wrote a turn-based game with TCP and I think there's a number of libraries out there that do easy UDP for you.
I'm okay with processing packets.
Can you explain ? I don't know what you mean.
big word I never saw before
So you decided to create your own netcode. Cool beans. You have raw data in hands. Now you need to: create your communication channels between clients and the server; make your data go through these channels until they arrive into Actors. You need to handle handshaking. What if a player has disconnected?
Yeah, I wrote all this before a couple times.
The only thing I messed up was client-side prediction/server side rollback.
I said 'all on you' - and after shipping 2 networked games, I swear I'd hate it if it was any different.
It's pretty simple to do this thing you want. And Unreal allowing you to have control over this flow is just Epic doing you a favor. =p
Unity? Netcode? Where? ๐
Hey there, I have a perfectly working multiplayer game but what I did is possibly uselessly complex. It's made of infinite tetraminos like puzzle pieces which I generate on the server (on purpose) and dispatch them around, to players near them.
Classes:
PuzzleManager: Keeps list of streaming sources
PuzzleStreamingSourceComponent: Keeps list of associated puzzle pieces
On tick, the manager that has authority looks at the position of sources to know what pieces they need.
If they don't have something they need, it sends its data with a reliable RPC.
The streaming source adds it to its associated list then sends it to the manager which meshes it.
The result is that a client manager only has the puzzle pieces of its player(s). The authority manager has all the puzzle pieces.
No iris, no repgraph.
Was there an easier way to do it?
I'd bet (and win) if DOTS netcode (or DOTS altogether) got deprecated(tm) in 2 years from now
From what I saw, you still have to do like a lot of the network stuff.
How does it get easier?
You just ignore player prediction/rollback?
Most (attention: most, not all) of the network work you have to deal with are based off the design of your game.
They do, i saw one of them spawning actor with multicast
and everyone was thanking him
Yeah, I thought maybe Unreal could do the players, and projectiles "for" me.
But based on what I saw in a course, it looked like that was not true.
Is it? I feel like there are something like 10 different game genres.
Nope. Projectiles are serious business. Now imagine having to creating all the projectiles logic PLUS your own netcode, heh.
Ah, also @cinder carbon............... if you go through the Compendium, keep in mind all those things would have to be crafted by you in case you go with your own netcode
(I was referring to our socket friend)
(Although I'm certain you know it, heheh just making it crystal clear so I don't sound dumb)
ugh
i forget this thing pings
Based on all the networked multiplayer shooters out there made in Unreal, it seemed like people could crap out an Arma clone in a week haha.
took me a sec to find it.
This one right?
https://wizardcell.com/unreal/persistent-data/
Well, that's for templates.
That one two, although it's a little bit more advanced; this one: https://cedric-neukirchen.net/docs/category/multiplayer-network-compendium
๐ค
Like you have FPS, RPGs, turnbased variants, RTSs, Editable terrain games, racing games. And MMOs but those are special.
If you cover a basic template for all those, I feel like you covered everything in the genre. And they're all the same between eachother.
I do like the control of writing my own netcode so I could design unique multiplayer games.
I was willing to sacrifice that if I could have an easier time in Unreal with prediction/rollback.
oh I thought bottom was
haha
I don't know what to say.
Nothing needed for that message.
If you are considering Unreal, the only reason I can possibly think of as for you not using its built-in netcode is exclusively performance.
You cannot ship a They Are Billions multiplayer using the current netcode
Right now I want to just make a small "Call of Duty arena multiplayer" style game as my first networked game.
100% possible
and not just possible, if you are committed to C++, you can get it to run really smoothly
but avoid casting if you're using blueprints otherwise you won't achieve 0 ping ||/s||
"built-in" multiplayer meaning I still have to write all the server-side rollback, etc myself?
yes, but what's the problem on that? don't you want control over it?
if you want to skip this work, get yourself a template - there are tons on the marketplace multiplayer-ready that can get you the arena shooter in a week =p
(don't promise it will perform, but hey)
https://www.unrealengine.com/marketplace/en-US/product/multiplayer-shooter-with-cover-system look, this one even gives you a full-featured cover system!
I wouldn't bother doing shooter with blueprint
how dare you
I couldn't find the templates section.
I see some samples, but those look like Epic Games' thingy
first task, make your character sprint with bp
I believe there's no template section.
spoiler, gonna hit a wall
Just search for 'shooter multiplayer'
(omg i just realised how many of them there are)
Yeah.
The main reason I was looking at Unreal is because I thought at least the built in-"character" blueprint type and "projectile" would have prediction and rollback.
Thank you @whole grove and @gloomy tiger . I'm going to read through what you've given me and assess what I am capable of or if I should go back to making a single-player game for my next project.
I'd like to make a multiplayer game, but we'll see.
Movement is done for ya
Just shooting is not - but again, you can rely on some third-party solution for that
I'm not really sure, but Epic's Lyra may have some projectile stuff
It's a non-competitive PvP/PvE (MP with bots).
I do need it to be projectiles because the guns are slow moving projectiles.
Check this out if you may: https://www.unrealengine.com/marketplace/en-US/product/lyra
So if I "just check the replication button" on a "character" blueprint, the movement of a player character if using Unreal's character movement system will "just work" to an "shippable" degree?
Yes
I know a lot goes into making a game. I shipped a few.
I just don't know much about server-side rollback etc.
Perhaps it's already defaulted to checked so you don't even have to click a checkbox
Opening the Lyra game project.
Read this with a grain of salt. It depends on your goals. 100 moving characters at the same time? No. Non-bipedal characters? AFAIR, no. Now if you're going to have somewhere between 1-20 bipedal/humanoid characters, probably yes. Then if you need to tune it up even further, there is this amazing plugin called SmoothSync - although to make movement smoother, it uses some exploitable techniques (aka if you care about protecting your game against cheaters, not for you)
https://x157.github.io/UE5/LyraStarterGame/ this is a good place to start
Just looking for some clarity make sure im understanding at this point. Clients can only interact with the server via the use of the actor they own?
i was attempting to use widgets for on clicked events to produce the games outcomes, but if the above is true I think I may have to use in game actors of some sort instead to the same end
widgets can't network
they can talk to things that do though
I was attempting this through the PC's Actor, but think I still need to read up more first as im not getting the desired outcome.
Correct
Rpc's from client to server only work on that clients owned actor
thank you for the responses. Is helping out tremendously.
Take stephen's multiplayer shooter course on udemy, it teaches you how to do all that
This is the one I was using.
https://www.udemy.com/course/unrealmultiplayer
you want this one, he teaches you how to write your own rollback system, lag compensation techniques, the lot, if you see the trailer your mind will be blown (mine was before I took it lol) https://www.udemy.com/course/unreal-engine-5-cpp-multiplayer-shooter/
lol
๐คฃ
Lag compensation and rollback are interesting topics, but I'm really not sure about the snippets of the player controller class that are shown in the preview video, and it's using Cascade for some reason in UE5?
but I suppose it's not a VFX course
so yeah all the HUD logic is in the player controller like this for some reason
which seems like a circular dependency hell, rather than just having delegates that the HUD elements subscribe to
I personally dislike Lyra. But hey, that's what our friend wanted so. ยฏ_(ใ)_/ยฏ
Lyra is "it has some cool things, but don't base your game on it" to me
Lyra and perhaps all templates in existance? That is, if you're going into business - not talking about prototypes, hobby projects, learning purposes etc etc
ShooterGame was also like that
but that didn't stop people from basing their games on it
Right hehe
Until the boom
(Not even the boom prevented people from base their games from it lol)
Someone got a good multiplayer lobby/host/create tutorial to recommend?
I don't remember using Cascade, we used Niagara. And it's a really great beginner multiplayer course
How about using blueprints only for multiplayer, it's doable right? I mean you really don't have to only use c++ for doing multiplayer. I'm not sure how complex can bp do with multiplayer, compared to using c++
it's doable, but it's definitely more annoying
Really? Can you give an example?
nah ive heard that with multiplayer, you will hit a point where you have to do c++
Oh, I see.. can you give some example what kinds are they? Well, simplest example I know is clienttravel, it doesn't exposed in bp AFAIK, only servertravel.
i wouldn't konw tbh since i usually try to do a lot in cpp anyways xd
Good for you.. I made multiplayer using blueprints only, it's a dedicated server. so far I can manage everything. Maybe I just haven't hit that point where I have to do c++
What type of game
Is very relevant
Why isn't there some kind of blueprint to c++ conversion tool yet? Couldn't something like that be made possible with the help of AI?
But it would be so much faster to make a blueprint then single click have it converted into c++
I tend to do things a bit differentlynin cpp vs bp
whoever makes that is gonna be rich, just saying
BP2CPP originally did that, but it really is just different paradigms
And it now works^^
Machine generated code tho, not human readable , atleast thats what i heard
that's what I was mentioning, BP2CPP was originally going the human readable approach but that changed, but forgot the exact reasoning
but I imagine it's hard to map it 1:1
right, so that's where some clever AI would be handy, no?
when the Blueprint header preview was added in 5.1, that at least made it easier to get started with hand nativising a class
the BP properties get remapped to the C++ ones properly now too
I don't trust AI to do a competent job so you're asking the wrong person
About time, ive had the worst time converting old bps
Or even new mashups made in bp...
even if it gets the file 90% there id be down to use it and fix the rest
would save a lot of time
well hand nativising a class is pretty much an intern's first task
I think it's pretty common to just do major systems in C++ and BP is then for smaller things and prototyping
avoid the problem entirely
BP to make it work, c++ to make it better.
that sounds like the wrong way round
depends on what it is tho
the major system being in C++ is "making it work", and the smaller things in BP is "making it better"
well im not about to make some level actor like a door or something that opens and needs to be replicated with c++ first
depends how important doors are to your game I guess, but we did have breachable doors and it was written all in C++
Timelines are chill to work with
it had some interesting replication challenges on its own
I cant even imagine what that looked like ๐
doom style doors
BP to prototype, C++ to make it fast and elegant
I couldn't find the projectile code in Lyra.
I think it's raycast projectiles.
I mentioned I was unsure whether they had projectiles. Sorry.
Hello. How can I find out players traveling from the lobby to the game map have completed the traveling?
Oh sorry.
It's all good.
BeginPlay? xD
You may be asking the wrong question. What does completed travelling mean?
All clients completed loading new map after servertravel
FCoreUObjectDelegates::PostLoadMapWithWorld
is replicating an array of 100 component references expensive?
In general... yes. It'll be quite a big packet size. But this is a really complicated question tied to several nuances.
Yes, sorry I only just saw your message. It's my game
well, the array never changes throughout the course of the game
its only populated at the start once
Probably whatever then
i see
It'll be quite a big packet nonetheless (to answer your question about 'expensiveness' more specifically)
@hoary spear I'm getting crazy with the movement issue for days, I thought I solved it and it's coming back like GameOfThrones seasons ๐ญ
And you decided to poke me about it ? ๐
Yeah because I need to share my suffering with someone ๐ And possibly to get some help if possible ๐
what would be a way to get server stuff from editor utility widget ?
It would be easier if you just went ahead and asked away
Why you would do that in first place?
The issue is I don't know what to ask and what to show as the problem makes no sense ๐ฅฒ
i want to create custom debug tools, a part of it needs to access the AI controller at runtime
the issue is, the AIcontroller is null when try to access it
alright then, good luck ยฏ_(ใ)_/ยฏ
noooooooo ๐ญ
Like I have a controller and I derived children from it and I want todisable movement and look input when joigning the game level but I don't know why it doesn't work properly
Your problem is not a multiplayer problem, your problem is a scoping problem. It goes beyond me how EditorUtilityWidgets would access the scope of a UWorld, but still, not a multiplayer-related question so please refer to #editor-scripting as your question fits better there.
i can access most thing like the player controller of a selected actor
but not AI controller, thats why i suspected its because it only exists on server side
๐ค
Of an actor you selected in the Editor, right?
Are you running this PIE with a single player?
yes
Hehe... so how is that related to multiplayer? ๐
i mean its running on a dedicated server
so still MP
just a server with 1 player
got the same issue if i spawn more
Right. And you're right. AIControllers don't exist for clients and should never exist.
yes
its weird that on editor i cant access those :(
and for more context
- this will print when selecting a player character
- this will print nothing when selecting an AI character
It's not weird. It's how things work. AIControllers don't exist for clients. You have to bridge your communication via a proper channel, such as your APlayerController. You send an RPC to the server requesting data of your AIController and you use the resposne to work with.
RPC doesnt work on editor :/
tried
๐
its like the editor BPs are cuted from the MP system
i can try one more thing
leme check
Well, I don't know what to answer, sorry.
What is not working?
yeah RPCs doesnt work
no pb, ty for trying
Ok let me explain better :
I'm having a MainMenu Level, a Lobby Level and a Mansion Level and each have a specific controller.
MainMenu Level = Pc_MainMenu (controller)
Lobby_Level = Pc_Lobby (controller) derived from PC_Core (controller)
Mansion_Level = Pc_Werewolf (controller) derived from PC_Core (controller)
On PC_Core, there are 2 methods : OnRepIsLookInputEnabled and OnRepIsMoveInputEnabled that I can switch from the server to enable or disable those inputs on both the clients and server. Both of these variables are set to true by default so the player can move and look around when he joins.
What I want is when joigning the Mansion_Level, I want players to not be able to move until all players have successfully travelled from the Lobby_Level to that Mansion_Level, then I launch a countdown of 10 sec then allow them to move and look around so nobody has an advantage over others in the game because they joined earlier than others.
The first issue I have is for some reason the client joining the Lobby_Level that the host created, he can't move or look around but the host can do that and I don't understand why it's not working properly with the client. And the client can't press the game menu by pressing T so it's looks like the whole inputs are disabled instead of just Moving and Looking like I wanted.
The second issue is when travelling to the Mansion_Level, the client can't move or look around (so that's good) but on the server I still can move but the look around I have to left click and drag the mouse to look around which is a weird behaviour. I also can press P to see the values of both variables to see if the server and the client versions of those variables are the same or not but on the client pressing P does nothing and I can't even press T to open the game menu (containing Continue, Settings , Quit button).
You probably want to simplify this whole process.
-
On your GameStates (one that exists on Lobby and Mansion), have a repnotify
bAllowedToControlboolean,falseby default. -
Use
GetGameState()->bAllowedToControlto do your logic inside the different PlayerControllers. -
Whenever you want to allow people to move, just make your server
GetGameState()->bAllowedToControl = true
One last thing: in your OnRep_bAllowedToControl you can broadcast/dispatch a delegate (which you can bind to in your player controller) so you can react to changes.
I mean, this is more or less what you are already doing, but by having things a little bit simpler/clearer and in the right places, it'd be a lot easier to make sense of what's wrong.
Inside the OnRep_bAllowedToControl should I get all the players in the game to disable / enable their controls ?
No - you broadcast a delegate and then in your player controller you listen to it
I'm not sure to know how to properly do that
You just need a delegate that takes a boolean as an argument
I can't put arguments on Dispatcher, could I ?
You can
My bad found the Inputs section
So like this ?
It's a multiplayer night club where player just connect to a dedicated server, and if someone is there also, they can voice chat, sit down, dances, I think currently that's all what the people can do. Just boring stuffs. We haven't made any gameplay that might give reason for player to keep coming back. It's related to coin in cryptocurrency, so the most possible action is at least collecting points (that later can be converted to crypto coins), and spending points or coins in the world like buying digital stuff like drinks, or maybe some apartments, or building
I think it's a pretty simple stuff in context of gameplay and logic, everything can be handled by BP and without c++. And until now I haven't got any need of using c++
Currently I only have 3 maps:
- Login map (singleplayer, for auth)
- menumap (singleplayer, after auth, loading player's data from mysql using varest, and save it to game instance variable, and show it in UI, and there's a 'Play' button, which only open level to ip address and port in aws.
-ServerMap, it's the multiplayer dedicated server map, where player joins the game in multiplayer. Right after joining onEventPostLogin, playerdata from game instance struct variable is loaded (so loading from rest api only loaded once after loading). Players Running around voicechat, sit down, dances.
But something in mind is. My server level is ServerMap. What if I have another ServerMap2, ServerMap3 (so I have 3 levels). And I want my players can choose which level they want to go. So if there are 15 users, maybe like:
- 4 users in ServerMap
- 6 users in ServerMap2
- 5 users in ServerMap3
From what I read, we can use clienttravel. But cannot do it in BP, using node open level or console command clienttravel will not work.
Or am I missing something?
I have made a run on client event on my server, which passes to an actor, which passes to a player controller, (the client) to remove a widget at a certain time. The widget has been removed for the client, just making sure this approach is valid as I know seeing what I want is not necessarily knowing what I'm doing.
As long as the run on client event is running on an actor owned by the client that you're wanting to remove the widget from, then there's nothing specifically wrong with what you're doing.
thank you, is appreciated. Just like to make sure I'm not moving forward with incorrect understandings.
The open level nodes causes the client to attempt to open a specific map which isn't useful in multiplayer.
You'd use "open <ipaddress>:<portnumber>" in the "Execute Console Command" node in order to have a client travel to a new server IP.
how can I test creating sessions on a dedicated server inside unreal ?
i know how to do it with a listen server, but not with a dedicated
Tried that but I still have the issue ๐ฆ
PIE should be able to read in active sessions. So if you start your dedicated server instance on the same machine, a PIE instance in the editor should be able to display that session in a UI like a server browser.
I'm running into an issue with trying to replicate a gameplay tag in a GA so that it triggers a state in my ABP.
if (GetAvatarActorFromActorInfo()->HasAuthority()) {
LocalASC->AddLooseGameplayTag(ZSGameplayTags::Character_Rifle_Equipped);
LocalASC->AddReplicatedLooseGameplayTag(ZSGameplayTags::Character_Rifle_Equipped);
}
This was the only work around I could get working, which seems completely wrong. Initially, the replicated version has the animation working between clients, but the server sees none of the animations. Then when I add the non-replicated version, I see the animations for all clients and servers. I have the tags mapping to bools in this variable FGameplayTagBlueprintPropertyMap GameplayTagPropertyMap; that lives in the anim instance class. Any ideas why it acts this way and how I'd go about fixing it?
Can the gamemode turn on / off movement and looking inputs that are in the player controller ?
Outside of some need for actor components or collapsed functions this isn't even that bad. I like it.
Hi,
If I only want to support dedicated servers, I should use UE_SERVER and never WITH_SERVER_CODE, correct?
Thx
i.e. I should use UE_SERVER for server code and !UE_SERVER for client-only code
The way i do it is the game mode has an array of all player controllers and loops through them and for each one run an owning client event on controller to disable input
Oh I didn't know about this. Thank you for the insight. How about client moving to different map?
When we build dedicated server, we select a single map server, is that mean that ther server.exe only contain the selectef servermap?
If I have 3 server maps, mapA, mapB, mapC, do I need to build dedicated server 3 times with each map selectef as the server map in maps and modes? And then run the 3 exe in virtual machine (ec2) with different port? Will it work like that?
I'm not using Enable / Disable Input, in this case I'm using Set Ignore Move Input and Set Ignore Look Input. Could you try this on your side and tell me if it works with your setup please ? ๐
I'm afk but it should work do you need to use those nodes?
Thank you, I never knew that using execute console command is the correct way to do that. I Will change my BP.
@sinful tree how about these?
You'll end up launching your server executable with some command line inputs that tells it what map and port to use.
Your server build should have all the maps the server will need to host.
I had a quick question maybe someone can help me with. I was testing my dedicated server and I wanted to see if I could change the variables with cheat engine. I was able to change my gold variable and buy things with it. Do you think this Is because im running the server on my pc/ip or is it because I am not doing a good enough job of making the server verify variables?
It's because the server is hosted on your PC....
That's why games where clients aren't allowed to cheat stuff like that need the Servers to be hosted away from them. Which also makes such games so incredibly expensive for the developers.
I mean, it can also be that you, on top of hosting the server on your PC, coded the multiplayer part badly :P
Haha true, Iโm gonna do more testing tommorow but I already change all important gameplay variables (like gold) through run on server events with replicated variables. But possibly missing โswitch has authorityโ nodes might be causing problems?
Depends what you actively changed with cheat engine.
If you changed a variable of the server then that's totally expected. Clients can't have access to the server. No matter how your code looks like. The server has to be hosted somewhere in the cloud, away from the client.
If you changed a variable on the client (only on the client) then you are telling the server the amount of gold the client has somewhere via an RPC and that's just bad and makes cheating easy
Ok Iโm going to go through and check everything tommorow, ty for the advice
In other words, only the server itself should be able to grant you gold through some verified method
There shouldnt be any rpc that changes this directly
An rpc may "suggest" a clients intent, but the server will have to verify thenoutcome of that
Otherwise whats gonna stop the client from cheating.
"Hey, server! I just picked up Thundrfury, blessed blade of the Wind Seeker!"
"In stranglethorn whale? How did you.."
"Random drop, i swear it"
Oh, so it doesn't matter if in the maps and modes we set MapA, server has every map?
I can run that exe with command line argument adding MapA.umap to go to MapA, or adding MapB.umap to go to MapB? Like that?
But how do I start the dedicated server on the editor ?
You dont, Dedicated Servers are an executable you build from Visual Studio
You probably need to google how to make one first.
Welcome to programming.
Im still confused for the code part
For eg, how do i make a client create a new session on the dedicated server and join it
Why would a Client create a session on a dedicated server?
Why do you need dedicated server?
I think the creative mode in fortnite does that
๐คฆ
?
Because games can be big (20/30 players)
I don't want to host this on a client pc
Its clear to me you are very new to this, I suggest you start with something much less difficult.
Try just getting sessions working with Listen Servers.
Isnt this how works competitive games when you enter matchmaking ?
If no servers or queues are free, its adds a slots so people can queue to create a new game ?
I already have that
But i coded my game to have a dedicated server, so i would like to perform my tests this way
Have you compiled a dedicated server yet? Do you know you need a source build of the engine to do that?
You seem to be trying to jump to far ahead, no point building stuff for dedicated server if you havent even got the understanding of how to make/run one.
I've read the docs, ik what I have to do.
Im just asking code related questions now
There is no points building the server if no code is setup to create session like i have in mind
Also, with UE, can 1 dedicated server be splitted to run multiple games (maps) ?
Or do i have to virtually split it or something
You can start a dedicated server using batch file in cmd, I did that to iterate my changes
https://nerivec.github.io/old-ue4-wiki/pages/how-to-test-dedicated-server-games-via-commandline.html
Check this out
ty
Yes, but a Client isn't doing that. This requires something outside Unreal Engine, written in some other coding language fwiw (i guess C++ could work too), that handles starting and stopping processes, as well as managing all the session stuff.
PlayFab and similar services provide that for you, but that comes with high costs on top of the already high hosting costs of the DedicatedServers.
No
One UE DedicatedServer = One Match
i was afraid of that
okay ty
You should also be VERY aware of the fact that any project that wants to pull something like this off needs a lot of money and potentially a lot of people.
You are free to try this alone, but it's honestly a pretty shit idea.
in the project plan i wanted to start with server listen to start, than seeing if there is enough player and budget to go to dedicated servers
but yeah, big stuff right there
You can do that, but the ListenServer approach instantly removes any form of monetization
wdym
also, i wonder how much players i can host on a clients machine
Depends on the Machine and their Internet.
ListenServer allows cheating.
If you plan on having some sort of free game with monetization options, such as Battle Pass and all that shit, then ListenServer is not an option
Then why do you need DedicatedServers?
Is it a competitive game?
Then ListenServer's are also shite
i will not have any skins or other paid currency in my game.
but since the best of the game has to be played by 10/30 players, its better to not host it on a players machine xD
10 to 30 players should be fine
ill do tests anyways
You are just putting extra cost onto yourself with the DedicatedServers and all the backend shit
I would just not do that
Make a ListenServer fun or coop game and let Players host
the other thing is, is it safe to make a client host the server, and be visible in public lists ?
usually you want only your friends to join, but in some cases you want to allow anyone to join
idk if this makes sense
Depends on what you mean with "safe"
no, see it like a The Escapist style game (in 3D)
performances are not fully needed, but i'll do my best to make each player have a good experience
idk, im not a hacker or stuff.
I suppose Steam already does a job keeping confidential information's private
Yeah it does
cool
if you're using steam relays, people's IP wont be public (not that people can do much with an IP in the first place)
well, here i go editing my code to make it fully work for listen server
the plan of the game is
- solo and AIs
- self hosted mutliplayer (with added AIs if needed)
- dedicated servers for bigger games and more performance
the 2 first will be done anyways, the last depends of the "success" of the game
๐
Prisoner0 is the server host
what am i doing :
-
Character : BeginPlay -> Authority -> Call
Initevent on replicated ACBP -
ACBP :
Initevent (Run On Server) -> fills an array with stuff. -
Character : Possessed - > Set
Player Controllervar (rep notify) on ACBP -
ACBP :
On Rep Player Controller: Remote -> Calls an event (client) <-- this fails on host client (Remote is not called because the "client version" of the Character and ACBP doesnt exist, it appears only later on (as you can see on first screen))
note : this was working fine when all instances where clients and the editor was the server
i am trying to convert my code to listen server
edit :
On Rep Player Controller is never called on client version of the server host
this issue is also hapenning at other places
for example, the begin play of the Character is never called on client side of the client host
Anyone about to talk to me about open world sandbox mmo design?
or just talk about it in general doesnt have to be jsut to me hhaha
@lament flax ListenServer is Authority
ListenServer does not count as a Client in that scenario
yeah its anoyying
This is more for #online-subsystems
i have to replace simple "switch on authority" with this kinda stuff
I mean you could just make your own node
before i just needed that
With 3 pins
i think i will when i'll understand better what i am doing
Authority, if we ignore for a second that this doesn't ALWAYS mean Server, would be the ListenServer at all times. Remote will always be the connected Clients. The only extra case you have is if you want to specifically target the LocallyControlled Pawn/Character or its Controller, at which point Authority also needs to check for IsLocallyControlled.
That should still be fine though
"remote" is not fired on client side of listen server
FocusStartPoint only needs to be set on client side
Hm, yeah. The only thing I can say is that one rarely has to do what you are doing there.
Which more or less means you are doing something more complicated than needed
yeah ik there should be a more simple solution than this bunch of nodes
You need to clarify if SimProxy or AutonomousProxy for Client
Then please read the Compendium again. That's very relevant to generally coding your multiplayer logic.
They are NetRoles. AutonomousProxy is usually the role of a Possessed Pawn/Character locally. SimulatedProxy are instances that are just simulated and not directly controlled.
its attached to usable actors that are replicated
In theory you only need to check if the Owner (which is hopefully a Pawn/Character) is LocallyControlled.
what "owner" ?
The SCBP_Focus should show the Widget for ALL Clients?
thz actor "owner" or the network "owner"
Or just the local one?
That's the same thing if we are talking about the GetOwner node.
What is that exactly supposed to do?
like a door
Just show a Widget to everyone?
i spawn this focus widget once, then toggle visibily on specific client when close enough and looking at it
Then just remove the SwitchHasAuthority?
well
If all you want is spawn it on everyone so you can later change the visibility on whoever is close, just remove the Switch
yeah it works
What does this code do then?
but server side of joining clients should care about spawning it
in the ACBP focus i linetrace on tick to check if i have a focusable actor
i only want this to run on client
for performance
So that is the thing that ultimately sets the Actor that you then set the Widget Visibility of?
well this will called on EVERYTHING
- listen server
- client (server)
- client (client)
i would like only client
Isn't this just an Actor in the Scene?
yes
Then BeginPlay will call in ListenServer and Client
idk what you mean with Client (Server) and Client (Client)
its better if i say player (client side) and player (server side)
because its placed in level ?
Doesn't matter if placed or spawned runtime
so its only owned by the listen server ?
That's a different topic, but yes
tbh you are just lacking knowledge
true
Or rather misunderstanding things
im still only 1 month into this
BeginPlay here calls on ListenServer and the connected Clients
Once per
There is no Client (server) Client (client)
There is just ListenServer (which is a Client hosting) and other connected Clients
So for 3 players, this calls 3 times, once on each game
i think this is what make me say there is Client (server) Client (client)
But that's a different thing, we are talking abotu the Cube
oh
The Cube should only have 2 entries there
still both
yes
So you create one WidgetComponent, on every player
per Cube fwiw
And that's totally correct
but i want it to create the widget comp only on client
because server will never use it
But your ListenServer is a Player
thats why i have to do this anoying stuff to filter
so the only server that has it is the listen server
and the clients the clients
But that's a different BP
For the CreateWidgetComponent part, it's totally correct to not limit it
yeah because its not asking much in performance
That has nothing to do with performance
but later on i will prob have to find this solution i m looking for
You need it to call on everyone
why :(
........
If the Widget doesn't create on everyone, how are they gonna see it=?
You need to forget about the concept that your Server is a separate thing
Your Server is a Player
is the reds one only for the listen server and the blue ones for the client that joined the session ?
Yes
okayyy
i was still thinking the same than when i was coding for the dedicated server
If you host a game and I join you, you are red, I'm blue
now i understand
now i see why my questions were weird
Then all you need to do is check if the Character is LOCALLY CONTROLLED
okay yeah
Let's assume you want to trace the Item Container and show the Widget when hitting it
You don't need any SwitchhasAuth stuff here
All you gotta do is on Tick, check if the Character is locally Controlled
That will filter all SimulatedProxies
Aka Server runs this for its own Character
And each Client runs this for their own Character
That's all there is to it. The only little thing you have to always keep in mind is PING.
E.g. you can't check IsLocallyControlled on the BeginPlay of a Pawn/Character, cause the info about being Possessed and Local takes time to replicate.
If you need a callback that you can use for when that is sorted, you gotta use ReceiveControllerChanged and check if the "NewController" is valid and a LocalPlayerController.
hey guys, sorry to interrupt, im trying to get the PlayerState in my Pawn on Beginplay, but i noticed it returns as Null (for the latency you just mentioned, im guessing)
if i add a short delay it works, but it seems like a sketchy solution, is there a better way to do it?
so this wont work because it isnt replicated at begin play ?
Is that the Character?
yes
Yeah no, then override ReceiveControllerChanged
i had this before
That calls from C++ via the OnRep_Controller
You can check IsLocallyControlled there
okay this worked great
ty
the last thing where im still a bit stuck, is this
why is there a client version of the listen server character ? (prisoner0)
is it the replicated version so the client can see it ?
Yes
okay
it takes time to re understand how networking works, but i'll get there
No worries, we've all been there. You are seemingly grasping it faster than others
its painfull to fix code when you passed so much time on it
It's part of the process (:
The more you learn, the more you will refactor, until you have the knowledge to create the thing you want in the more or less optimal state
And that takes years, so don't beat yourself up over it
true
I find joy in fixing my old code haha
im still shoked of the differences between my last project that i started last year and how i code now on this new one
anyways, ty for helping this long
i can finally eat, i should of started cooking 2hrs ago
yes I do
It should not
So I'm confused then because even with the game state it doesn't work
Your GameState does nothing
All it controls is the state of whether players are allowed to control their pawns or not
(via the bAllowedToControl prop)
Your PlayerControllers listen to the change on this property and react accordingly
This is wrong
I had to leave yesterday
Tell me what's your current situation
My current situation is nothing works and it's getting me crazy ๐ฅฒ
Do you still have this setup?]\
Yes
Ok, perfect
That function is this one
Ok, yea, that's perfect
Now, let's just review it - where are you at right now?
How are you changing the value of bAllowedToControl on the GameState?
Like this
This is bad
Yes, it's bad
The default of your bAllowedToControl is false, right?
yeah
why ? Only the cast to the "GetGameState" too ?
You do nothing there
Nothing related to GameState and/or bAllowedToControl
Once you removed these two functions, just play the game in PIE and see if you can control your character. You're not supposed to be able to do so.
Not the client, not the server.
Now we talking.
i still can't move in the lobby but I guess it's normal as the pictures above are the ones for the controller on the Mansion_Level only
You cannot move, perfect. โจ
no hold on
Holding on...
In the Mansion_Level (the one having that PC_Werewolf) I still can move with the host and can rotate my camera but I have to press and drag around but with the client I can't move and can't look around. It's like all the inputs are disabled for him
So, isn't the input focus of your game Game and UI?
yeah
I'm not sure to understand ๐ค
That is, can your host move?
With the host yes and he can look around but by holding the mouse button down and dragging the mouse around. The clien't can't do both of these actions
Ok, is there any piece of your code setting the bAllowedToControl to true?
In GM_Lobby, yes. But it's not related to Mansion_Level.
OK, just to be double safe
In your PC_Core
Call this function in the BeginPlay, passing false to it.
Run PIE again and see whether your server can still move/look around/whatever
should I delete this first ?
It does not really matter, but you can delete it yes
Ok now I can't move nor by the host nor by the client in both the Lobby level and in the Mansion Level. But still in the Client it's like his whole inputs are disabled as I can't even press the Game Settings keybind to open it
And trying to set this to true works perfectly on the host again, but the client still can't move ๐
I'm suspicious there's something else going on here, such as InputMode UI Only or something
Make sure there's nothing setting InputMode UI Only for clients
found no solution yet :c
These are all the references to that I have
You don't do that
In the BeginPlay of your PlayerState, you check whether it refers to the player state of the local player and then you get the pawn and call an event BeginLocalPlayerState (on the APawn) - if you're doing C++, there's the GetPawn fn on APlayerState IIRC
Yeah I mean I don't know - you just need to make sure there's no Input UI Only somewhere doing something for ya. If you look at the very first result, it seems you're calling it in the PC_MainMenu ยฏ_(ใ)_/ยฏ
Remember: the InputMode persists travelling and whatnot - so if you set to something at level X, it goes along for every and each time you travel
That could be the issue, I didn't know that
Yep. ๐
is BeginLocalPlayerState a custom event? 'cause i cant seem to find it
the GetPawn is also returning null...
Ah yes its a custom event you create yourself, sorry if wasn't clear
Hmm
In C++ we have a PawnSet event - not sure it exists in Blueprints, does it?
i just tested with a couple prints and apparently the pawn's beginplay is firing before the playerstate's
yeah, this one im guessing
You don't need ot access the pawn to check whether it's locally controlled - the PlayerState has its own IsLocallyControlled function - if not, then you can get the PlayerController (on the PlayerState) and check whether it's locally controlled
Cool beans yeah, whenever the PlayerController of this PlayerState possesses a Pawn, that event will be called
God damn it, that was the issue ๐ญ Thank you so much for relieving me from 2 weeks of pain ๐ญ
My project is a mess
You probably can lead from here then, but go with the bAllowedToControl boolean - it's better than having two separated booleans
And allow the GameState to mange that variable for ya - your Controllers just react to those changes
It happens to the best of us xD
I really hate the way Epic did their class system by having 3500 different classes that we need to learn
and each tutorial I watch comes up with a new way of doing stuff
And also could I right now call set the variable in the GameState inside a gamemode directly instead of using BeginPlay of player controllers to have more control ?
its throwing this error at me
Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetPlayerController_ReturnValue". Node: Branch Graph: EventGraph Function: Execute Ubergraph Standard Player State Blueprint: StandardPlayerState
but the ping widget (which would show 0ms if it didnt have a valid playerstate) still works
wait now its not giving the error anymore
Yes, you can. As long as it is the server setting the variable, you're good.
๐
Run it 10 times just to make sure, because you might be facing a race condition
yup its giving it again
Ok so
Is your Pawn being given to the Player automatically by the GameMode or you calling Possess yourself?
its being given automatically
Yeah don't do that
That's your race
In your PlayerController, create a function called idk, RequestPawn, which is a RPC client -> server
Then in the RequestPawn you spawn your character (StandardPlayer it seems) and you call Possess
reliable run on server?
Yea, reliable
aaand i should call it on the controller's beginplay?
Yup
At the very beginning - and then you probably don't want to do anything else there
wont the gamemode still try to spawn players by itself?
Ah yes! Good call. Remove the default pawn class from the game mode.
Back to the same issue ๐คฃ Now it doesn't work on the host but does on the client as the client can move freely but not the host ๐ฅฒ
Put a print string at your Enable Control and see if the server is calling that function
I don't know if Blueprints automatically call OnRep_s
still getting the exact same error :c
on top of that, some stuff broke
Probably your begin plays that were depending on your Character
yeah, just moved it to ReceiveRestarted
on server it's being called but not on the clien ๐คฃ But it does the opposite behaviour ๐ฅฒ
Ah, sorry
You have to run an if to check whether the PlayerController is valid
Because that function is called to all connected clients (including the server)
And remote clients don't know the PlayerControllers of anybody but their own
(That said, if you put a print string in the OnPawnSet, you're going to see it's going to get called X times, where X is the amount of players with pawns you have)
You have some messed up logic somewhere then lol
How ? ๐ฅฒ
Are you sure there's nothing wrong with this logic?
More specifically to these nodes
You gotta debug a little
Put print strings in places, see what's going wrong, what is being called, where, when, etc
Somehow input is ignored for the host when joining the lobby level
aaah i see
i only have 2 players but its firing way more times lol
and its getting to the end of it twice on the client and zero times on the server
so i get two ping widgets on the client spawned and none on the server
this is so confusing
Hello
There is a way to exclude assets when you're packaging, so your server doesn't necessarily have to have all the maps you may create - like there is no point in the server having any sort of "Menu" map or any maps that may be part of a single-player only campaign and wouldn't be used in multiplayer gameplay at all, therefore you could save some storage space by excluding those from the dedicated server build.
And yes, by running the command line in such a way, the server can load to a certain map.
How do I possess 2 pawns using one controller or player index? I want to move Pawn #1 using WASD and Pawn #2 using Arrow Keys while keeping it on one camera.
You can only possess one pawn at a time. You can "enable input" on other actors, or you can pass along inputs from your controller to other actors if you can get reference to them.
i cant figure out how to patch the sprint logic
You don't, your best bet is to have a second PlayerController (CreatePlayer for a local one), and to have two InputMappingContexts, one for each player (at least that would be my first approach). Then activate one in each (not both).
For the Camera you can use the PlayerCameraManager that you can set on the PlayerController. That allows you to control where the Camera is transform-wise etc.
can someone give me some feedbacks from my actual sprint system ?
Ever so often I run into situations in a listen server setup where:
Server player to client replicates fine
Client to server player replicates fine
But not client to other clients
For example this would be an int for attack angle choice in an anim bp or a Boolean for holding a weapon out (animation)
What am I probably missing with this scenario? I don't want to abuse use of multicast when it doesn't make sense to ๐
Complicated question.
What's not working would be an easier question to answer.
In general, client to client communication is quite an equivocated idea. The actual mental model you'd have to have that may facilitate your life is: client -> server -> other destination (that may be all clients, or some specific clients, etc)
the typical pattern is:
Client -> Server (through a run on server event, this is the ONLY way for data to get from client to server)
Server -> everyone (through replicated variables for state and multicasts for 1-offs)
that pattern will work in all situations. If you don't want to wait for the network round trip to see the results of a client action on that client, then you're in prediction land
Certain things like Character movement seem to automagically be making it to the server, that's the Character system doing the run on server events for you under the hood in C++, things like movement and jumping etc.
Knowing clients always have to go through the server to transmit their ideas to the world, everything becomes easier. And take note: the only way you can communicate client -> server is via an RPC. There's absolutely no other way; no replicated properties, no nothing. Period. Don't waste your time trying (unless you come up with your own netcode, then it goes beyond me and may invalidate most of the things I typed below.)
Now, knowing this information, the most used - and probably the only few ones - channels you can choose to call this RPC is one of these three:
APlayerControllerAPlayerState- The possessed pawn of the
APlayerController
Out of the box, these three Actors (when marked bReplicates = true) and their respective UActorComponents (also marked to replicate) can call Client -> Server RPCs. You can also go further and have your own UObjects calling RPCs, but under the hood, they mostly always use the callspace of one of these three channels. The key is: actors are your channels. And the channel you choose is on you and depends a lot on context.
Alright, now you got the info you wanted in the server. What now?!
There are lots of nuances here, but:
NetMulticastRPCs mostly for one-off effects, with (mostly) no filters to who is going to receive. Even if you put anifin your multicast trying to filter local players and whatnot, that does not save you from bandwidth waste - the local player received the information anyways.- Replicated properties (or variables, if I may) is mostly the way to go for state 99% of the times; these guys give you lots of filters out of the box so you can save big when picking to who you want to broadcast information to. Not to mention that, by default, they are replay-ready, so late joiners to your game will consume the world the state it is at that exact moment.
The above is just a general outlook. As I disclaimed, there are multiple nuances and tidbits spread out, but may be a good start.
Thanks guys, really appreciate the responses. Starting to make more sense :). I'll toy around some more with some of your suggestions to see what changes the behaviour
Also if you haven't, read up on RepNotify variables / OnRep functions
they are insanely powerful
Atleast worth 3 level ups, if not more
As I understood the Unity networking API in few weeks, in unreal I can't get it 100% for last months xd sometimes I am doing something but I don't have idea why it works this way. Today I was making a door actor. Is has interact interface implemented which is called via server rpc from player character. Door actor is ticked as replicated. Properties I did as replifetime and it works without any rpcs or something, but to play for example opening sounds I was forced to use net multicast even if my open the door function was executing on every client
You don't have to use an RPC
You can use rep notifies for your replicated properties
Yeah, they are rep notifies, as I said I am not using any rpcs in the door actor and it is still networked properly, and I can't understand why xd
You should be able to play things like sounds in those rep notifies
Ah
I will try, I had problem also with broadcasting events to all players, so I think I should do it in rep notify also
And the one of biggest difference between unity - unreal is that with rep values we have handling late joining players automatically. In unity was a one of the biggest issues when making mp
Losing my mind, NEED HELP.
Must support local split screen + LAN + Network. So many problems with local players 2+ controller initialization, etc. Please, if anyone is experienced and willing to help.
Thank you, I'm going to playaround a little bit more to test some things out.
Btw I have a case like this:
- server is executed in ec2 with default server Map named MapA.
- it's a mobile android game. when client is running the game, the will go into loginMap
- After they login successfully, they will load playerdata from API using varest, and save the data to game instance variables.
- They will automatically directed to CustomizationMap, and call the playerdata variables from game instance. and there's a Play button that excute console command open ipAddresOfEc2, and takes the client to MapA in multiplayer and client meet each other. They can chat, dance, sitdown, that's all. Everything works.
- There are 6 clients connected in the MapA server, let's say named client1-client6
- There are also different MapB, and MapC. is it possible if client2 and client 3 is go to level MapB
Client 4,5,6 go to level MapC? - so that the server which has 6 clients, are divided into 3 maps like that?
- How do I achieve that in dedicated server using aws like that?
hi , is there a way i can detect if a multiplayer is in progress ? checks before joining session if game in progress or not , like i tried with a boolean , and diff bp classes like game mode , and the boolean in the game instance doesnt seem to change its value at all , any idea ?
What are you trying to achieve?
so players are in a lobby , they chose a map , and load it , im trying to prevent another player from join the same session when the game has already started
maybe there r nodes im unfamiliar with , but since im using different bp classes for the lobby and menu , the work with HasGameStarted boolean doesnt seem to fit , ive tried different classes , or a "bridge " to change the boolean value , but its always false for the new player *
You have plenty of options.
- If using lobbies (I know you mentioned sessions, but sometimes people use these two words interchangeably so...), you probably have access to flags. You can set a
match ongoingflag that discloses the situation to others willing to join. - If using lobbies still, another option is to just close the lobby altogether.
- If using raw sessions, you can allow others to connect and just kick them out once they connected.
- If using raw sessions still, AFAIR you can destroy the session once the match starts and re-create it once the match is over.
yeah , 4 seems fitting , thank you
a static mesh component with collision runs on tick? or is it only when Generate Overlaps is ticked? or not im assuming this because of the begin overlap and end overlap must be running on tick right?
please if anyone know share the knowledge
I'm asking because im trying to have few things running on tick on the server
1 server = 1 map in Unreal. You'd have to launch multiple servers, one to host each map.
Then you'd have to set up a backend system to direct the players to the appropriate servers for the map you want them to be on.
regardless of whether or not things are running on tick, if you need tick to be on, then the rest doesn't matter. If you don't need it for gameplay, then turn it off alongside all other features (related to collision) that you don't use.
I don't have a basis for this, but my assumption would be that physics interactions would be updated when components with physics enabled are moved/moving, not on tick or periodically. I'd also be happy to be confirmed or corrected.
Static mesh components (or other non-skeletal primitives) do not "tick" themselves. Unless you enabled it yourself which would be weird.
The physics engine manages its own ticking, whether a component ticks or not has no effect on physics.
I remember having to enable ticking on my player mesh because it wasn't replicating some blend space params
If enabling ticking isnt a good thing, i might have to ho back and fix the issue
What happens to the GameMode when the map is reset, meaning when the current map is (re)loaded?
I know it runs begin play. I am asking because i am spawning loacal multiplayer + AI that fills any remaining player starts, players spawned first then AIs. When I reset is when I am getting +1 additional AI on top of the second local player and also the order in player starts is not the same; only happens when I re open the current map.
when you look at the Game Flow it looks like the Game Mode is loaded when a Level is loaded
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Framework/GameFlow/
so even if its reloaded, Unreal doesnt care and will do the same as if it wasnt ever loaded
Yeah. It is strange, i get all actors of class player start. When the level is re opened then my player spawns, spawning local player 2 (aka index 1) is spawning at a different start with one additional AI along with it. It never happens the first time the map is loaded only on re opening.
While developing a multiplayer game, we are persistenting player data on the server during SeamlessTravel to the next map using the PlayerState::CopyProperties function. However, the client is currently only replicating the data from the server and does not maintain the data locally.
(Destroying local data and replicating from server)
during SeamlessTravel. In this situation, how can we client to carry data locally while seamless travel? Which function should I check? (C++)
for to be sure
In C++ OnRep functions are not being called on the server, listen server, right?
If I want to I must call them manually?
Yes
GetAllActorsOfClass is nothing that has an order to it. If you need an order, you gotta program it into the PlayerStarts. One way would be making a cluster actor that has an array and getting that instead.
I don't think that's a thing
All function calls in that regard are done from the Server iirc
Oh I see, but 1 exe can contain all the map so I don't have to build exe for each map, instead use the same server.exe, adding command line parameter to define which map to open and which port to open, or I can just run 3 of them each with different command line parameter to open different map in different port, can it be like that?
Great thanks a lot for the help. It shed some lights to my problem ๐
Now I know what I need to experiment with
Well, Is there any function before ready for seamless travel? (Client side)
I want to predictely ready for client data not always replicating from server.
Thanks for the tip I'll think about that.
Not sure, you could check AGameModeBase::StartToLeaveMap, but can't comment on any form of RPC properly reaching the player in time.
Client Data should replicate from Server. There has never really been a reason for what you are trying to do here.
There is also AGameModeBase::ProcessClientTravel
Followed by APlayerController::ClientTravel and APlayerController::ClientTravel_Internal, later one being a ClientRPC.
That RPC will call APlayerController::PreClientTravel
You could listen to FOnPreClientTravel& OnNotifyPreClientTravel() { return NotifyPreClientTravelDelegates; } from the UGameInstance in classes where you want to react to it.
But this is not really allowing you to move data from PlayerState to PlayerState
That would only allow you to maybe save the Data locally and later somehow reload it.
All not really required, but I'm not gonna question your needs
Hello everyone! Is it possible to transfer the coordinates of a player from the server to another player who is in a single world? I know how absurd that sounds.
But I must wrap this into HasAuthority condition, right? Because on client it will be called twice?
yes it was
A little confused by switch has authority node, it's my understanding that clients have authority over pawns their player controllers possess?
that's the one more thing I am wondering about, I want to know about it too.
its to do with autonomous/ simulated proxies im testing it in listen server environment
looks like players have remote role for own pawns but remole role is split into autonomous/simulated, autonomous for your own pawn and simulated for the rest
probably authority for clients is only for the controller and controller spawned?
so can filter the switch has authority with an extra remote role branch
Thank you.
looks like not easy to filter network roles just in blueprint though zzz
@formal solar @bright summit Clients have Authority over locally spawned Actors.
They are "Remote" for any Server-spawned, replicated Actor.
That's why people usually say that "Authority != IsServer"
If you want to branch on a condition for "actually local" and "simulated", aka AutonomousProxy and SimulatedProxy, you either use the LocalRole or you can do "IsLocallyControlled" on Pawns , as well as IsLocalPlayerController on PlayerControllers fwiw.
I made a table
I would like to have a switch on ENetRole but looks like not exposed to blueprint
GetLocalRole should be available
You can check == fwiw
oh ok i can try that
You gotta explain what you want to do here. I doubt anyone will really engage your question otherwise
what would be a good way to move an actor betweens points with consistent speed between them.
So that it's synced between Server and Client?
yes
Out of the box that's a bit tricky.
basically i got an flying AI that i move to follow an array of points
the issue i cant rely on any Move To because it doesnt handle "flying"
so before going for an event tick or timeline, i wanted to ask here
Hmm
an AI character
Last time I had to do a flying actor I just fake it with a high capsule, but that has to be something fitting the game
Does it have to actively navigate or just straight from A to B?
i am using a 3D pathfinding plugin to get a path
so now i need to go between each point
A to B to C to D to .. to end
I would use Tick then. Server-only though I guess, cause the Server can replicate the Location back.
yes
im just scared its a bit to much for server
replicating on tick
actually you are right, server will only does his job, then it will be the clients machine job to move it
(if i understood correctly)
If you use a Character, the CMC should already replicate the Location and smooth it or not?
CMC has a flying mode, so that should be fine to use
CMC is used when setting actor location ?
Iirc, yes, cause the actual Transform replication that every Actor has (bReplicateMovement) is hooked into for the CMC to smooth stuff
I, personally, would modify the CMC for this stuff
And see if I can use some sort of PathFollow logic for this
But yeah, good old "BP Multiplayer sucks" topic.
I remember the first time i built full BP Multiplayer game to distribute to my friends,the movement logic is messed up because it modify lots of CMC stuff in BP..lots of funny stuff like my friend can climb infinite height because the CMC height var nit exposed
Fun times
Hi! I am doing some debugging on our multiplayer setup - we have a bit of a different system where we have a class named "PlayerHandle" that inherits from "AController" and kind of acts as a substitute for PlayerState (partially) - I am not sure the reasons since I was not coding multiplayer at that time.
Anyway, I'm seeing that the PlayerHandles are not being replicated to all clients. I am aware that PlayerControllers are only replicated to owning client, but in this case we need all PlayerHandles to be accessible to clients to run certain game logic (like checking teams etc).
My question is - is the restriction of replication to clients "hardcoded" into the controller class, or does it only depend on how this actors are being spawned and configured to replicate?
Code for actor spawning:
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = CurrentOwner;
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.ObjectFlags |= RF_Transient;
APlayerHandle* Handle = GetWorld()->SpawnActor<APlayerHandle>(APlayerHandle::StaticClass(), SpawnInfo);
And in the PlayerHandle constructor:
APlayerHandle::APlayerHandle()
{
bReplicates = true;
bAlwaysRelevant = true;
bOnlyRelevantToOwner = false;
}
Thank you ๐
Hello, I have a question, I have a line trace that returns the character I touch, and I would like to be able to spawn a widget for the character I touch with my character, how can I do it?
The way I did it, the widget appears on all clients, but I only want it to appear on the client I touch
You'd pass along your "Character Receiver" value as an input on your "SR_TradeSend" RPC to the server.
Change your "Client_TradeSend" event to be a Client RPC rather than a multicast.
Plug in the "Character Receiver" value from your "SR_TradeSend" event to the target of the "Client_TradeSend" event. This should now route the RPC to the client machine of the player that owns the "Character Receiver" you detected with your trace.
Change your "Client_TradeSend" event to be a Client RPC rather than a multicast.
How I do this? I thought multicast was to replicate to clients
I made the changes, but the widget still appears on the character I use, and not the one I interact with
Err...
Don't think this will work as I'm guessing the Receiver is the target character.
But your nodes are present on an actor known as "C Trade"
You need to have the client RPC go to the receiver, and from there it will communicate to that client to open the UI.
Yes
I cant connect my character on the target
I think this is very difficult, I'm going to try to watch videos and learn more replication fundamentals before doing it.
I'm getting a bunch of segfault crashes when doing seamless travel in FSeamlessTravelHandler::Tick e.g.
0x00007f0e798fded9 libUnrealEditor-UnrealEd.so!UEditorLevelUtils::ForEachWorlds(UWorld*, TFunctionRef<bool (UWorld*)>, bool, bool) [/UnrealEngine/Engine/Source/./Editor/UnrealEd/Private/EditorLevelUtils.cpp:1436]
0x00007f0e798fdfea libUnrealEditor-UnrealEd.so!UEditorLevelUtils::GetWorlds(UWorld*, TArray<UWorld*, TSizedDefaultAllocator<32> >&, bool, bool) [/UnrealEngine/Engine/Source/./Editor/UnrealEd/Private/EditorLevelUtils.cpp:1451]
0x00007f0e798b2745 libUnrealEditor-UnrealEd.so!UEditorEngine::CheckAndHandleStaleWorldObjectReferences(FWorldContext*) [/UnrealEngine/Engine/Source/./Editor/UnrealEd/Private/EditorEngine.cpp:7172]
I'm calling ServerTravel() from my GMB. these errors occur in PIE and in packaged build. i'm on ue 5.1, with seamless travel enabled (in pie and gmbs)
for some reasons, its very lagy on client
this is the code on tick of my BTTask https://blueprintue.com/blueprint/hwgk3uxv/
Server - Client
Id imagine simulating this on the client should be very possible?
Path points + timestamps for arrival
the path can dynamically change
so 'ill have to update client
also the tp effect is weird
the character isnt teleporting with it, its fixed
he is attached to the root comp of the fyling actor
(called on server)
Thats not really an issue
im trying to find the soure of the issue
Depending on how dynamic ofc
