#multiplayer
1 messages · Page 107 of 1
you would run your own function and set your own boolean
For communication you can cast to your own playerstate or use a blueprint interface. Most of the time you want to use interfaces, but in this case casting is fine.
I recommend watching some tutorials and reading the docs about replication
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
So something like this? I'll definitely watch that, I havent seen the talker before. thanks!
no no
the talker and the relevancy
as I said were only examples
since I didn't want to create new functions in the playerstate real quick
Oh xD shit
the cast is correct but not the get player state
you already get the player state in the for loop from the array
with the get playerstate u made, you would always make the player at index 0 a teammate
😅 ?='D
yup
now you could also add a function in your custom player state
what to do when the player is an impostor
I have this in the player state, just to see if it works who is who
Hmm what could i use those for?
for example here you could plug in the correct controller into owning player
so to explain further with the repnotify
in the notify function you would put everything you would want other players to see because of this change
but outside of that you would modify things for the current player
Oh so i could put the ui in that function?
that would make the other players see that ui
thinking about it
you don't need the repnotify, just replicated
since other players shouldn't see a change
as well, that would expose the imposter
ok! ye hehe
you would keep everything the same, just set the variable to replicated instead
everything the same from which of the images above?
every single one
but usually, you wouldn't create UI on the player state
the player state is just there to keep variables and inform if a variable changes
so in this case you would inform the player controller that he is the imposter and then the player controller adds the UI
well and also the beginplay in the playerstate fires way before you would assign the player as an imposter
ah so i move the ui branch to controller and have a delay before?
ah oki
an example
again, remove team widget is just a placeholder for your function
this is what you would call in the gamemode
Player controller?
perfect @azure vessel
one last thing
so this works is setting what runs on client, what runs on server
set impostor UI and Set teammate UI both need to be "run on client" in the replication settings
and Set UI in the playerstate would be "run on server"
gamemode beginplay and so on is automatically on server
at least I believe it is, doesn't hurt to use a switch authority before and only do things like setting impostor on authority, as that means server
Hi
I have 10 skills and I need to check if the skill has loaded while updating the Widget which displays the current Cooldown. How can I make it the most Optimal?
10 timers? One Event Tick? Or what?
Someone can give me good idea?
probably a question for #blueprint
Right now I use Event Tick for whole 10 skills
Nope, there say me here is the best place 😅
Thank you so much! I'll test it out
1 Event Tick check 10 skills
no, he just said to go here because you asked about what if multiplayer
and to answer that question, why not have the skills just send an event when they're done
why use timers and poll
or tick which is even weirder
that would be the most optimal way
Because I have to constantly check when the spell will load
why would u have to
I don't see any reason to
you set your cooldown timer in the skill, or wherever, once it's done it reports that it's done
simple as
Bad idea
This is bad
Then every actor would have to wait for time to run out before could be destroyed
Maybe you have abilities that fastforwards your cooldowns, or want to visualize the cooldown or update a text
You could have more Skills as well, your cooldown should be contained in your skill
polling is fine if the data is usually changing
not some event tick somewhere that tracks all 10
I would just Tick -> update widgets
no
you would get timer remaining, set a new timer
no need to poll
You still need to update your VIEW of the time remaining unless it is not visible, so something somewhere needs to tick
visualizing the cooldown is easily done without polling as well
I don't see anything wrong updating Widget Info with ticks
It's all down to scale
have the cooldown inside the skill but the widget can update with ticks
with 10 skills
sure
ticking is fine
doesn't matter what you do
it was asked about optimal
optimally you tick as little as possible
which a timer will accomplish
It wouldn't make difference, performance wise
How do you suggest updating a visualization of something smoothly changing over time without tick?
Calling timer every 0.0001 is more expensive than ticks I heard
It's not the boogeyman
it's actually more things to call
but it ticks less information
less executed code
as stated, as little as possible
a timer counting down ticks the time remaining
a skill ticking might check whatever amount of variables and whatnot
I mean you could do something fancy like having a parameter on each material instance with the time info needed to do the shading of the bar or icon.
and I don't remember cooldowns being 0.0001 of a second
but more like, a second
How do you show a sliver of time remaining?
I won't call mine a second, I have to displey Cool dool down to the decimals
like 5.05
like I am not debating that the widget will tick regardless
it will depending on what he wants to do there
I mean the UI like this
how do you do the clock fade on the icon and the decimal cooldown
that needs to get updated every 100 milliseconds, I would throw it into tick
but again
question was optimal
I used tick to display my Cooldown, need the decimals to have a smooth circle
It wouldn't make difference doing it 0.01 second or on tick
performance wise
Yeah for that stuff either tick or do the material thing
Okay, thanks everyone. I guess I'll leave it as it is
material thing is probably the worst idea lol
I bet the material approach would scale pretty great for something like WoW where you have 100 icons doing an animated GCD wipe
shader updates are expensive and you wouldn't want it processed on the gpu
which nowadays will most likely be your bottleneck
You should move stuff in the GPU side when possible?
instead bottle necking your CPU
No - you profile and see where your bottleneck is
The shader approach would cost like zero
I see
with modern games it will most likely be your GPU
If you are CPU bound and can get away with doing things on the GPU, then do it. If you're GPU bound and can get away with doing that same work on the CPU, then do it.
Someone was suggesting to Rotate things like Coin using world position offset instead setting the rotation
I thought GPU should be opted instead of CPU
that is quite common
it's easy to do that in unreal engine
for whatever reason
probably some legacy stuff
A progress bar material is going to update anyway, there's approximately zero difference between it having its progress % fed to it by game code or figuring it out on the fly by doing math on game time.
You're right, it depends what you do
instead of:
Tick -> Hey material instance, your progress is 69%
You'd instead:
OnAbilityCast -> Hey material instance, the ability will be ready at 420.69 seconds.
and the material updates itself based on that parameter. No need to tick to tell it anything.
but it's easy to do shaders wrong, I wouldn't touch them if you don't need to
mite b cool for something with tons of icons like WoW
oh yeah that is fine
but honestly, performance isn't to be gained here, so our entire conversation is pointless
any way you do it, nobody would notice, nor would the performance change with 10 skills
So anyway, how do I do predicted physics on BP only, anyone got a tutorial? Just started gamedev this week btw
you get all the bones
Make everything client auth. Leave it to the bit gods on what happens.
Has anyone done that with good client vs client collisions?
make the server do some calculations
by creating a actor for each bone with a projectile component
you send all the info back to the server
where it gets processed
do get all actors of class bone
Arn't you C++ boss? 👀
Sorry i thought this was #programmer-hangout and started shitposting
and no my C++ is very bad
You are probably the first person I will ask when it comes to Physics
So what's the elevator pitch for how CMC handles char vs char collisions?
I think I'm there, and other dude thinks he's there. Who's there?
Since we're both in the future on our screen
A and B are running towards each other
A gets there first on their screen, B gets there first on their screen
What happen on server?
i assume that the predition wont let it happen
in cases where the network is bad u probably get rubber banded back
Server will always be the truth isn't it. If both of them running on equal speed, the one with better ping will probably be there first. And the other one will get rubber banded (corrected from the collision?)
Pure speculation tho, I have not try to race anything
someone mentioned with custom code someone could replicate TMaps are there any pointers/docs on that?
Source code most likely
its supported now?
on the rare edge case they hit the server just collides them and one gets a net correction at most
Yeah that's the core of the biggest problem with my project, except mine isn't characters. Right now I'm pretty commited to serverside vehicle physics and letting lag be lag, but if prediction wasn't a total bugbear then I'd maybe consider it
In my project they'll be hitting all the damn time, like destruction derby
oh vehicle collision, big pain
Yeah and they're player-built vehicles, can be anything from a dirt bike to a Mad Max monstrocity
No. You should read the source code and understand how Unreal does replication and all that.
IE - the odds of there being something out there for this specific thing is quite low.
NetDriver.h is a decent place to start I'd say.
i have a "blueprintImplementableEvent" that is called when HP reaches 0, in that even im just detaching the players weapons and making them simualte physics, this works fine from an oposing players perspective but doesnt work for the owning player and i have no idea why
i feel like im missing a key aspect of the architecture here
fuck it, imma just write a wrapper with rpcs
what could go wrong
lol
ok it was a joke
Is there a way to replicate only subobjects which changed? Let’s say I have 1000 of rep subobjects and I don’t want replication to try to rep all of them. I have a dirty list of ones which contain changes.
https://vorixo.github.io/devtricks/phys-prediction-show/ follow this article
lmao, i know ur memeing around, but ironies aside, its now possible.
I saw that. I still wonder if dealing with predicted vs predicted collisions would be worth the trouble
as long as they are physical objects they run the simulation predictively and server provided the correct result, resimulating the physics state for the affected bodies
I'd have to really think about how my system is set up but it might be plug and play. Basically my system is like this:
Input -> state on devices -> 1D physics network -> forces/impulses
Right now my networking is like:
Input -> RPC to server -> set replicated control state on devices -> 1D physics (runs everywhere) -> forces impulses (runs everywhere)
I think I might be able to just skip owner on the replicated control state and use locally provided control state?
the way i tested it is by having the same move commands in owning cli and server
and it (kind of) worked
still very experimental, it hard snaps more than I'd like
reviewed it over the top with 0lento
Yeah so something like
UNPREDICTED:
Input -> run on server -> multicast -> impulse
Predicted:
Input -> impulse -> run on server -> multicast skip owner? -> impulse
What does a non-owning client do? Are they applying forces locally ever?
although i think u have to replicate physics to autobomous proxy for the prediction system to work... but for that you have to set the actor physics replication mode to resimulation or prediction
no, the predicted would be: local move, rpc server move
without the multicast
move or force/impulse?
force/impulse
so a non-owning client is just interpolating between updates from server, never doing any physics of their own?
i didnt dig too much but essentially... theres some form of interpolation. Maybe if you multicast it it will work better, but havent tried it.. maybe you can try it and see if the likely hood of hard snaps get reduced
maybe i missed that part and you are supposed to multicast it!
but again - blank canvas - no documentation - gotta try to know haha
yeah i think it would depend on what your physics is doing. Like say you have some value driving a hover, you might want the client to use that replicated value to drive the hover locally instead of basically falling and periodically being corrected by server
I'll check it out though, it might be useful. It'll all depend on how collisions are handled as I have a lot of vehicular sumo
yes it is definitely a bit of a change in paradigm
i think that at some point this will all be also brought to characters
but long overdue
I only replicate the physics of the vehicle body and physics turrets, not the individual wheel colliders, so it should be pretty easy on data anyway
I don't care if everyone doesn't agree on if a wheel bounced or not, just that they agree on the movement of the actual vehicle
indeed indeed, thats what i was doing aswell
#ue4... couldnt get my vehis to work in ue5 (chaos)
:(
would have to work quite a lot to make them feel 1:1
What is doing your suspension?
If it was soft constraints, they seem broken
I changed to linear motors
noo, it's just no substepping support
which is fine as now I can do hydraulics like a westside lowrider
I havn't found a need for substepping honestly
but I haven't really tested at like 30 fps or anything like that
What did you need substepping for?
in physx had it smooth as butter at 15, very close sim results at 60
its part of the premise, to have an accurate simulation at lower frame rates
also i noticed the suspension bounces way more now in chaos
noticed it was partially the phys particle physical material and partially my suspension damping
i basically need to adjust all the values
had also to change the car mass from 1.3KG to 1.1KG
many "arbitrary" changes to reach equivalence on system simulation - didnt liked that and I ended dropping the ue5 support
(I want to code, not to move values up and down type of deal hahaha)
How are you doing your suspension?
as constraints or your code outputting forces?
That's probably why, you're probably hitting the critical stiffness problem
w some damping, bound/rebound ratio, stiffness... etc
If you aren't clamping you need to
even that won't be perfect as your code runs after phys sim and not during it, so it can only respond to displacement
yes the bummer is that it was perfect (for me) in physx
I haven't found any way to do suspension forces that behaves well at high stiffness vs just using constraints
so i get annoyed by these "new" problems
Might be a PBD thing
since forces aren't really all that fundamental to PBD
I'd try reformulate to impulses (not sure if that needs doing but it might be more stable) and 100% for sure do the clamping explained in that article
i will (if i ever get back willpower) take a look
because i believe im clamping already
if not it would have been shit in physx aswell
The core of the problem is that for any given delta time there is a certain stiffness and damping which will return the sim to the equilibrium state in 1 frame. Any higher, and it'll overshoot (that's your instability)
so as framerate varies, that stiffness/damping coefficient will vary
you need to clamp by that
you also have the problem that you just know the last frames deltaT, not this upcoming one, that's why I use impulses and handle the frame time myself.
gotcha yeah i believe i compute the suspension delta, so should be easy to apply (if not done yet)
I do that for my tire model's friction. For suspension I just use constraints and linear motors as they do this stuff behind the scenes in Chaos
and as far as I can tell they are perfect, can crank the stiffness up to infinity and it behaves
You also have a coupling problem as you have 4 sping/dampers supporting 1 body, so there's a rocking couple and such. You'll need to divide your critical coefficient by at least 4
yes well each susp can compute its own coefficient, but i see what you mean
Yeah computing the coefficient requires knowing the effective mass attached to the suspension, it'll be something around mass/4 but will depend on distribution of mass and moment of inertia.
I'd probably do mass/5 or mass/6 and see how it behaves, that might be stiff enough. You won't get it F1 stiff tho
i did have a mass distributor actually
working perfectly on ue4
after upgraded to chaos its all jittery
essentially it looks like all the systems i had to make the car more stable for sensitive calculations produce jittery results now
Have you turned up your chaos iterations? I think they default to really low
no i havent
just worked with everything stock Adriel
maybe its as simple as tuning that up?
won't hurt to try
will give it a shot, didnt know about this setting lol
also I would consider formulating your suspension into 1 force/impulse and 1 torque/angular impulse
too used to "physx" just works™️ situation
basically do the math, add them all up, and apply 1 force and 1 torque. Should help with angular oscillation if that's a problem
Yes I have considered that, rn its.. 5 forces (4 suspension + 1 for movement) and 1 torque
yep
yes all 5 forced are at position
and torque is using this principle
of doing the math
and then apply it in one single place
so 1 force per wheel
and.. 1 force in the "acceleration source"
that also aplies lateral friction (very arcadey)
gtg now
thanks for the chat Adriel
Hey, if I have the serverside player pawn, how do I pass this onto the client in such a manner that it doesn't return null for the client?
and search session with this
void UW_MainMenu::SearchSessions()
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub) {
IOnlineSessionPtr SessionInterface = OnlineSub->GetSessionInterface();
if (SessionInterface.IsValid()) {
SessionSearch = MakeShareable(new FOnlineSessionSearch);
// Fill in the session search settings
SessionSearch->bIsLanQuery = true;
SessionSearch->MaxSearchResults = 20;
//SessionSearch->PingBucketSize = 1000;
//SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
//SessionSearch->QuerySettings.Set(SEARCH_KEYWORDS, TEXT("MySessionName"), EOnlineComparisonOp::Equals);
// Bind the delegate for search completion
SessionInterface->OnFindSessionsCompleteDelegates.AddUObject(this, &UW_MainMenu::OnFindSessionsComplete);
// Start the session search
SessionInterface->FindSessions(0, SessionSearch.ToSharedRef());
}
}
}
void UW_MainMenu::OnFindSessionsComplete(bool bWasSuccessful)
{
if (bWasSuccessful && SessionSearch.IsValid()) {
UE_LOG(LogTemp, Warning, TEXT("Found %d sessions:"), SessionSearch->SearchResults.Num());
for (const FOnlineSessionSearchResult& SearchResult : SessionSearch->SearchResults) {
UE_LOG(LogTemp, Warning, TEXT("Session Name: %s"), *SearchResult.Session.OwningUserName);
;
}
}
}
but every time it shows find 0 session
We have a server-authoritative inventory system that works by having clients request actions of the server (Add/Remove/Destroy Item) via a UFunction declared like UFUNCTION(Server, Reliable) and passes on a RequestId and the server then validates the request and does the work and calls a NetMulticast. In some cases the RPC payload back to the clients is the new "state/result" and the clients just overrides the local state (basically replication) and in some cases it askes all the clients to do the same work as it and all the other clients will do (since we assume the state is always consistent between the server and all clients so the outcome should be the same). The same RPC sends back the RequestId so the requesting client can handle an optional callback function at that time (e.g. maybe update the UI to show the action failed/succeeded).
What we don't like about this design is the clients can call NetMulticastAddedItem_Implementation() and essentially have client authority over the inventory -- which is one thing -- but now that we have NetMulticast implementations that share logic we have had to add helper functions like AddItem() that where before we only had AsyncAddItem() and AddItem_ServerOnly() and the potential for misuse of these functions starts to be more of a concern.
There's no way as far as I can tell to "lock out" _Implementation() or the helper functions like checking if we're executing on server or not because the NetMulticasts are executed locally and so any helper functions are also necessarily executed locally.
We brainstormed about using replication instead of NetMulticasts but we're not sure how we would facilitate the callback/response behavior we have going with that. We're also not sure how that would work w/r/t reliability and timing of replication of different UProperties that would be altered by a single inventory action.
Any feedback or advice is appreciated!
You shouldn't multicast the state.
Use a replicated variable, use an OnRep function to then drive changes.
Also, a client calling a multicast means they are only changing it on their side, not anywhere else, which really, you shouldn't care about. The server would have the real copy of the inventory which you can always validate what the client is trying to do based on what the server has.
hey guys, i got some niagara warnings in my server logs, is there anything i can do to make them go away? should i be worried at all?
null object as world context
gonna take a big guess
the server has no object associated and you're spawning systems in a weird way
those particles are in the character so i dont think i am
since those characters are only spawned after a player joins
and that log is from when the server starts
i have quite a few warnings to be fair
they are mostly particles tho
Shoe the code for how you create your particles. Unless you have specifically told it to create them on the client or the event/function they are created in only runs on the client then they could be being created on the server
just stuff like this in the constructor
to be honest i have no idea how the server handles this kind of stuff
Why is it that when I have Super::RestartPlayer in the beginning of this , i experience ghosting (a copy of the player spawns twice) but when its on the bottom it works fine? ```void AFPSMMOGameModeBase::RestartPlayer(AController* NewPlayer)
{
//when Super::RestartPlayer(NewPlayer); is here, ghosting happens
if (NewPlayer)
{
APlayerInfoState* PlayerInfoState = NewPlayer->GetPlayerState<APlayerInfoState>();
if (PlayerInfoState) {
FVector SpawnLocation = DetermineRespawnLocation(PlayerInfoState->TeamId);
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
AFPSCharacter* NewCharacter = GetWorld()->SpawnActor<AFPSCharacter>(BP_PlayerClass, SpawnLocation, FRotator(0.0f), SpawnParameters);
if (NewCharacter)
{
NewPlayer->Possess(NewCharacter);
NewCharacter->SetOwner(NewPlayer);
}
}
return;
}
Super::RestartPlayer(NewPlayer); //good here
}``` I feel like if it works I should be good but im not sure if this is supposed to happen and if its good practice.
If you check what RestartPlayer does in the game mode class, it itself can end up spawning a pawn for the player. By calling super after, the game mode is checking if there is a pawn for the player already, and if so, it doesn't spawn it - since you're spawning and possessing a pawn, this is why it's ok here, but you also return from the function anyway before it could be called if the NewPlayer is valid, so it probably doesn't ever get called.
By calling it before, then it proceeds with spawning a pawn since there isn't one available, and then in your code you're also spawning a pawn for him, so then there's going to be 2.
Depending on what you're doing, you may not need to call Super::RestartPlayer at all.
Ahhh okay that makes a lot of sense, thank you for breaking that down for me.
Is there something I'm doing wrong when it comes to binding to a Multicast Delegate on a client? I'm trying to do this in a HUD widget. Ignore that Delay and GetControlledPawn nonsense (unless it's part of the issue somehow). Hand is a replicated actor that being spawned on Server when the Pawn is possessed. I'm not seeing any of the invalid checks show up in the output log, so I'm very sure that it's valid by this point. This setup works fine on Server not on client. Setting a breakpoint in the native code shows me that when it's the Client, the OnCardEnterBank delegate has 0 entries in its invocation list while the server has 1. This indicates that the Bind is failing on the client. This is the server code that both cases are running and where the Broadcast is going out.
void ACardBank::PlaceCardAt_Implementation(const int32 Space, const FGuid Card)
{
if(IsSpaceAvailable(Space))
{
OnCardEnterBankDelegate.Broadcast(Space, Card);
Cards.Add(FCardMapStruct(Space, Card));
}
}```
Any insight?
My guess would be that you're not calling the event dispatcher on the client side when it's appropriate to do so.
ie. Cards variable gets replicated, OnRep is called, OnRep triggers event dispatcher.
What difference would that make if it's still not bound?
So you're receiving the "Invalid hand bank" message?
No. No invalid messages. I'm pretty sure the Hand actor is valie by the time we're in the blueprint.
Event dispatchers aren't network replicated. They run only on the game instance they're called on. So if your Implementation function is only running on the server, then it only gets called on the server.
It's likely your binding is working fine if there's no message, it's just that there's no event dispatcher being broadcast on the client side for it to receive the message.
I see, and your suggestion is to somehow move my Broadcast into OnRep to get around that?
Because OnRep will be client side?
Well, in this scenario, you're dealing with something stately - a hand of cards. Adding to the array can then cause that variable to replicate. If you have an OnRep set up, then that OnRep function will be called on clients when it is replicated, and if you're using a listen server, you'll have to call it manually when the server sets the value. When the OnRep trigger happens, you can have it call the Event Dispatcher, which your UI is bound to, so then your UI would do what you want it to do when the dispatcher is called.
Very interesting. Sounds like more what I'm after. But will there be a way I can make differentiations of what happened in OnRep? I only want this Delegate to fire when a card gets added to it. I have another one for when a card exits.
Does OnRep give you Before and After states of the property?
Yes. I'm just not 100% on the format of how to do it at the moment.
It could be as simple as adding it as a parameter to the function.
Okay cool. That sounds promising. If that's possible then I can probably figure out what just happened and broadcast the right delegate.
How do I find out which player is interacting
because get player pawn or controller doesnt work because it always gets the host
so what do I use as the object wildcard
to find out exactly which player has interacted
Typical multiplayer interaction:
Client Presses Input on Controller or Pawn >
Does a trace to detect an "Interactable" actor >
Server RPC (can be on controller or pawn) requesting Interaction with the actor, passing an actor reference in the RPC >
Server validates player's pawn (Self if on Pawn, otherwise Get Controlled Pawn on Controller) is close enough to interact with desired actor >
Interaction Interface passing in a reference to the controller/pawn performing the interaction >
Interaction Implementation on actor can read the passed in reference to determine who made the interaction call
@feral narwhal Clients locally also keep track of the session they are part of. Even if the Server and your backend removed them, they might still have the session entered locally and then the session nodes will fail. So you have to "destroy" the session for them too.
You do that locally
Whatever/whenever it fits for your game
If you never expect to be part of a session in your lobby/main menu, then destroy it when that GameMode gets created
Otherwise you could blindly destroy it whenever you try to host/join/find
As "just in case" destroy
Isn't that what he just said?
hey guys im having a hard time understanding the sessionn create/Join from Ues built in system
it isw only working localy ?
on the same ip ?
just @ing so you get your closure 😄
In C++ yes, just add the same variable as an argument in the onrep function. Use const ref where it makes sense
How would one make this work in multiplayer?
One more ques
Just tell me am i correct
While learning multiplayer i got this
Let 1 server (s) and 2 client (c1 c2)
All have variable test and it is replicate so everyone has their variable instance called (stest c1test c2test )
So there is a function called testing() which has if (HasAuthority) and else RPC called (server , reliable )which increment test variable by 1
So if its called on server then stest and its instance changed for all client
And if i call from c1 then it tell server that change c1test to increament and it is replicated so all got to know that ok c1test changed
Hello, does anyone know how client online beacons should be treated in regards to the destruction?
When dealing with regular replicated actors we usually destroy actors server-side, which is then replicated to the client. However beacons are a bit different, in fact it's the local machine that creates them, however they then establish RPC-like connection with the server.
So should it be the server to destroy the connected beacon client actor client-side, or should it be the client to destroy its beacon client actor?
hey devs i bough some asset with weapons , characters, pickups etc. and i noticed it is fully replicated , but my game is single player , how this will impact on the project? i don't know performancevise , project size etc , is it neccessary to remove all replicated code?
I want to do amongus like game but I dont know how I decide is he sus or crew anybody can help
no, none of that code runs when there is no NetDriver around to run it
Hi! If I add a mysql connector into my unreal project and set it to run on the server only, will the clients have the copy of it as well? (they will not be able to run it, i know, but will they have it mentioned?) I am trying to avoid a player in any way to gain access to the database which holds the player data. How does one go about this issue? Is there a better solution to run real-time data for playerstates and gamestates in my multiplayer game?
this is generally done with something like VaRest plugin on marketplace, you don't access the database directly
does this mean setting up http requests on the client and having a middleman server as a rest api that in turn after getting a request will run the query to sql server?
if you're using a dedicated server, the http requests happen on the server, server sends that request via string commands to sql
Does anyone know how to check whether a port is occupied or not using UE?
COND_InitialOnly
replicates the thing only once on Initialization?
Initial replication frame, so not necessarily actor initialization.
Whenever a connection receives that actor from a new "channel", that value will be sent. Usually you only use it for properties which never change once initialized, otherwise relevancy/dormancy can result in clients having different values for it.
Why are animation notifies so unreliable?
like seriously, in a multiplayer scenario it is a dice roll whether they will fire on server
they seem to always fire just fine on clients
it renders them unusable
animation notify states for whatever reason never fail me, but anim notifies always do
and it's not that anything is blended in, or the animation is blended out
they just don't fire
my guess would be from my observation, that if a player is laggy for the server, the animations don't always go smoothly
and it skips the notify
Super thanks for making this clear to me understand it more deeply
Wouldnt this be true for notify states aswell?
Ugh, not looking forward to dealing with those kinda things
Just a follow up question, so on initial spawn my player runs begin play. Which spawns the weapon, sets the health, etc. (not gonna show the full code, but here is just the relevant code: ```void AFPSCharacter::BeginPlay()
{
Super::BeginPlay();
if (HasAuthority())
{
ensure(GetOwner() != nullptr && "Character should have an owner on the server.");
}
bCanFire = true;
if (SpawningWeapon && HasAuthority()) {
// Create an instance of the weapon object
AWeapon* Weapon = GetWorld()->SpawnActor<AWeapon>(SpawningWeapon);
Weapon->SetActorLocation(GetActorLocation());
Weapon->SetOwner(this);
EquipWeapon(Weapon);
} if (HasAuthority()) {
SetShield(MaxShield);
SetHealth(MaxHP);
}
}Which works on the initial spawn. But upon death and respawning, for the client it works correctly. But when the server dies (client killing the server) , it wont set the health nor the weapon. Unless I add the code to the restart player. As shown herevoid AFPSMMOGameModeBase::RestartPlayer(AController* NewPlayer)
{
if (NewPlayer && NewPlayer->IsLocalPlayerController())
{
APlayerInfoState* PlayerInfoState = NewPlayer->GetPlayerState<APlayerInfoState>();
if (PlayerInfoState) {
FVector SpawnLocation = DetermineRespawnLocation(PlayerInfoState->TeamId);
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
AFPSCharacter* NewCharacter = GetWorld()->SpawnActor<AFPSCharacter>(BP_PlayerClass, SpawnLocation, FRotator(0.0f), SpawnParameters);
if (NewCharacter)
{
NewPlayer->Possess(NewCharacter);
NewCharacter->SetOwner(NewPlayer);
NewCharacter->SetShield(NewCharacter->MaxShield);
NewCharacter->SetHealth(NewCharacter->MaxHP);
if (NewCharacter->SpawningWeapon) {
AWeapon* Weapon = GetWorld()->SpawnActor<AWeapon>(NewCharacter->SpawningWeapon);
Weapon->SetActorLocation(NewCharacter->GetActorLocation());
Weapon->SetOwner(NewCharacter);
NewCharacter->EquipWeapon(Weapon);
Weapon->SetPickUp(true);
}
}
}
return;
}
Super::RestartPlayer(NewPlayer);
}``` which seems redundant. Am I approaching this correctly or should I refactor this and fix the issue at hand or is that okay?
Character animations are updated in lockstep with the character movement updates. If you have logic dependant on animations updating, you will also need to force the animations to always tick even if not rendered on the Server. This is obviously a performance concern, which is why you usually consider alternatives.
I guess that answers that, thank you
IIRC notifies should be set to "branching points" too, rather than queued.
There's a lot of factors, can't remember them all
I guess a delay will do the trick...
If you want to drive gameplay logic from animations, they should pretty much always be forced to tick regardless of render state.
Automatically 😅
Which is obviously a performance concern.
where is that setting even?
Id imagine server could just not do any anim stuff except the notify track(s)
No bone updates, nada
On the skeletal mesh
Yeah, should be okay then, the anins will always be updating at least
and it happens with this setting
makes me question, with the interrupted nodes and so on
why aren't they just delays
why not have delays, that check whether the animation was interrupted before firing
IIRC you also to use branching notifies not queued, and I'm not sure but you may also have to use notify states as well
Because presumably you might change the play rate etc. Probably not efficient to do it that way
Playing only the notify track would account for that
Wouldn't solve the problem anyway
As long as you set them to Branching, they seem to be 100% reliable for us.
This is triggered from montages, not sure about anim sequence
Id be surprised if it was sent by delta
Hey, I've got a very simple ability that fails to predict on 300 ms for some reason
Are my "Wait Net Sync" nodes placed incorrectly?
the way I simulate ping is by adding this:
[PacketSimulationSettings]
PktLag=150
[/Script/Engine.Player]
ConfiguredInternetSpeed=500000
ConfiguredLanSpeed=500000```
to DefaultEngine.ini
and that's actually 150 ms not 300ms
Only what changed
Thank you!!
Anyone else can input in this btw. I just wanna know if I’m in the right direction or if I’m wrong, What I should change etc
If we use a replicated variable and an OnRep function how do we use that to trigger the callback functions we have on the client? For example, if the client consumes an inventory item and we want to show a UI element saying it was successful. The client will get the OnRep after requesting the server to consume the item but how will it know if the OnRep was in response to their request and how will it know if it was successful?
Would anyone be able to help as i'm still stuck on this. I can't figure out how to make the gamemode play widgets on the respective winner/loser playerstate variables
Your inventory would need to be the thing that has the OnRep, not the item itself. Notifying a player of successful usage of something could be an RPC itself.
An example:
Your inventory is an array of some kind that holds whatever data is necessary to store your items for replication. This array is what is replicated and uses the OnRep function.
A player walks up to an item, the server detects the overlap, and "picks up" the item, adding an entry to your array at index 0.
The OnRep triggers on your inventory notifying the client that something was updated. The OnRep calls an event dispatcher your inventory. The dispatcher is bound to by your UI which then can update the display of the inventory.
That item that was picked up was consumable.
The client sends an RPC to the server indicating they want to use the item in the array at index 0. The server receives the RPC, validates that there is an item at index 0, and executes whatever that item is supposed to execute when it is consumed - the server then removes the item at index 0. The server can also send back a Server>Client RPC indicating the item was consumed. The OnRep triggers on your inventory notifying the client that something was updated, and the OnRep once again calls the same dispatcher which then allows your UI to update based on the new state of the inventory variable.
Sounds like you may be attempting to spawn the new character locally rather than on the server, like perhaps your attack and killing logic is happening client side as well?
I can't wrap my head around the replication for this pretty much
Ok, so there's no way to avoid adding the extra RPC call then? This seems less optimal than what we already have? (2 RPCs + replication vs. just 2 RPCs)
If only one player can be the winner, all you need to do is call a multicast on the gamestate that includes the PlayerState reference of the player that won. That multicast can then create the widget, but you should have a PlayerState variable set to exposed on spawn and instance editable within your widget so you can pass in the reference of the player that won. Within the widget, you can then check if the Owning Player's Playerstate == to the winner, and if not, display the loss screen, otherwise, display the win screen.
I had a guy say I should use onrep and not multicast, like this below. Is this correct?
Datura I think i've been bamboozled is what i'm trying to say aha
multicast is good enough
an onrep is the wrong thing to do in this case
you would set the variable to replicated, then multicast the widget most likely
How can I check if the player is the winner/loser?
I know how to set the player as the winner/loser but not sure about checking which player is what
I'll wait for Datura, he will give you a detailed explanation most likely
been at it for a while
Probably not. Using the OnRep doesn't make sense as you wouldn't know why the item was removed in the OnRep. Like, the player could have sold it to a store, or traded it when it gets removed from the inventory. So that means it only makes sense to RPC the reason why the item was removed, and you wouldn't want to RPC to the client what the change is to the inventory as then you have to constantly maintain the copy of the inventory that exists on the client - it's possible, but it is messy.
Why would you need to check
and well, you could just get the reference to Game Winner
assuming that is not part of the question
There's only 2 players ever in this game?
yeah
So like this?
Ok, and the code you've shown where you're setting the winners/loser variable, is this in your game mode?
yes
Ok, game mode does not replicate. It only exists on the server. No point in having those variables as replicated if no one can receive them.
you're now giving the winner first the win screen
then the loser the loss screen
in sequence
Are you still on this Paradoxed? What have you tried in the like 3 weeks since we covered this?
lmao
been confused af
watching the basics of unreal engine and the basics of replication might help
Idk some guy said I should do it with on rep and I basically fucked my understanding of it
This bit is looking better.
oh wait, it's game loser in the second
yeah
that's better
but won game screen
and loss game screen
need to be run on client
so it runs on the client, not server
oh
And again... Game Mode doesn't replicate. You can't do any network communication in it - no replicated variables, no RPCs.
That's fine, but you can't use it to do network communication.
By who? I told you to use GameState a few weeks ago.
variables into game state
You'd have to use something else and you can have the Game Mode go into a different class to do it too.
yeah I was on the right track then but someone said to use gamemode and have the lose/win variables on rep
That person doesn't know UE's networking then
GM simply cannot replicate (as Datura said) because it does not exist on the clients. GameState's entire purpose of creation was to convey information from the game mode to clients. It's an extra wall of protection pretty much. You have to be deliberate on what information you send.
So, the overall process is as such:
- Player does something that causes them to win the game
- Do the check on the server (I see "killer", so I'm assuming some kind of pvp) IE - when they slay the other, the server then gets the game state and says "hey, this player won"
- The game state then does a MC that lets all connected clients know who won
You can pass that info in from the person who killed the other person. Flip some flag. W/e you want really.
So this would work for showing the winner in the text?
(theres some other random stuff too)
Yesn't. In this case it would really depend on if that variable value got there before you did your RPC
"Game Winner" may not be the value you expect. Due to latency and networking shenanigans
It doesn't play the widget though only the sound effect
It also plays both the win and loss sounds on the one who killed the player
I'll send over the whole code one sec
Below is the player related code
Here is the gamestatebase code
You can't take lines across network executions - you're setting those Winner/Loser variables using the values from the previous event. If the server was executing "Player Died" the client wouldn't know the values, luckily in this case, because you're using gamestate, there is no owning client other than the server so it, sort of? works, but only for the server.
Additionally, because you're calling both of these bits in sequence, of course you're going to see/hear both.
If you look at the example I just made, it simplifies it. You're creating a widget on gamestate after a multicast, so both players will receive notice that they need to create widgets. When the widget is created, it is owned by the local client, so the server will own the widget they create, the client will own the widget they create. From there, you're able to get the playerstate of the owning player and verify if they are the winner or not.
So why is this, I thought this was only executing for the respective winner/loser?
I just explained why. You're calling a Run On Owning Client event (Gamestate is not normally owned by clients, so it only executes on the server) and then you're calling those functions on the respective playerstates.
Playerstates exist everywhere, so if you call functions on them, regardless if it is on a client or server, it'll execute them.
So I should use multicast?
No. You should not use the code you're using as it's doing what you want and it doesn't matter if you mark just that single event as a multicast.
How can I fix this?
I already gave an example.
The first image can still be used if you've moved it to gamestate, you just wouldn't need the cast.
All the code is on the gamestate
I moved it from the gamemode
Do I actually need to use the gamemode?
No
If you're following my example, then you'd be calling "PlayerDied" on GameState when running on the server.
You are multicasting in the GameState with a reference to the winning player - that value is passed through the RPC to all others. That's all the "replication" involved in my example.
Do you know what marking an event as "Run On Server" does?
Nope.
It marks an event as being allowed for a client to potentially call it for the server to run it, but only if the client is the owner of the actor.
Ok
Do you know what marking an event as "Run On Owning Client" does?
Hey quick question, for shutting down a server quit game is not the way? Is it FPlatform exit or another way?
Do it only on the local client
Nope.
It allows the server to call to a specific client to execute something, but only if that actor is owned by a client.
A good example would be PlayerState -> Something that is replicated to everyone, but owned by a client. If you did a Run On Owning client on PlayerState, then it would only execute for that particular client.
One way that wouldn't work, is running a Run On Owning client event on an NPC actor that is not owned. This call wouldn't do anything as there is no owning client for a "Run On Owning Client" call to work - in fact you'll get a warning in the log.
A multicast can be called on any replicated actor. And yes, it'll execute for all clients, but only if that actor exists and is relevant for that client.
So again, an AI controlled actor, you could call that multicast on and this time it'll be received by all clients who have that actor as relevant.
If you called a multicast on Game Mode, only the server would execute it as Game Mode doesn't exist on clients.
If you called a multicast on Game State, it will be received by everyone as it is an actor that is always relevant.
And of course, a caveat with both Run On Client and Multicast is that they must be called by the server to actually work 😉
Nice
Thanks im gonna refer back to this
The gamestatebase DOES need a execute on server then?
Even if its already the server?
No.
Got it
Unmarked events (so no Run On Server or Run On Owning Client or Multicast) and functions will execute wherever they are called from.
So if I'm already running on the server and call the PlayerDied event on your gamestate, then the logic afterwards should already be executing on the server.
does this work for servers too?
Like if the winner/loser is the server it works?
The server can call Run on Owning Client on an actor that is owned by the server and it should only execute on the server.
It is not correct.
As this is on the gamestate, the gamestate is owned by the server, so running on owning client means it is executing on the server.
It logically doesn't follow what you want it to do.
In my brain it makes sense for it to be only with a server not a owning client idk why
What you want is:
Player Died > Notify all clients who the winner is > Clients display the appropriate widget.
What this is doing:
Player Died > Server is running events on playerstates
Nope.
What am i doing in this code
Don't do this
I want to make amongus like game but I dont know how I decide is he sus or crew and how can I give them different colors anybody can help
Player Died > Running Multicast that attempts to set values both on the client and server even though the values only exist on the server, then trying to again run on owning client on the server (which is the server when dealing with gamestate) and then running things on playerstates.
bool bIsSus on pawn or playerstate
Color Color on pawn or playerstate
onrep for color to apply it
Color gets set on server, replicates everywhere, the onrep is called, the actual color changing is done
I cant understand Im very new at it
Then don't even think about multiplayer
Start by making something dummy simple and singleplayer
Here's a question.... Do you actually need to store the winner and the loser variables? Are they used at all beyond just displaying the UI?
is there any picture or video about it
Yeah
What for?
To count the wins/losses of the entire game
Ok, but counting the values doesn't mean you need to store who the current winner is.
Eg.
I win a round. You'd add +1 to my count. You don't need to necessarily store that I am the current winner.
If a player leaves, then their playerstate is gone anyway.
That's why I store it in the gamestatebase
I removed the custom events as i'm not sure
If you store a reference to a playerstate in the gamestate and that player leaves, that reference is then invalid.
I'll tackle that afterwards as I still don't understand the win/loss widget
I can't see how that fails to work
I'm literally referencing the winner/loser
You're running on server when this is executing. You're then still executing on the server and calling those functions on the playerstates while still running on server.
Why is this bad?
You're literally not internalizing anything I'm saying T_T
If you're running on the server, how are the clients going to know?
hey, is this too much for a fast paced fps?
or okay?
my game doesn't have a lot of entities
It's directly targeting them with the code?
No its not.
Functions and Events (when not marked to RPC) run where they are called.
So basically the clients have no idea
Exactly.
But the server does
Yes.
So the server thinks its the winner and loser
Yes, because you're calling both of those Win and Lose events while running on the server.
Now don't touch anything, leave it as is!!
All you'd need to do...
To at least get it somewhat working...
Run on owning client on the winner first right?
Is mark these events on your Playerstate as Run on Client.
It's not the best method, but you'll probably get something working as you want at least 🙂
ah now this was in the player character bp
is that bad
That should be ok.
what would the code do if it were like it was, without run on owning client
It's already doing that - the server is both winning and losing while the client doesn't know about it at all.
so the gamestatebase which is the server is carrying over to the play sound and widget etc
Yep
which makes it not function
but the run on owning client makes it work only on that specific character
It's not just GameState, but the PlayerDied event is running on the server.
Makes it run on the specific client that owns that character.
Gotcha
So if it's running on the server obviously the client wouldnt have the widget be displayed
I see
That's correct right?
Yep
So when the server kills the client it works perfectly, when the client kills the server it only shows the widget on the server
I probably missed something
When the client kills the server, does it show that the server lost at least?
Yeah
It shows the client won
But theres just no widget or sound effect on the client
Do you have any error messages in the output log?
Nope
Check to see if the values on your PlayerDied event have values - like plug them into a print string.
ah I see
The killer was the loser
Hm the problem is still there though for the client when killing the server
When you're doing those prints, are you seeing
Server: .....
Are you seeing any
Client: ...
being printed?
On the gamestatebase?
Yep
Are you also perhaps destroying the player's character at any point before trying to display the widget/play sound, or even just momentarily afterwards, in the same frame even?
And sorry, I need to go out, but I'll be back shortly.
Yes I essentially removed the beginplay logic and added a HasAuthority() check so that works now. Only problem is that now the HUD isnt updating on spawn for the client until they're shot again. My HUD is on my player controller which isnt destroyed on death. So thats what im confused about.
Hey all, i've got a dialogue system in my game and im adding the widget i made to the viewport through the HUD blueprint, the problem is, when a remote player wants to access the HUD blueprint, it throws errors. Any idea why it would do this?
UI elements generally aren't replicated.
Are you creating it on teh remote player's client? Do they see it? And what error does it throw?
I'm creating the widget through the HUD bp, so im not specifically doing anything extra to make sure the widget is created on the client, and it throughs read access violation because the HUD is null on the remote
for reference, the players are not meant to share this widget (at least for now) they should be able to go up to the character and get their own dialogue going
So yea, you'll have to check backwards. Check the values that you're passing into your PlayerDied call. Check how you're ending up with the values for The Killer and Player Who Died. Whatever logic you have in Player Died is correct, so the problem is no longer in there.
So how do you create the widget?
this is in the hud
So where does the null error occur?
it occurs in the player controller when it tries to access this variable, which is set OnBeginPlay
HUD class doesn't replicate. You can't reference it in a replicated variable.
If it's created locally it shouldn't be null, though.
yeah thats why im confused, i honestly set it to replicate to see if it would fix it without knowing that in this case it does nothing lol
on begin play of PC
Begin Play executes on clients and server. Server can't access another player's HUD class.
the crux is that it can't use Get HUD for some reason on remote clients
the problem isnt serverside its clientside
nope, just the local player's hud
HUD can only be clientside. But if you're getting null errors, it's because the server is trying to access it.
at least thats the intent
interesting
let me put a has authority there
yeah that doesnt seem to work, i also just tried using Is Local Player Controller and added a print statement, looks like its set on the client and server now but its still null on the remote client for some reason
Branch on Is Local Player Controller
i think the rest of this might just need some checks/proper replicated events to make sure that the client is the only one trying to call these events
yep just needed to set this to replicated on top of that previous fix and it works, thanks all!
You cannot access HUD of other clients.
Only the local client can have a reference to HUD.
What if I make it replicated in player state /s
yeah i got that part lol, i just meant for some reason the remote client's was null, but actually it was the possessed pawn that was flipping out because on possess is serverside only
I have car in my multiplayer game and character can posses it. What could be best way to not delete that car when player disconnect from server while driving car? Spawn another car in game mode disconnect?
Have the PlayerController unpossess it before Disconnecting.
The default behaviour is for the PC to destroy its possessed Pawn upon disconnection.
This cant be changed in Blueprint, unless you have C++ capabilities to override it.
Okay I need to override it and make it only destroying actual player
As an FYI, wizard's pinned post about data covers this
What could be causing the problem though in this code?
Keep printing values - see who your damage causer is.
make sure it's not the same as "self"
if it is, then you may be feeding in the damage causer inconrrectly.
Anyone know what RemoteRole should be expected to be set to for a listen server host? Is it ROLE_SimulatedProxy or ROLE_Authority? I wanted to implement a "should I bother sending this RPC" check, which will be pointless doing for the authority player
do I have to dig for the player controller and run IsLocalController
I would expect it to be Simulated.
though for a remote player on a server, then RemoteRole would be ROLE_AutonomousProxy?
No I would think that would still be Authority.
Id just load up the Editor and run a quick Blueprint to verify
why would RemoteRole be ROLE_Authority on the server?
Oh I thought you meant from the perspective of a Client
RemoteRole for a Client on the Server, it should be Autonomous yes
then I can just compare GetRemoteRole() == ROLE_AutonomousProxy for determining whether to send the RPC then
Should it be saying the same text for both screens?
I guess so, is this to avoid having to find out if its LocallyControlled?
But a client RPC called on the host player will stay on the host player (won't get sent to a client)
It can. What the problem is right now is that if both the damage causer and self are the same thing, then you likely are calling Apply damage wrong/feeding in the wrong values into it.
It's just a guard for sending if an RPC should be sent to a client, where it's triggering some delegates, but I want the delegates to always fire on the server too
Yeah then just call the client RPC. For the host player it will run as a normal local function
The reason is since the host player is server-owned
No? because that won't call the delegates serverside if it's a remote player
I think checking ROLE_AutonomousProxy as the RemoteRole is the move, but just need to get the rest of everything in a compiling state
So when the server kills the client (left image) it works fine, but when the client kills the server (right image) it doesnt work properly
That's another story. So you want it on server and on owning client
Multicast on PlayerController sounds like a viable solution 
And you haven't shown anything of what is happening before calling apply damage, so I have no idea what you may be doing wrong.
Does the image i sent about the apply damage look fine?
I can send over the saber damage code.. I suspect i've been doing something wrong
From what I can see, the server and clients take damage as they both have health bars
Yep. Apply Damage looks like it should be fine.
im trying to make a spectator system, my current aproach is to simply give the spectator pawn the spectated player yaw and pitch. The thing is, it looks choppy when things move, is there any option in the CMC or anywhere else to make movement smoother?
Camera should be attached to the mesh, not to mention that my website has an article on the subject
i think i did check ur site, but iirc it didnt have the FPS view specificly
if its attached is it going to be smooth?
Ah yeah it was written with TPS in mind, but technically speaking implementation shouldn't be too different
my third person is working fine lol
its just the first person that altough works, doesnt look good
my 3rd person spectate is free tho
u can rotate around and stuff
Not that I'm familiar with what you ended up doing, but the jitter issue usually results from the fact that the camera component is attached to the capsule which is teleported rather than interped (which is the case for the mesh)
You arent going to get smooth or accurate FP Spectate without doing a lot of work.
this line for example " PlayerState->SetIsSpectator(true);" does this do anything special?
or just lets the server know ur a spectator?
thats a bummer
is there no way to hack things to make them look decent "enough"?
It's part of a puzzle that initiates spectating
Depends what "decent enough" means to you I guess
so what is exactly in the chacracter is smoothly interpolated?
The Yaw of the CharacterMesh will be smoothed, Pitch is what you will have trouble with
i managed to make the camera feel smooth with interp but tthen i had an issue with the meshes lagging behind
The simulated character is already interpolated for you, and you are just counting on the CMC's vanilla implementation
You probably need to setup some sort of stream where the Server passes you a higher rate of Pitch (of the spectated player) changes than normal.
As was mentioned that's not enough for other uses not just spectating, and since why, you need your extra touches ^^
If I'm not mistaken, Lyra has a Camera Something that looked decent
Saw it in vori's article about Instant Replays
i messed around with this var and it seemed to help a bit
the one with the yellow arrow
by the way, do u guys know how to acess them in c++?
Yeah it's a matter of accessing them from the Actor
so thats what i was missing
i didnt know "GetReplicatedMovement" was a thing
i was trying to access the cmc
private vars usually get getters
Not to mention that it exists in the Actor Class Defaults, so everything you see in that picture exists at the level of the Actor
ye i figured that much i just didnt know the name
i think something like this "GetReplicatedMovement().RotationQuantizationLevel = ERotatorQuantization::ShortComponents;" is probably gonna make the rotation decent enough
now i gotta worry about the pitch
You want the _Mutable version
oh, i missed that part
what exactly is the diference?
why would there be 2 of the same thing?
by the way
messing with any of these vars
would it help?
One that returns a mutable version that can be modified, while the other returns an immutable one that is const
Not that I have an idea
is it possible replicate void* pointer?
what would be the purpose of that?
the other machines don't have a memory mapped in exact same way as yours does
you can replicate the data it points to, as TArray<uint8> but that requires some custom work
you can't UPROP a void*
you'd also need to replicate the size of the data
I need to send MessageData and MessageDataSizeBytes from EOS to client
/**
* Structure containing details about a new message that must be dispatched to a connected client/peer.
*/
EOS_STRUCT(EOS_AntiCheatCommon_OnMessageToClientCallbackInfo, (
/** Caller-specified context data */
void* ClientData;
/** The identifier of the client/peer that this message must be delivered to. See the RegisterClient and RegisterPeer functions. */
EOS_AntiCheatCommon_ClientHandle ClientHandle;
/** The message data that must be sent to the client */
const void* MessageData;
/** The size in bytes of MessageData */
uint32_t MessageDataSizeBytes;
));```
so probably in my case it won't be true
any example? should I iterate through data?
hi, let's assume that I have created a structure and in it I have: Texture, Montage, Health, Mana. If my game is multiplayer, should I keep texture and montage variables separate?
only Health and Mana should be Replicated
and is there anything wrong with that, for example, I would have many such constant variables in a structure that is being replicated
Hello, did anyone succeed to use online beacons hosting on them on public IP?
I'm trying to change the URL.Host that I feed into the beacon's NetDriver->InitListen(), though log then says LogNet: Created socket for bind address: 0.0.0.0:7787, which is definitely not the IP address that I've set (the port is correct though).
The code snippet:
bool ATextChatOnlineBeaconHost::InitHost()
{
const auto* SocialSubsystem = USocialSubsystem::GetChecked(this);
const FString& PublicIpAddress = SocialSubsystem->GetPublicIpAddress();
FURL Url(nullptr, TEXT(""), TRAVEL_Absolute);
Url.AddOption(TEXT("NetMode=ForceIP"));
Url.Host = PublicIpAddress;
Url.Port = ListenPort;
if (!InitBase())
{
return false;
}
if (IsValid(NetDriver))
{
FString Error;
if (NetDriver->InitListen(this, Url, false, Error))
// ...
I also have no idea.
I wrote something like this:
const TArray<uint8> NewTmpArray(static_cast<uint8_t*>(InMessageData), sizeof(InMessageData));
``` now how to cast array to void*?
someone?
The real question is why are those things linked together in the first place
But that aside you can mark struct members as NotReplicated provided you're in C++
for convenience 🙂
i am not
:/
You have no choice but to separate them then
Otherwise the references will also be replicated
Also forgot to mention that when I don't specify the IP myself the clients can connect to the host, but when I do specify it (and yeah, the IP is correct) they cannot (the clients know what IP they have to connect to though).
thanks
ok, so if i move all these variables to a Data Table and add it to a Structure then only the Data Table reference will be replicated?
and that will be better than keeping all these variables directly in the structure?
Yes
The data table and the row name, which is probably more expensive than just replicated references since now you'll have a reference and a string
Just separate the data, it makes little sense for them to be together
ok thanks
so what I'm going to do is that instead of these references, I add the "Name" variable after which I find in the DataTable
so now i have only replicated Row Name in structure
instead of these references
But that's a string, so it's probably more expensive than two references
Anything more than 4 characters would be in fact
The setup just seems bizarre to me, not sure why you'd pack those things together
Data locality matters a lot more in MP
ok, i'm creating a spell system and in the replicated structure it currently stores mana cost, cooldown, image, montages
after separating these unnecessary variables, I somehow need to figure out which spell to which mana cost to assign, etc.
and this, I think is good idea
but i don't know
maybe is better way
@chrome bay
indexes?
Another way to approach it would be with a data asset which contains the spells "configuration". You just create an asset for the spell and replicate that reference should you need to.
Right now you're replicating a struct of presumably static data
If you have a mixture of fixed + dynamic data, create a "spec" struct of some kind, that includes the static data (as a data-asset), and the runtime-modifable data next to it.
so this is the same method like this? but in blueprints 😄
Not really, but if you have a static configuration for a spell it might be better off in an asset, rather than replicating a struct of info the client can find for themselves
So in PrimaryDataAsset i can replicate variable? I'm just making sure ;p
Having Issues with Dedicated server setup, I deployed a Dedicated server on Playfab , but Cannot connect it using the client.
I was able to connect it when setup as Mock server on my local machine. Help would be appreciated
No, the point is you replicate that asset reference, which contains static data. You cant modify data assets at runtime
damn, that's a shame :/ thanks, so i create Data Asset and replicate Reference
yes, to store the static data, which presumably all of those properties are
if i change the replicated variable on the server will all clients see the actual value of that variable?
or i need use multicast?
That's the point of replicated variables so yeah, assuming the owning actor is also replicated.
Never change state with multicasts
Quick way to make a broken game
thanks
Hi.
Is it possible to join a listen server by IP, and still have the onlinesubsystem initialized?
Currently, we create session, then openlevel.
And then the clients will openlevel with the IP as level name.
But that method doesn't work with VOIP as the online subsystem isn't initialized it seems..
Any help is greatly appreciated.
Best,
Matias
Clients need to join the hosts session to benefit from most of the OSS logic.
@chrome bay @trim plume Some knowledge:
VOIP in the Engine "requires" the Client to be in a Session. That's why you might think "Oh, if I connect directly via IP, without joining a Session, I can't use VOIP.", which in theory is correct.
However, the VOIP doesn't actually need the Session. It's a local condition that just checks if the client, locally, is in a Session.
I don't 100% recall where the check was, but it might be this one:
void FOnlineVoiceImpl::Tick(float DeltaTime)
{
if (!OnlineSubsystem->IsDedicated())
{
// If we aren't in a networked match, no need to update networked voice
if (SessionInt && SessionInt->GetNumSessions() > 0)
{
// Processing voice data only valid with a voice engine to capture/play
if (VoiceEngine.IsValid())
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_FOnlineVoiceImpl_Tick);
VoiceEngine->Tick(DeltaTime);
// Queue local packets for sending via the network
ProcessLocalVoicePackets();
// Submit queued packets to audio system
ProcessRemoteVoicePackets();
// Fire off any talking notifications for hud display
ProcessTalkingDelegates(DeltaTime);
}
}
}
}
Easiest fix for this is to just add a fake session locally :P
Doing that requires C++ of course
That sounds like something we can use! Thanks
How do we add a fake session though? I have no idea where to start honestly..
We tried with just the CreateSession node in bp, however, it caused some lagging. 🙈
Not sure why that would lag
But no, you have to do that in cpp
You need to get the subsystem and manually add a named session
Cause all it cares for is there being one in the array
I'm sorry, but could you be more specific? I'm not sure to where I would be adding that and to what array exactly?
I'm guessing the FindSessions? But that would mean creating a struct of the BlueprintSessionStruct, and I tried follow into it, but didn't give me an answer.. Also, if we ever figure out how to make such struct, the IP address isn't within it either?
I apologise for all these questions, but I've been trying all day.. 🙈
To me it's just a bit weird there isn't a JoinSessionByIP or something like that 🤔
Session and Server are two different concepts. Join can join either without joining the other. Sessions hold information while the Server is the actual game.
There is no JoinSessionByIP cause that makes no sense
A session is just some data on the master server fwiw
You need to locally, in c++, get the OnlineSessionInterface and add a NamedSession by hand if you want to have VOIP without joining a session
Nothing with FindSessions, nothing with Join or Create ever
Also nothing with Blueprints
This can't be done in BPs
If you aren't able to use c++ then you might need to give up on the connect by ip stuff and properly utilize session with a subsystem of your choice like Steam for example
Gotta head to the gym now, so won't answer for a while
That makes a lot sense actually. I appreciate your replies a lot. It really helps.
I do know cpp a bit, it's more figuring out exactly where to add the session.
However, you definitely pointed me in a direction that sounds promising.
Thank you very much!
And happy gym time ☺️ 👍
I always wondered, if I have a COND_InitialOnly property, and I set it after the actor has finished spawning, but still within the same frame, is it still guaranteed to be replicated to the client (and before the client calls begin play on the actor)? Because some properties of APlayerState are like that (PlayerId, UniqueId etc.)
And APlayerState isn't even deferred spawned, the game simply sets the Ids mentioned before after spawning it, and yet they seem to be always guaranteed to be replicated. So I assume it's 100% safe if I set a COND_InitialOnly property within the same frame that the actor spawned (or had bReplicates set to true), despite not using deferred spawning?
Yeah it will replicate
Replicated properties aren't checked until the very end of the game frame
nice, thx, so basically using COND_InitialOnly gives me guaranteed pre begin play (on the client only ofc) replicated variables which come with the initial bunch, as long as I set them within the same frame that the actor was spawned/set to replicate, excellent
yeah, and so long as the actor isn't map-startup actor or something
yeah ofc
(and is always relevant)
I wondered why they used it for PlayerId, but it makes a lot of sense when considering this
Yeah. COND_InitialOnly is really for stuff you never expect to change once initialized with the actor
this also has some funny consequences, for example PlayerId won't be set when BeginPlay is called on the server PlayerState, but it will always be already set for clients. In general, the BeginPlay of PlayerState is a really terrible place....
Not even the controller will have been set yet at that point (at least on the server)
Player State lifetime on the Server is a total meme honestly
You login.. it creates one, then it searches for an inactive one that matches, then it restore that, then it spawns a new one to replace that one etc.
It's absurdly stupid
It smells of legacy code from UT/gears
yeah it is quite frustrating
this in turn also means that anything COND_InitialOnly set during Copy/Override Properties of the player state will be guaranteed to be set pre begin play on the client, which is pretty nice. I assume it will not be set pre blueprint CS execution though?
ahhh.. I did know the answer but forgot it.
I can't recall now if initial bunch properties are applied pre or post construction script
no worries, uve already helped me a lot with confirming my theory. according to bing, PostNetInit is called after the Blueprint construction script has run, but who knows if that is correct...
one last question: I assume ordinary (non COND_InitialOnly) replicated properties are not guaranteed to be replicated pre begin play on clients, even if I set them on the server during the spawn frame? that would be really awesome, but probably just wishful thinking
If they're considered at the same time, i dont really see why it wouldnt be the same
Probably because you're constructing the widget before you're setting the name values.... Either way, you're better off not sending the message with the player name like this to both save bandwidth and to prevent people from spoofing their name. All you should need to send to the server is the message the player wants to send. The server can then grab the playerstate of the controller sending the message and send the message as a structure containing both the playerstate and the message. When anyone receives the message structure, they should then read the player name from the playerstate received and construct the message format locally.
probably because the name is set after construct
Hi! Can someone please tell me what is the correct approach to working with Team specific data in multiplayer?
Lets say i have top down multiplayer game with 2 teams. Enemies only see each other if they are in a certain range. I Can achieve it using "only owner see" and a client RPC, when there is a collision of an actor with a field of view.
But how do i make it so that only the enemy Team has "only owner see" on, but teammembers have it off?
Read up on network relevancy - you can control specifically what actors are relevant to who programmatically.
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/Relevancy/
ownership will not help you with filtering things per-team because only one player can own an actor. It won't let you know anything about teammates.
Alternatively, you can manually hide/show actors if relevancy is a bit too big of a hammer (it means that actors could pop in if the process making them relevant takes too long)
Thanks! Ill take a read on that!
whats the best way to make it rain in my level for all players at specific times retrieved from a datetime
You could probably just have the game state on the server check if it should rain or not and then have an OnRep (replicated variable with a callback) notify the others if the state changed or not. This does assume that at most 100-200 milliseconds of latency won't make a difference. It seems pointless to me to replicate down all those timestamps when the server could also just indicate with far less data what the current weather state is.
I would also recommend looking more into the basics of Unreal's networking if this might still be confusing. There are some great resources in the channel pins. Specifically Cedric's website is awesome and there's also a video somewhere in the pins going over the basics 🙂
i dont understand how the server can run code without a client telling it to
i googled it but idk what thats even called
do you mean a third party server or server within editor
any of the above
the server is running a full instance of the game, albeit without graphics/sound/anything client-only
@whole pine I would recommend with first looking up some articles / videos in general about how Unreal does networking things instead of jumping straight into making something work. I like this video a lot as an example: https://youtu.be/JOJP0CvpB8w
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
it does not simply respond to queries to clients, it runs the game.
i know how to replicate and stuff i just dont understand how you run unreal engine code on a server, unless you mean i use a cloud script in playfabs website for example
generally by running on bare metal or a VM/VPS, not some managed web hosting service.
playfab multiplayer servers require you to upload the server build and it runs that build on a VM
and playfab cloudscript has nothing to do with any of this. You'll note that cloudscript is not the same as their multiplayer server offerings.
I don't see what Playfab or whatever has to do with this though? Wasn't the question how to synchronize rain? 😛
idk, i dont get how the game can only call code if its open, and if its open a client is playing it
so how does the server call something on its own
lets say i have a random float generator in my game state, how do i make the same float outcome for all clients
I would like to ask trying to make it more clear what your current issue is and just in general elaborate on what you're trying to do as at this point I'm not sure what the question is any more. Are we just trying to get multiple players to see the same weather? What do those floats have to do with that? If the question is how a client can communicate with the server or vice versa then I would again like to point you towards the pins / the video from above. How to do that is covered in there with examples etc. and is generally a quite basic thing to learn about 🙂
yes, just see same weather at same time
the floats were to generate random types of weather
i know how to replicate but i dont understand how rpc applies to the situation
cause a client needs to call the code
therefore a client is initiating the weather
I never mentioned RPCs though. That was in response to this:
sludge — Today at 22:02
idk, i dont get how the game can only call code if its open, and if its open a client is playing it
so how does the server call something on its own
As in the client can decide what the current weather is like?
i just want all players to see same weather at same time depending on which one is chosen by a random float generator
currently i have it so that on a timer is an event that checks the time and depending on what hour it is, it makes a certain weather type play
if i want a random weather to play, and i play the weather based on the random float
every client will see different weather types
As I mentioned in the first message it would come down to the server having a replicated variable somewhere. I suggested using the game state for that as it seems like an appropriate place. All that variable has to do is tell clients "Hey this is the current weather". Whether that's a float, an enum or even a string in the end doesn't matter. Then you can use a so called "OnRep" which is just a callback to have clients change the weather when the server sends a changed weather state.
if i make an event in game state that checks weather every 60 seconds, do i call that event on my pawn every 60 seconds too?
What does a pawn have to do with the weather?
nevermind
Wouldn't it be great if there would be a document/page that explains the framework classes and their usecases?
Like some compendium you say?
I did say this twice though :(
Yeah I only read that last message
I was gonna say theres a pin for it even, but theres a boatload of pins these days 😕
Back to the top we go
Shameless but I consider that one of the first places to go for beginners. Everyone with more questions can scroll :P
I agree, most of the other stuff is for more advanced users
I do like that video from Alex as well. For me it was a good one in the beginning 🙂
100%
The compenium is super helpful and helped me with learning multiplayer. Still reference it often 🙂
I can try shuffling that video up a bit. Not sure if one can reorder those easily
this is in my gamestate, based on what hour it is its generating a random float once and activating the cooresponding weather
so if i have this running on a server, regardless if someone joins later they will see the same thing?
Well let'S assume that's the cleanest way to do it, so we don't move the problem away:
You do realize that only one of your brances is connect, right?
ya
In addition, your RandomFloatInRange will produce 4 different random values, that's also clear, right?
And that a RandomFloat can also be 1.1 and never satisfy any of your 4 conditions is also clear, yeah?
Probably want the integer version of that
(Switch on int?)
Yeah that too...
How about.. No switches / branches at all? 😛
With all the respect but this seems extremely chaotic / unmaintainable 😅
If possible /desirable
But again, improving the code itself doesn't help right now. I think it's better to get the code working first
Less confusing for them
This is currently the bigger problem
Not sure what comes after that
Yea, essentially will never be true.
The thing defining if they would see the same thing would be the replicated variable
OnRep would give late joiners the chance to update the local weather
Again , random int into a switch on int
