#multiplayer
1 messages ยท Page 671 of 1
Yes. I know but I'm worried about my game server CPU performance because I used replicated properties for some sort of fire and forget data using push models instead of reliable rpc's . just worried about replicated property counts because of the iteration count of the replicator. should I ignore the overhead?
do you have an actual problem or just imaginary?
I'm worry about trouble at later time .
what is the case you are worried about?
uh RPCs are fire and forget
Iteration count of replicated properties in my pawn class .
the whole point of push model is to forego the property comparison each frame overhead
so I would call whatever problem you're describing as completely imaginary
Yes but its not recommended to use them and they recommended to use replicated property . I watched epic's live stream and they said that .
if you don't have a problem with performance don't do a premature optimization if you are not experienced and can kind of predict where problems might be, it doesn't make sense
did you ever had trouble with replicated property count ?
Thanks for your guides anyway . I'm gonna take it easy ๐
RPC for fire and forget
Replicated Prop for state changes
I have a server function that is called when a player picks up an item, it checks whether they can pick it up and then adds it to their inventory, which is a TArray marked with Replicated.
I want to notify the player's UI that their inventory has changed. I usually do this with a Delegate that the UI subscribes to. The problem is when I call OnInventoryChanged.Broadcast, I think it's doing it on the server, so the client isn't notified.
What's the "correct" way to fix this?
i actually used a fast array serializer for the inventory
it has client side callbacks when an item is added/removed/changed
check NetSerialization.h
only way when using bog standard TArray, is make it ReplicatedUsing and handle it inside the OnRep_Inventory function.
@meager spade Thanks! It's more of a question about how to tell clients that certain stuff has changed on the server. Like I just want to tell the client that owns that inventory component that a specific item has changed. I usually do that with delegates.
I guess I could get the server to do a NetMulticast function, and then that function calls the delegate? it's juts kind of gross
like i said, FastArraySerializer
is your friend
@rancid flame its how we do our inventory, its likely also how Fortnite does its inventory
@meager spade Thanks, I'll look into this some more then!
A separate question: I'm spawning an actor and it's showing up on the Server (when playing as listenclient) but never on clients.
Are there any usual culprits for this?
It was replicates in the Actor settings ๐คฆ
if some1 can help me figure this out that'd be amazing
client 1 shows proper cape colors/materials. the other clients always show the same color on all 3
I attempted a rep notify w/ bool check based on team as well and that just made so all 3 clients showed same color, either red or blue
If you have a boolean set up with Rep notify, then on the OnRep function, set the material you want to use.
Also make sure you're setting the boolean on the server.
That's not how it works currently in BP. You can set a rep notify variable on the client, but it doesn't update the server's value.
That's a good question, but I doubt it.. Lemme try :p
Yes it does o_o
And yeah, if you're not careful, and set the value on the client first, you won't get the repnotify when the server sets it.
BUT if you're smart you're not setting replicated variables on a client anyway.
so am i using multicast here at all then or nah? Just set rep notify bool on server and code the material instance from the notify function? Where does the client come into play
or is it essentially grabbing the 'local player' node and using that ?
You shouldn't be using multicast for state changes. A team value / color is a state.
The repnotify will run on any clients when the actor's value changes or when it becomes relevant.
The repnotify can then be used to perform whatever actions you want to do when that value is altered. So if you have a boolean called "Blue Team" and all players start with red coloring, then you can make it so it switches the colors to blue if "Blue Team" == true, and red if "Blue Team" == false.
Sure
If I spawn a replicating actor on the server, unless i gate its own logic behind a server rpc, it could spawn things on clients through natural spawn calls right?
You can spawn objects (including replicated actors) within replicated objects while running on the client, however those objects would not exist on other clients or on the server.
I'm running into some warnings about "No owning connection for actor. Function XXXXX will not be processed" and I'm struggling to wrap my head around whether its a problem or not. Do you have any experience with that?
It is. What you're trying to do is run an RPC from an actor that the client doesn't own.
Does an authority switch mean that when the authority section runs, that it's running on the server or that the entity running the logic owns the logic?
I had the warning for this section of code, then i added in the authority switch, and the error stopped. Is this the solution or am i masking an issue?
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...
Even tick on its own runs on both the client and the server.
So when your actor exists on the client, its event tick will play, and it'll start calling that Server RPC. Since the actor is not owned by the client, the RPC fails giving you that message.
Okay, that makes sense. that 15 seconds was exactly what i needed lol (at least to understand the authority node)
Here's another example of a place where there's the warning. I could again throw all of this logic behind an authority switch and it would most likely be resolved, correct?
Because both the server and client instances of the pawn overlap with the box?
This is a monster spawner, would it even need to replicate?
Correct.
And the monster spawner probably wouldn't need to replicate itself, as the actors it spawns themselves would be replicated.
The other thing is, you shouldn't be using "Run on Server" events unless you're trying to send data from a client to the server, and that's usually only needed to be done on the player controller, the player's character, and possibly player state. One could do it on other "owned" actors, say for example, a Pet AI the player has some control of, or any other AIs that are controlled by the player in some way, like units in an RTS game.
The HasAuthority node is your friend in this case - you usually only want the server to be running code on your actors in your game, not necessarily the client, and definitely not the client telling the server what to do (unless you intend for the player to do so of course!)
Thank you, that all makes sense! @ruby raft take a look at this short chat when you get a chance
This is a real shot in the dark but I'm seeing something really weird. When I play in editor on a test map, sometimes when a client picks up an item it instantly changes the client back to the project's Game Default Map. Like something bad happened so the server disconnected the client.
Is there somewhere I can set a breakpoint to see what's causing this?
In your gameinstance you can try checking this out:
Sweet I just found that in C++, adding it
I also just read that a UFUNCTION() RPC with WithValidation will kick a client if the validation fails, so maybe it's that
Oh yea for sure - if that doesn't return true, it's a boot.
OK that's not the kind of validation I was expecting heh, I just thought it wouldn't run the function
https://youtu.be/hvwM8AXohqU why does my visibility break once i set the variable with notify of my current weapon
So it works when first showing the second gun as you haven't "hidden" that mesh yet. @58 seconds into your video, you disconnected the one thing that should be making it reappear when swapping between the two weapons.
Hide current weapon > Swap to new weapon > Set Current Weapon > Show current weapon
Dude what do you mean nothing is wrong with my code it's not broken?
i check if the weapon is valid hide the weapon and set the new weapon to my index variable this is off of on rep and then i show my new weapon
please help
when i set the current weapon with notify it breaks
the visibility breaks
see i am setting the new weapon's visibility to true once i set the current weapon to my index
You didn't have that full path connected in your video.
I know
but i do
i was showing the tests i did
but please help i think this is a bug
on event begin play on the server i spawn the second weapon and add it to my array
Can you explain what happens or post a video when the full path is connected?
Yes
it doesn't hide my pistol instead it still shows it @sinful tree
on the server it works perfectly
on the client nope
if i unhook the set notify of the current weapon it hides the weapon im currently holding but once i hook up the set notify of the current weapon the visibility doesn't change it stays the same
did i do something wrong @sinful tree
this is what im doing on the on rep of my current weapon @sinful tree
this shouldn't be breaking my code
Can you show the code that's before this on your First Person Character?
Looking for the triggering event
Yes
im spawning the default weapon class, primary weapon is being spawned here @sinful tree
and i added it to the array
What are you doing on the remote path?
hiding the secondary weapon
by the way keep in mind that all of this works on the server window and doesn't work on the client window
and all the logic and line tracing works properly the visibility is being broken
That's all? Secondary weapon probably wouldn't exist yet as it's further down the spawn weapon server path that you create them - that's probably those errors you're getting (I know that's a separate issue and doesn't really correct the issue you have with hiding).
I'm asking as it may be your references being mixed up somewhere. I was thinking that you possibly were spawning the weapons client side as well as on the server - the Executes on Server and the Has Authority should ensure they are being spawned and being added to the array on the server though.
i am adding them to the array on the server the array is being replicated
what do i do man i still don't get it?
@sinful tree
im using switch has authority which literally does what you are saying
there is def a better way of doing this? how does the shooter game do it
The only thing it looks like it could be is your references are likely being lost in the code you've made - you already have a Primary Weapon Ref, and a Secondary Weapon Ref, and you're also using a current weapon ref, then you have your weapon array ref.
Perhaps approach it differently? Like if you know you're swapping to weapon index 1, you know that's your secondary weapon ref, which means you'd want to hide all other weapons and show the secondary weapon. You may not need to use the replicated array at all.
(Above just showing that you can hide multiple meshes at once if you ever intend to have more than 2 weapons)
Like something as simple as changing a "Selected Weapon" variable on the server to do something like this with the onrep
the same bug is still there dude i think this is a bug and not my code
how can the visibility not change?!?
I'm doing exactly what you're looking to do, and it works on my end. This spawns the replicated actors on begin play.
Pressing the "2" button swaps the visibility between two without issue using the OnRep function I posted just before this.
isn't visibility already replicated?
it 100% is
UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing=OnRep_Visibility, Category = Rendering, meta=(AllowPrivateAccess="true"))
uint8 bVisible:1;```
no need for the onrep
just have server adjust the visibility
@woeful pebble
ensure your weapon is "Replicated" also
oh and you need to replicate the static mesh component for this to work also
never mind the question i asked, i have a variable in my weapon blueprint called "bisequipped" this variable is rep notify in the rep notify function i basically set the visibility of the first person and thirdperson gun. i set the value of this variable in a server event :D
i hope i did it correctly cause it was working :D
sounds good
tho personally
i prefer the weapons to handle this logic
and not put everything in character, so what you did is good.
the weapons? well that variable is in the weapon bp and not character bp
thankfully
I actually had to override that visibility replication in RS2 to let client handle their own visibility. ๐ I didn't know it was replicated until then.
setting the visibility on the server doesn't replicate to the owning client sadly basically in the first person view the visibility will not change only in the third person view since it's being called on the server im guessing...
You have to set the mesh components to replicate too if you're only setting on server.
ohhhhhhhhhhhhhh
uhh
i avoid replicating un-needed components tho
and what you did with equipped bool, works well
yeah
and is similar to how i do weapons.
i saw the shooter tutorial and it basically called the unequip function in the weapon bp
when you switch
why does my firstperson gun of the server show up on the client's screen? is it cause of irrelevancy?
this only happens sometimes and not all the time?
never mind it's cause i wasn't using my rep method that one works very well and will update on every client that joins later
Anyone here know how to make a rotating door in Multiplayer not lag that hard? I use Component Move to rotate the door and If I rotate them first on the client and multicast it to other clients is smooth on the first client who interacted with the door but all others have a lag on the rotation and it's not smooth.
While testing in editor it's all fine but even with a ping of 4 to a real server the doors is visibly lagging.
Any idea?
You need to always interpolate everything on every client
In the case of a door, you should replicate the door state alone
"open", "closed" - and then animate the door entirely locally
Ok I'll try that
@rich dune multicast also doesn't really work well
say, im 15k units away when you open door
that door is not relevant to me, and i won't get the multicast
so my door remains closed
hmm if I want a weapon to deal damage during parts of an animation through line traces on the server
are animnotifies workable?
or do I have to use delay?
currently doing it with notifies
but if server is laggy it doesnt fire the traces
also, anim notifies tend to be optimized out
dedicated server can be made to run them
but listen server will not run anim notifies if they are outside what host iis looking at
you need montages for that
you don't need to use delay, and server is perfectly capable of running traces
i fixed that part
temporarily
forcing the server to update bones anyway
because my dmg and everything is based on the bones
listen or dedicated?
listen
you have to swap to anim montages
i am using montages
k
the client only sends the run on server when attacking
and the server plays the animation multicast
and the animnotify on the server gets skipped if its skipping frames
the way we distinguish them, we'll call then montage notifies, not anim notifies ๐
because there is a significant difference
with listen server
the clients CMC is running the TickPose
for their pawns
so their animations won't tick if the client is slow either
hmm I guess my problem isnt mp related per say
as it happens on frames when movement update arrives
its just fps dependent collision
CCD?
im running line traces every tick from a weapon during parts of an animation
from the last position of a few points on the weapon to current
yeah nvm
its my fps dependent collision
server client stuff working fine
client can lag, server will run the things
framerate smoothing?
but server lags and it misses the collisions
with traces each tick, that shouldn't happen
if the tick is too big
the traces never start...
cause it doesnt seem to get the montage notify
since its between ticks
atleast thats the way it seems to me right now
would have to run prediction/sim on the movement to disconnect it from fps I suppose
Why my character is jittering on movement? I set the max walk speed on client and server with the same value ( and i have no ping)
when do you run this
there might be no pawn?
print string on cast failed?
or controlled pawn is valid?
or print after set
with the value
@CoolAnswerMe#0294 Do this in the Pawn, not the controller.
i use onrep variable for this
and just change a bool/enum for different movement states
and call the movement change in onrep
in the pawn
hmm
is there a way to get the last value of an onrep variable on rep?
built in that is
Not in Blueprint but yes in C++
You just add the type as a parameter
In Blueprint you would have to keep a shadow variable
Also bear in mind BP OnReps aren't really on-rep callbacks. They do dumb things like firing on the Server too, or firing when the client changes something locally
Yeah, which is terrible
mm
If the server changes the value it will fire on the Server too, though
no simple way to change default behaviour on that?
Not in BP
no problem working in c++, but havent done much of it for unreal
I have no idea why Epic chose to make it work that way (not sure anybody does tbh), but it does
But just bear it in mind the logic is a bit more sane in CPP
But it may change the implementation slightly
good
dont have to make my own rep functionality then
I suppose you could put an auth switch in the onrep function
but efficiency :/
for the issue with it running on server
Hello, I'm having trouble with a multiplayer game
I created a function inside a BP like a door or a light that display a widget when you focus on it..problem is, the widget display on everyplayer on the server..
Is there a way to display it only on the player who is looking at it ?
There is an example with a door.
Naw that's not it, owner of most things will be the server.
Show how you're calling the Focus event.
owner of child widget actors for client is client for a possessed pawn afaik?
The problem is that that logic is being triggered everywhere. Widgets don't replicate anyway.
Event On Focus needs to run ONLY on the local client doing the focussing.
thats why you update it with onrep variable no?
or multicast/run on client I guess
depending
On focus is called on even tick like so, on my character
update the clients version with the new visibility options, or create it on the client based on an onrep variable or run on client/multicast call?
hmm, the door could run code after switch auth remote on getting focused, creating widget?
before sequence ?
mm
and the server could create it with only owner see on auth?
maybe
there are probably better solutions
but that would work for a listening server in my mind
i'll try
make your tick do a line trace on if its locally controlled
Somehow it does work, as player 1 is now the only one who see it, but if player 2 or 3 focus on the door, it still display on player 1
only*
i'll try this
SO SIMPLE !!
Can i get you anything? Cofee, 20000โฌ ?
thanks much i've been struggling on this for days
dang ill take those Euros lol jk,
least ya sorted it now ๐
this community is really the best
others came with extremely complex solutions that don't even work
years of experience some of us have ๐
Then u might help me for a small thing if u like maths :p
I posted it in blueprint if u want to look at it anyway :p
Don't do any of that, just check for Focus only on locally controlled character
Check is locally controlled before that. Only run the focus check on a local controlled character
Hey, yes we did this it's working ๐
What you have right now is every character on every client is checking if they are looking at an interactable actor and showing the widget if they are. What you want is that only YOUR locally controlled character on YOUR screen does that, none of the other ones
just scroll down ๐
I need some advice on how to have smooth wall running/climbing
I've been thinking about having volumes that would allow that and the movement component would check if the actor overlaps any of these volumes
And then set the current mode to wall running/climbing if it's overlapping and unsets it if doesn't overlap any volume
The movement component doesn't have to poll for that, just hook into the event overlap for the capsule
The issue is that I'd have to store a list of overlapped volumes to not end wall running it the capsule stops overlapping one while it's still on the next
But overlapping actors are stored somewhere aren't they?
Just have an integer that goes up by one on begin overlap with a volume and goes down by one on end overlap with a volume
Returns list of actors this actor is overlapping (any component overlapping any component).
They are but you already have all the info you need to detect when you begin and end overlapping a volume of whatever class you want to filter by, just keep a count of how many you are overlapping
On begin overlap, increment the integer, check if it's greater than 0, set while running mode.
On end overlap, decrement the integer, check if it's greater than 0, set wall running mode
Technically you don't need to check the integer on begin overlap but whatever
Yeah, I see
Where would this be done though?
On the server? Autonomous proxies? Or both?
How can I make it smooth?
Learn the character movement component inside and out.
It is not simple, at all. Especially in multiplayer. For single player things are a lot easier
Hi, does someone know if action inputs executes for both server and client or client only?
My character movements are still replicated jittered , while i'm having the same character movement on client and server
And no ping
ping = 30
Input is only on client
Are you doing anything weird or just trying to walk around?
Just walk around , i think this is a framerate dropdown
i have only 17 fps
is this normal with a dedicated server working behind?
What's your CPU, ram, and GPU?
Im trying to add an acceleration penalty to landing. Right now i have a one second timer that starts right when the player lands. i overrode the GetMaxAcceleration() function to use the elapsed time of this timer to use as an alpha to lerp between a acceleration multiplier of 0.2 to 1.0. If the player has just landed, calcvelocity calls getmaxacceleration which returns the max accel multiplied by the lerped penalty multiplier. Any idea why this implementation would cause net corrections?
{
float MaxAccel = MaxGroundAcceleration;
if(IsSliding())
MaxAccel = MaxSlideAcceleration;
if(IsFalling())
MaxAccel = MaxAirAcceleration;
if(bEnableLandPenalty && JustLanded() && !IsSliding())
{
const float TimeSinceLanded = GetWorld()->GetTimerManager().GetTimerElapsed(LandedHandle);
if(TimeSinceLanded > KINDA_SMALL_NUMBER && TimeSinceLanded < (1.0f - KINDA_SMALL_NUMBER))
{
const float AccelPenalty = FMath::Lerp(LandAccelPenaltyMultiplier, 1.0f, TimeSinceLanded);
if(AccelPenalty > (KINDA_SMALL_NUMBER + LandAccelPenaltyMultiplier) && AccelPenalty < (1.0f - KINDA_SMALL_NUMBER))
MaxAccel *= AccelPenalty;
}
}
return MaxAccel;
}```
@dark edge cpu = i5 , ram 32 Go , Gpu = rtx 2060
What does it mean "Is locally controlled" for a PC?
directly controlled by the local machine
the machine thats running it is also responsible for controller input
It will return true if i run it on the server player?
for the server yes
if you run it for the server player on a client no
or any other player
only returns true for a pawn that is controlled by the local machine
hmm
any conditions in parent beginplay?
but yeah
if a player spawns on your server
that wont return true
No conditions neither assosiated logic whit the spawned actor
cause the player is remote
If I have multiple actors attached to a parent actor, and then move only the parent, does only the parent's transform get replicated, or do all of the children change too?
that actor is controlled by another machine through a network
ergo not locally controlled
does it spawn for the servers pawn?
But each player has it own PC
yes, with this switch you should get the protoboard for every local machine but they wont replicate to the others, right?
oh
but server does not have it's protoboard
might be better to run it OnPossess
oh that's nice
Will try that
Do you mean execute all the logic on the begin player on Possessed?
make it a function or something and then call it OnPossess in the controller
or
in the pawn
Ok
beginplay can do things too early alot
esp with level streaming etc
on possess happens later
The input for "Is local player controller" will be the output of "On possess?
just make everything after "parent beginplay" run on possess instead
should work, cause afaik is locally controlled should DEF be true for a pawn controlled directly by the listening server
That works
but i've had alot of problems doing things in beginplay
Thanks โค๏ธ
no problem
Good to know this tricks haha
Hey guys, does anyone know how can I add a second cursor for local coop?
Your GPU and game thread are getting hammered by something. Wtf is you doin lol.
GPU is the bottleneck but that's a bad game thread time as well.
@dark edge thank you that was the corrupted Foliages
In advice for everyone DON'T use static meshes as foliage
prefer always create a foliage type
I have read everything about it but I still can't seem to understand how things are properly done
even within the component itself things are often handled differently
any ideas?, when the client shoots the host it moves the model of the character but the actor stays in place
Gotta do that on server only.
those get actors of class tho ๐
why dont you cache the spawnpoints in the gamemode
mans too dumb to know how
our spawn point bp on begin play just adds it self to the gamemodes cahced player starts array
thats cute ngl
ive found the host can "death event"people
but client's cant do it properly
Why different class per spawn point?
Just have a spawn point array, get random
That's exactly it. Client has to ask host to do it for them. Or rather, host should be making the call on whether or not someone is dead .
how would i go about that?
@dark edge
the spawn points are just for ease because im not an advanced coder
this is my first multiplayer game
and i just wanna get the mp side of things working
That's the very basics of a networked game. Find a multiplayer tutorial and start from the beginning.
Honestly if you're completely new, I do not suggest trying to do multiplayer right away.
In this series we will be explaining how to add online multiplayer to your games. First we are going to explain how it works, then we will go into creating lobbies etc.
In Part 2 we talk about relevancy and its various settings, what each one means and when you may want to use it.
SUPPORT ME
Patreon I https://www.patreon.com/ryanlaley
Buy Me a...
ive tried this guy's videos
he's said to use custom events then set them to replicate on server
ive used UE4 before and made a few games now
i got a simple demo level working with MP
and ive got a parkour & sliding system working
its purely the death that i cant get to replicate properly
Death should be a thing that happens on the server and is replicated out. A client should never say "that guy died". The server calls the shots on that.
should the host also be a player who's playing
That's a listen server.
Why are you calling that event then doing the teleport locally too?
That's all sorts of fucky. All of that code should only be happening on the server.
and you should really do that via the GameMode
ive disconnected the two
the moving to spawn points etc, has no reason to be in the character bp
The RESULTS (the fact that the character is teleported) are replicated.
Honestly it's all screwed up. Start from the beginning.
ok
so im using a line trace for hitscan shooting
when it hits a player
it casts to them and tells them to set their replicated variable to dead
Server or client?
That's not what casting is. "I casted to the hit actor" is not a thing. You casted the hit actor to a class.
Casting is basically checking if a thing is of a certain class.
"Is the hit actor a character?" Is what casting is doing.
The absolute simplest mtiplayer shooter I can think of goes like this.
Client does line trace.
Client tells server "I hit that guy"
(Optional) Server checks to make sure client isn't cheating
Server kills hit guy and respawns him
ok
ill try that
how would i say which guy?
should i still use a "cast to"
what code should i be running? a custom event?
btw i do really appreciate your help ๐
Line trace
Cast hit actor to character class
If it was a character
Tell server (run on server event)
Events can have parameters. Make the parameter for the run on server event a Character reference.
Yes. Should be reliable too.
Things that happen rarely should be reliable. Things that happen all the time (on tick or whatever) should not be.
is this how i should get my obj ref?
You passed it over in the event right?
im not sure
sorry to be difficult ๐ฆ
thats the other side of the line trace
i think its working but theres a few hiccups but that might just be the rng of the spawn choser
Why are you replicating that shoot? We're doing client side shooting here
ah ive disconnected the shoot from the line trace
If I want something to be multicast and then after that finishes, have something ONLY run on server, is this the correct way to do it?
Why not just spawn the acid bomb on the server? It looks like the animation would be replicated, but idk Im not to experienced
Is there a way to know if other players are playing on the same machine on PIE?
for debugging
I use Play As Client on the same machine
I'm still having an issue with my Launch Character node's movement being choppy on the client. I'm fairly sure it's getting corrected by the server, but I don't know how to fix that
I'm launching from the server btw
Do all animations look choppy or just that particular animation?
It's not an animation, and it's only the movement from that specific node, because everything else I've used so far is built into character movement
Hm then I'm not sure, sorry man
can someone tell me why this variable isn't being set to the correct value when the node directly before the custom even is the server setting its value?
What's required for an actor's movement to be replicated? I have the actor replicated and replicates movement set and it has a movement component. the server is seeing movement but the client isn't.
is the actor being spawned by the server?
Yes. That's actually what seems to have caused my problem.
I've been switching everything to have authority nodes in front of it and now my client enemies wont move. Turns out it was somehow my nav mesh settings got messed up.
Should I replicate line trace if I want them to ignore certain actors with tags? It doesn't work for the clients
Is there a good breakdown somewhere of cloud hosting providers that would be suitable for a dedicated server (for internal testing only)? Do people typically use AWS/google cloud or is there something better?
You can't rely on a replicated variable to arrive before the RPC to the client arrives. Instead, change your Cross Hair type variable to be a Rep w/ Notify and use the created OnRep function to perform the actions your RPC would've done. Make sure you use something like HasAuthority and use the Remote path if you want it to only do things on the client.
Thanks, I've got it working now
hmmm
does restarting a listener server host player do something to its gameinstance variables?
nvm i'll just look up the engine code
trying to replicate subobjects of a component, I have overridden ReplicateSubobjects() and called ReplicateSubobjectList on a UPROPERTY TArray of object pointers. These objects have overridden IsSupportedForNetworking() to return true, and have GetLifeTimeReplicatedProps() implemented and correctly listing all the replicated properties. The component itself is set to replicate by default in the constructor.
I put a breakpoint in ReplicateSubobjects and it seems to be returning false from ReplicateSubobjectList, any reason this would happen?
properties on the component itself are replicating correctly, but my bWroteSomething is just always false when trying to replicate subobjects.
https://gyazo.com/be996ebce02e9ff88094447ba0f53336
Here is the function, I set a breakpoint inside the if(IsValid(Handler) && Handler->GetPredictionID() == 0) block and it hits, but bWroteSomething false after calling ReplicateSubobject there.
Quick question: is it safe to use .AddImpulse() on CMC without caring about custom lag compensation?
Can I call it from server while local player moving and not think about anything else?
Source code tells its fine but I'm not experienced with CMC deeply so want to be sure
if its anything like Launch, you need to do it on the owning client and then the server otherwise you'll get jitter
but i would test it in BP and see what happens
Hi, Stupid question. I was setting up a text on top of a character, the text sets with the clients index, Server joins and text is set to 0, client joins and text sets to 1 however when the client joints it cannot see the '0' above the server's characters head. if someone could help me that'd be awesome! Thanks
Hey guys - any chance someone can point me to a decent direct IP connection tutorial? Im having trouble testing connection to guys overseas using steam. Figured i needed to try it the old fashioned way to see if it guaranteed finding eachothers game
open <ip> in console command
Steam should be disabled for this to work
When using Steam you will use sessions instead
That simple? Awesome - thanks @bitter oriole๐
Yeah, just don't use Steam with this
Yeah i figured - set onlinesubsystem to null right?
Yeah
Cool
@bitter oriole hey whats the console command to be the host?
Just start as server
I'm trying to call multicast RPC from a custom component code on the server. RPC implementation executed on the server but not on the client. Actor is not owned
What could be wrong?
Are the actor and component both replicated ?
Looks like actor is not replicated, as I can see in editor. How can I make it replicated by default in cpp? bReplicated = true in ctor?
SetReplicates
Hi Guys, Does anyone know how to spawn a particle spawner on a dedicated server? Or how to replicate it? Ran into a snag :c *try to make muzzle flash particle spawner
Particle system component on your gun, attached to muzzle, activated while firing
No replication required other than what's already in your weapon code
I have a volume that loads a streaming level, then that level loads another streaming level into a specific location. Sometimes, one of my 3 clients won't have the second streamed level load. I get the following message in their logs, does anyone know how I might resolve this?:
2021.10.16-23.27.55:574][982]LogSteamSocketsAPI: Warning: SteamSockets API: Warning SteamNetworkingSockets lock held for 6.7ms. (Performance warning.) ServiceThread,PostConnectionStateUpdateForDiagnosticsUI,ThinkPingProbes,P2P ThinkSelectServer,ThinkSelectServer,EnsureDataCenterRoutesValid
This is usually a symptom of a general performance problem such as thread starvation.
Is there any system built-in to restart/reset a sub-level in a multiplayer session? Basically I want all the actors in the sublevel to be reset to their initial position (re-loaded?), any deleted ones respawned, and any dynamically spawned ones destroyed...
The two approaches I've considered:
- Unload and Load the level, making sure it is not just visibility toggled (not actually possible from blueprint it seems). This is what I did in a singleplayer game in the past to reset a sublevel.
- Make custom spawner actors for everything to manage the lifecycle, and have them destroy actors and respawn them if Event OnReset is triggered.
The use case is like for a shooting gallery where the players will be shooting targets which will explode. After each round I need to reset all the targets.
What's the best way to do this?
Does anyone know about this? I need to do something different if players on the same machine, for debugging.
Is there a way to know if other players are playing on the same machine on PIE?
for debugging
I use Play As Client on the same machine
I think all my ideas regarding this are only possible with c++...
namely using the device id, local machine name, mac address, something like that, using replication for transmitting that info to the server or other clients and matching, this way you should be able to tell if clients are on the same machine as others
Just check if you're running PIE
how so?
Get world type, check for PIE
aight, a lot better than replicating anything here, but also only available in c++ I reckon?
Blueprint only multiplayer isn't really a thing tbh
https://answers.unrealengine.com/questions/222975/how-can-i-tell-if-im-in-standalone-or-new-editor-w.html here is a similar topic basically showing Stranger's approach
why wouldn't it be? I think Advanced Sessions Plugin with BP only could work great for many games
Advanced Sessions is a C++ plugin that essentially just exposes existing C++ functionality to Blueprint
well everything is basically C++ exposed to BP, innit?
Using AS means you already need Visual Studio and a W10 SDK
Your project is essentially a C++ project right there
but apart from building the plugin, you don't need any custom c++ classes is what I meant
And yes, you may be able to have a simple multiplayer game without additional C++ work but imho if you're doing anything you'll very quickly end up needing some
Sessions are also just a very tiny part of multiplayer. BP Only can work, sure, but it has some severe limitations. No FastArrays, limited repcondition. Inability to override a lot of native code that largely drives how gameplay is handled. Some of it isn't just about straight up performance so much as just how organized a tiny amount of C++ can keep your project.
Need something that moves and isn't a Character ? Welcome to writing complex multiplayer code in C++
Technically possible to do it in Blueprint but this goes into why territory faster than you can imagine
IMHO, anyway
I see, good to know
just wanted to mention it anyways
did anybody glance at this? just need something to point me in the right direction
posting again because nobody was around last night to see my question: any idea what would cause ReplicateSubobject to fail? PostNetReceive is never called on the client, and I don't think the object ever even exists on clients (tested by adding an OnRep variable that is never called either)
For those who have issues with dedicated server Character movement jittering , the solution is here https://answers.unrealengine.com/questions/961583/view.html
That's not the end-all-be-all solution. This will allow the client to tell the server where it is, rather than the server enforcing where the client is. If these kinds of options are left enabled, then someone malicious could basically allow themselves to move anywhere whenever they want.
I always thought just the player controller exists on the server and client but does a standard character as well?
Any replicated actors that are spawned on server can exist on clients - they are "linked" together over the network by a UID, so if you pass a reference of that actor from the client to the server, the server will be able to determine which actor you're actually looking to reference on the server. The relevancy settings and I believe the repgraph determine whether or not that actor exists on any particular client - this is to prevent the server from always replicating all actors to all clients when it's not needed.
If you spawn an actor on a client, even if it is replicated, it will only exist on that client.
C++ is fine, but I don't think it is a good idea to add extra replicated variables just for debugging...
I got your point, though. a client cannot communicate with another. I need server between them.
Isn't that possible for a client on other machine to join a PIE multiplayer game. I don't use that approach now, but if that is possible I think I would use it in the future because it seems convenient.
may not. correct me if i am wrong
anybody know how to improve this replication code for lights (engine thruster) so they won't flicker for clients?
I don't believe you can join a PIE game from another machine, unless maybe you directly do "open <ip of the dev machine>" from another client maybe, assuming all ports open and no OSS set up on that client
I probably mistook for something else then.
Then checking PIE seems ok
why does running my code on the client window crashing unreal engine?
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000
what does this error mean and why is it always with the client window?
Debug it
i sort of found out that when i don't have authority im doing TWO server events every .1 seconds and so i just put those two events into one event and luckily fixed it. yes this was entirely my fault
No I mean when you have crashes, debug it through VS
EXCEPTION_ACCESS_VIOLATION is the easiest error to fix
Ah....understood but my problem was solved anyways.
im guessing there's a limit on how fast you can do a server event and how many you can do
Or it's pure coincidence and you still have the crash
that's true
Do you have any C++ code? Cause it's kinda rare to get that crash in blueprint.
No.
I don't seriously
other than one empty c++ class i created so i had a .sln file
Yeah. That's a lot of guesswork without debugging to find what function is actually crashing.
hey. Probably an obvious error but I've never had this happen in replicated projects before so I might be missing something. This project is C++ based, using client-host model.
What I am trying to do:
GameState calculates a value . GameState passes this to the player controllers for all players. The PlayerController passes the info to a UMG widget.
This is done in a C++ mostly (the widgets are spawned in via derived blueprints)
What is happening:
The information is being passed the host player. Any other other player has a widget show up but does not get the data. While debugging it appeared the GameState could see the correct PlayerController. The PlayerController could not see its own widget however.
What could I have overlooked/missed?
Why not do the calculations on the game mode though? the game mode is server only and so you know the calculation is being done on server
Replication has its issues of not updating properly when you test play with 2 players they don't both spawn at the same exact time why not try a delay/timer?
Per Cedric's documentation of replication, the type of calculation I am doing falls under GameState and I am using that as guidance for where to place certain calculations.
Have a delay in place. Again the GameState is seeing the PlayerControllers. The non-host player controller is not seeing its own widget
To update this widget are you using a client RPC or?
i think you have to
for example you can only cast to your hud class on the player controller with get HUD only on owning client events
not on server events? or perhaps you have a has authority/is server check?
I think that might be the issue too. I think I set up my client RPC incorrectly
I am about to re-factor the code and see if that resolves the issue, give me a few minutes and I can update
because the host is technically the server and anybody who joins the host's server is considered the client
at least i think that's how it works
That is my understanding too but god knows I probably have it wrong ๐
I honestly think I am not replicating the events correctly. Let me just try to see if this change I have in mind resolves the issue
@novel sirenOut of curiosity. What is creating the widget? What event?
got it working
I had the wrong part of the chain replicating on the client
and @kindred widget the local player controller
On a side note. It's often best to move any widget based logic to HUD. Your replicated logic can get the local HUD to get widgets or do things. This enforces the idea that it's client only. Less issues with it being the server or client version of the controller since HUD only exists on the client.
Fair point. I thought of that but in this case I decided to bypass that route. My rationale was in this case that the players interaction with this particular widget has a replicated effect (e.g., pause the match)
(to be clear the replicated events do not occur in the widget for obvious reasons, I am not an idiot)
(they just call replicated events in other classes)
Sounds like an RPC in playercontroller. Widget gets local player controller, calls that rpc. Widget binds to a delegate in GameState that gets called when the Paused state changes, and updates it's own UI based on that change.
I haven't implemented those events yet
just the rational for why I went past the UHUD and straight into UMG for this
I'm just saying that it shouldn't really matter what holds the widget. Widget should be able to be added from anywhere to function with no inputs from anywhere else for the use of pausing the game. You can easily get local player controller via GameInstance, and GameState also has a global getter.
oh yeah, that I realised which is why I was confused by my bug. I just had replicated the wrong event (mostly cause in my pseudocode for this I had one function to do what I wanted, instead of two like I ended up with)
and I replicated the wrong one of the two... >.>
Haha. I feel you. I just converted a slider widget to C++.. Took me half an hour of trying to figure out why it was getting wrong values. Don't use direct gets when there is a getter function specified. ๐
At least not in 4.25+
pre 4.25 you could get away with it to some extent (if memory serves)
In this case, the slider UWidget doesn't update it's value. That is just used for default setting. I was getting the default. The getter, gets the actual value from the UWidget's internal slider. Slate, man.. Slate.
There is a reason I hate doing UMG in C++
I'm starting to love it. It's just very quirky.
in terms of BP:
UMG
Interfaces (I am just not a fan of UE4's API for interfaces in C++. So much easier to deal with in BP)
you want to hear me swear like a banshee at something? Give me UMG work to do - especially on the graph side of it. Want me to just kill someone? Ask me to do a widget tree in C++
and add an interface to the widget ๐
c++ interfaces are full of caveats
but blueprint is oh so much worse
when you find yourself debugging a packaged game only bugs
See I have an easier time seeing interface related bugs in BP, not in C++. Other bugs? Usually better in C++ for me.
then you'll find yourself rewriting those into c++ where they belong
I still do them in C++ for the paid work I do but man I do prefer them in BP, if they are done right.
can't debug blueprints without the editor running
Just started getting into Networking again - If I have a server owned actor, that replicates to the clients, and the clients are supposed to call a Server RPC function on said actor - Is there any way on the server to determine which client send the request? Idea being a permission system that's server authoritive.
Kind of out of the loop for years, with networking, so might be thinking about this completely wrong
yeah, no
you have a No owning connection for <insert actor> warnings in the logs
every time you try that
client has to own the Actor to RPC through it
welll in theory you could still debug blueprints... the fancy noob way ๐ (print strings!)
(I will go punish myself for my bad joke)
@exotic spindle Clients can't call a ServerRPC on a Server Owned Actor. If this is the case of like opening a door. You need to interact with it via the pawn or controller. So like line trace on the client, take the hit actor, send that through an RPC to server as an actor pointer. Call an interface on it on the server. Interface function in the door can set it's state on the server then replicate to clients that the door is opening.
In this same case, your server can do permission checks after the RPC before and/or after calling the interface function on the door.
While folks are here I have more general question....
@kindred widget Ah, yeah right, I start to remember. I'm still in the rough planing stage of this endeavour. Thanks for clearing that up.
So the game I am contracted on is an RTS game (and no it is not violating OOP like my series if you recognise my name) - the camera pawn itself is replicated but the movement is not replicated. The rationale behind this decision was: 1) players can individually set their own cameras speeds 2) even if 1 wasn't true, and the player upped their speed to move across the map faster, it would not give them any benefit as there will be other ways to jump the camera around 3) the other players can never see each other's cameras. Given this set up would you still not replicate movement itself or would you still replicate the movement? (The only reason I can think to do so in this case, especially due to 3 is due to cheating, but again 1 and 2 address that)
I assume this is like a Starcraft camera setup?
I'm pretty much new to multiplayer as a whole, but does anyone know how I can use media players / sound with multiplayer support? sorry if I'm interrupting anything
Doesn't really need to be replicated at all I don't think. There's no reason for it. It's all local interaction and view. The most you'd ever need to replicate is the position if you wanted other players to see where someone else is looking at on a minimap or something. But that would be client updating the server of it's own state and skipping owner replication.
As far as cheating. Let them hack the camera all they want. Visual state of things should remain the same and be affected by authoritive replication elsewhere.
That was my original thought
Multicasting is how I do my replicated sound events if other players can hear it
@kindred widget thanks for confirming I was not going batshit.
You may be. But not about that. ๐
Ah thanks a lot!
I mean I am well past bat shit, let's be fair
You usually do this locally based on replicated stuff. This is an exceptionally complicated question because there are a lot of edge cases and different implementations based on what you need to do. For instance, your players finish a boss fight and you want a cinematic to play. You replicate or RPC a simple value through somewhere like GameState. You use this value to look up which cinematic to play and play it all locally. The only networking being the lookup data for what it is you want to play.
but Fog of War, hiding units, all the other visual stuff is handled elsewhere and replicated so that if they hack the camera it won't matter. And there will be a mini-map and hot keys to jump to various spots already.
oh @small stratus he is right, I was thinking of simple sounds (like music and footsteps) not more major events
What I'm trying to do is get a video to play through all clients, with sound
sounds simple but it could be a lot harder I wouldn't really know
multiplayer aint my thing
Start simple. Make a non parameter multicast. Call that multicast where you want them to see the video. Set the video hard coded to one video. Then send that multicast from the server.
This will play the video locally for everyone.
sighs yay time to refactor code.... cause I am an idiot and forgot that I didn't pass that value cries
After that, you can start branching out. Add a parameter to the multicast that's a GameplayTag or Integer, or Enum, whatever you prefer to handle your data. Then switch on that to select other videos.
That makes a lot more sense than just playing the video. Thanks a lot, I'll give it a shot
So I've managed to replicate the media player, but how could I replicate the sound? Any ideas
hm. When I package the project, it isn't working. But when I play as a listen server with 2 clients, it plays on both clients
Hello everyone.I am playing a camera shake on my anim montage.But when it is playing it is playing on all clients instead of one client.How can I stop it.I am playing it on fire animation
How are you playing the video? If you're using the MediaPlayer, you need to test without RunUnderOneProcess
It does the same thing as before
Not sure how to fix this
I have an issue where UGameplayStatics::SpawnSoundAttached causes a warning on a listen server when there is at least one client connected.
LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: AudioComponent /Game/Maps/UEDPIE_0_Develop.Develop:PersistentLevel.GBP_AIActor_2.AudioComponent_0 NOT Supported.```
There's no issue on a dedicated server with several clients or a listen server with just the host.
I'm a bit confused since I'm playing sounds the exact same way in other places with no errors, but this actor in particular seems to cause the error when spawning the sound.
is it possible to pass variables around from one client to another? I need to keep track of who is currently rolling the dice and im not sure how to tell the clients who is rolling and who isn't. Can client transfer data like this?
Probably need to go Client1->Server->Client2
So some server call that tells the server what client you want to send a message, then the server can send the message to that client. Even if it would be possible to do it directly it would not be safe
if it wouldn't be safe, how else would I do it
The way I said :p
That way you can validate it on the server and make sure one client doesn't use it to crash another client
Hi guys, i'm an indie dev learning UE!
Do you recommend using **AWS Gamelift **for multiplayer FPS titles?
(Example: Counter Strike)
1-What is your experience, is it cheap?
2-What tips you would give?
I like playfab
If you're learning Unreal I would very strongly suggest cooperative games with no servers, too
Well technically I would recommend singleplayer
But hey
Turn based is so underrated, you can essentially not do any actual multiplayer code, and you have like 80% of the value of a multiplayer game
Makes anticheat a lot easier too
Hi, i set all the things for replication on actor, but it's value doesn't replicate. Here is example: I have 3 players, one is server, other 2 are clients. I made so when i press a F key, replicated value increases for 1. But it changes only on one side and never replicates
I increase time by this function
Which is just this
Replication is server to client, not the other way around, so check that first
Yes, i know it
So you're only changing Minutes and Days on the server, right ?
Yes, i even have GetLocalRole to Authority only
and i tried this function as RPC Server
Results are the same
How is TickTime called ? Did you confirm it's called ?
Did you override BeginPlay or something ?
It's called from a Timer, that i run from BeginPlay.
Yeah, i just noticed
But the function should apply only on server i guess
yep, already fixed
I also see no initialisation value for those variables in constructor
Anyway, I don't see any error in the code here
Im just very lucky for issues that has no reason to appear
added initialized values in constructor and made BeginPlay Authority Only. The same
Need to see the rets of the code
I forgot about debugging, so im gonna look what is ever happening on different sides
On client it's still 0, so it's not issues with how i get the value to print.
And actor seems like the one for all sides
code for this actor
Where's the log ?
In BP. Just gets actor from world and displays data
I thought it's not reliable, so i checked with debugger
it's the same
How is the world manager spawned
I dragged it to the world in editor
Check that it's replicated in the details panel
There's your problem
I have a 3D widget component attached to an actor. On that actor's beginplay, I want to give the component a reference to its owner. How can I get it to have a valid reference on clients?
hello, i have a weird bug with Run on Server event, i marked it as reliable, the actor have player authority, but it triggers just once on server, if i call the same event second time, after some frames it doesn't called on server
any ideia why this happens?
i find out that it's the net dormancy, it was set to something else than awake/never so the actor was starting awake but getting dormant after few time ๐คฆโโ๏ธ
Hey guys how do i replicate a sound or play at location for all players? in C++
most likely with multicast RPC
that is common case
Hello,
I'v a Jog_Stop animation in my AB. This animation uses root motion. My character does a little step forward in this animation. But I know how not recommended root motion is for multiplayer games.
What alternative do I have to make this little step forward without root motion ?
Is root motion this bad in Animation blueprint (for multiplayer)?
Thanks ๐
Hi, sorry to randomly reply to this but i am having somewhat of a similar issue, where the movement isnt replicating. To fix this i just need to spawn each character from the server right
Yeah, run a custom event that's set to "Server" aka (Server RPC) and have the server create the actor that's being replicated. Make sure the actor's movement component is also replicated
Alright, would this also be the reason that AI that are placed down and not spawned by script dont have their movement replicvated or would that be something else?
That would be a cause of it, but not necessarily the only reason
what other reasons could there be to it?
Any number of things really. Maybe your ai is broken or anything unrelated to MP
Ok Thanks
I wouldnt think it was broken as in singleplayer it works fine
Does AI run on the server by default? I've never done anything with it and don't know, but it could be that you need to run it that way so that the server doesn't overwrite the client's request to move
Or, for example, your client could be writing to a blackboard that the server is ignoring because it has authority over the client
I return, again!
This project is an RTS, client-host approach. I am trying to set up my sun rotation. To do this I use an actor. This actor is made in C++ and is replicated. The rotation event is a multicast event (because it was not replicating without NetMulticast). What happens changes slightly:
- In stand alone - works fine.
- In listen server with just host - works fine.
- Running dedicated server (just to see) OR listen server with more than just the host - the directional light vanishes...
I am a bit lost as to why that might happen - again probably missed something obvious (though not as bad as earlier where I placed my RPC in the wrong spot... twice)
In the instance of "listen server with more than just the host" does the light vanish for everyone, including the host?
Also, maybe instead of replicating with an RPC, you use a replicated variable with a RepNotify that can then change the position as needed?
including the host, yes
didn't think of RepNotify, I will try that tomorrow (or after I eat)
Anyone have experience with widget components? I'm really struggling with getting ai health bars to replicate properly.
So I have a player character with a movement system that correctly replicates. I am working on a drone pawn class with a floating pawn movement component. For some reason the movement is only done on the client and not the server.
The pawn is replicated and the box "replicate movement" is checked
this is the look input, i was mainly looking at it since it was the same functions used by the player
but this is the movememt for the drone
Show some code - how are you replicating anything?
I have an actor that replicates and a 3d widget component with component replicates set. I have this logic.
what movement component does the drone have?
I have tried having the custom event have varying replication states but it never quite works.
yeah that has no built in movement replication iirc
nor smoothing)
@charred crane you can not replicate widgets
does character movement component include flying @meager spade ?
and why is a HasAuthority branch, running a server rpc @charred crane
@unreal epoch yes
set its movement to flying
ok, then perhaps I will just make it a character instead of a pawn
Yeah it's weird because they are replicated. I have both a client and server instance of the widget component. One has the reference valid and one doesnt. The RPC being server was messing around with it being a multicast and trying a bunch of different stuff.
if you go pawn, you will have to put in smoothing and stuff for the movement
if you ever get it working without, it would just be skipping/jumping when moving
you can not replicate WidgetComponent @charred crane
UI is all local, it should not/ can not be replicated
Why would I have 2 copies of a widget with the same name then?
because your logic is wrong
you need to create the health bar locally
and update it via events/tick
when it takes damage/gets healed.
because i'm trying to figure out how to do it
Why before rather than after?
and turn off replication on widget component
because it needs to be done locally @charred crane, and you don't need to gate it.
@meager spade how do I change the movement to flying instead of walking? it is a function or can I change a default variable?
CharacterMovementComponet -> Set Movement Mode
It seems to be working, so thank you for that, but could you help me understand a little better why it should be done before the authority node? Could it have been done off of the remote output of the authority node and have worked?
The other day I think Datura helped me realize that most of my logic needed to be behind authority switches, so that's what I've been doing. The only logic I don't want on the server is UI, anim, vfx, sfx, user input, etc, right?
ui never spawns/runs on server
if its dedicated
if its dedicated server
then yes you can do it off the remote role
if its listen server you have to be more careful.
but p2p the host wouldn't see it, right?
I have another problem. I'm testing in PIE using the dedicated server checkbox. My melee attack relies on the animation of the swinging sword overlapping with an enemy to deal damage. I have the below logic. the client triggers this, but the server doesn't. When testing in a packaged game using the steam subsystem and a p2p connection, it works.
Here's my attack logic
I guess my question is: why does this fail with a dedicated server and succeed with a p2p?
Server Attack calls a server rpc which calls a multicast rpc to run that third image
the third image has the animation in it
your server is not running animations on dedicated server.
which is why its not working
you mean like dedicated servers just dont do animations?
blast these dedicated servers lol
ya
set VisibilityBasedAnimTick to AlwaysTickPoseAndRefreshBones
sure enough, that does it. Thanks again!
is that a relevant perf hit in general?
it's only gonna be on a max of 4 entities in my game, but just curious for future stuff.
I'm trying to get a placed static mesh to replicate its visibility and collision status. The entity in which this logic is located is not replicated.
When EventBeginEvent is triggered, the collision is enabled, but the door visibility does not change for clients. it remains invisible.
is the door replicated?
its a placed static mesh, so I'm not sure how to replicate it other than using the SetReplicates node as you see in the first image
it looks like an actor
so you can set it replicated
oh wait
your doing a multicast
what actor is this in?
ignore
the door actor exists inside the level
ok that makes sense, this logic was from before i made this not replicate
there's no need for authority switches in an actor that doesn't replicate is there?
because wherever it's spawned, it'll be the authority?
right
a non replicated actor will always be authority
a client spawning an actor, will have Authority role
Authority is who has authority over that actor
right
for replicated actors, the server has authority cause only server can replicate actors.
A static mesh that's placed in a level is naturally replicated, so I shouldn't need the SetReplicates function either
its not replicated
it exists on both client and server, but that is not replication
that is cause its in the map
if it needs to replicate stuff then it needs to be set as replicated
at that point, the server will take ownership of it
Will SetReplicates retroactively remove the client side version of a placed actor like that?
and replicate it via its name (if we want to get technical)
no
setting it to replicate, the server will adjust the role add it to replicated actors list, and send that to all clients
clients then grab the id of that actor, and map it to the actor in the world
(for pre-placed map actors)
Spawned replicated actors is slighly different, as server willt ell clients to spawn that actor
Ok here's my new logic. It works on dedicated server but not p2p
Wait, it's not working because the boss ref is invalid. disregard.
how come you are setting them to replicates on begin play instead of in class settings?
Because it's not a class, it's a static mesh that is placed in the world.
I mean, it is a class, but not like a bp object
well okay that explains it
Also, I just realized that the object all this logic is in is placed in the world, so I have two instances. I need that to be 1 instance i guess, so it has to replicate so that it doesn't fire off logic I don't want to happen, right @meager spade ?
by the gods, i've solved it
yo so I'm having an issue with connecting to an IP on android
you can host a server fine but can not connect.
So thereโs 2 ai one that the player influences and one that they canโt touch but both run off the same bp just with different teams. The one they canโt touch moves replicated on both players the one they influence dose not
How would I go about doing that
@sinful tree RepNotify worked kind of. I had to force the notification to go through. And it takes a couple of seconds (more than 5 but no idea how much more than 5) for it activate. (I know it is at least 5 because I have a built in delay for something unrelated that is 5 seconds and that went off before the sun began rotating)
What do you mean by forcing it? When you set a variable on the server, the generated OnRep function should fire when the client receives it.
The client wasn't (I remember reading about who sets it determines if it fires)
so I had to force it to fire for all
Can't seem to get the client side to function while server side is working normally. Haven't changed anything, excepting taking away some VR stuff. From the pre-built top down package. Anyone else gotten similar issue?
In the event graph for movement etc it still firing and looks identical for both client and server. But the client wont move.
So run the event that tells it to move from the server rather than client?
anyone here by any chance ever implemented backfill tickets with playfab in blueprint in ue4 in a p2p game?
Thats the event that is used for movement of the ai
Yeah the template i am using was initially meant for single player, I'm attempting to convert it to multi
My guess would be that that event needs to run on the Server
Would it matter where it is called from?
Nop
If you're not familiar with replication I can really recommend this video series (It's not from me).
https://www.youtube.com/playlist?list=PLemTaQ_N519DocM4AqiK08GfsUSnxRPdv
Hello. I am new around here, I apologize that English is not my main language. If it is not a suitable channel to ask this, I am sorry. In a multiplayer if for example I have 100 players in the same game, how do I assign a camera / point of view to each one? I can't find any mention in the forum or youtube about this.
Thanks ๐
I go search onto this. Thanks Lorash โค๏ธ
does anyone know where to look for simple AI that roams and around and chases the nearest player in multiplayer?
im using pawn sensing and behavior trees and it keeps getting stuck near my second player which is the client
How can i make the ai find the closest player?
Ok im having a weird issue, im using spawning volumes that were in this template and i have the items that are spawned being replicated but the 2nd player is only able to see the ones that are in its initial view when it was spawned rather than all the others which are spawned
This is where it is spawned
both the spawning volumes and the items are replicated and the event called to spawn the items runs on the server
It does matter, the Run on Server/Run on Client needs to be on an Actor that is owned by an owning connection (PlayerController) via SetOwner. Multicast must be used on a replicated actor, but does not need to be owned by anyone.
just to clear up mis-advice
Any idea about the bit above?
To add running it on multicast allows the user to see the initial set but then generates a 2nd set in the area
in editor, at the bottom right of your outliner when looking at the scene during play
there is an illuminati eye
you can use it to expand a menu which lets you select which world is the outliner showing
(client/server...)
use it, figure out if you have invisible actors on clients, or you don't have actors at all
It isnt spawning the actors for the client when running it as the server
If those are supposed to be replicated actors, don't spawn them on a multicast. Spawn them only on the server, and if they are marked as replicated, they will make it to the clients.
Dose this look about right for the replication settings?
Sure, that'll work.
Yeah the event is running as server with them settings and it is not spawning them for clients
What event are they firing off of?
Don't do this. The server has its own begin play.
think of the replicated actors are fully separate and independent instances, which they are
the only think thats special about them is
A - server can set replicated variables, that get propagated to clients, with optionally having a callback when changed
B - those actors can send RPCs (to another instance of the Actor on another machine, that happens to have same NetGUID, but is in no way the same instance)
so every engine function/event that would normally run on server "on its own" runs on clients as well
that very much includes BeginPlay, Tick, Collisions.... and many other things
ok so how would i go about achieving it to run soely on the server?
depends on the scope
where you'd put it
you can put a branch IsServer there and just call the spawn event
not ideal for every use-case
They are placed in the level as fixed points where the resource can spawn
but it will always run only on server
you can just pre-place them on the level if they are "fixed"
but even if you want to randomize those each time the game starts
those
A - do not need to be actors, it can just be an array of vectors
B - most certainly don't need to be rerplicated
probably didnt explain that as well as i could of, the script is running on a spawning area for a type of resource, so they are predefined areas that the resources can spawn at random positions when the game starts and then there is a timer that will regenerate on when they spawn it will place the actor into the world for the corresponding resource type
I love his work. He's not so active on our mutual discords any more
I will have to look out and see what has happened to him.
So weird question, and one I feel I should know the answer to. With Replicated elements in a USTRUCT, used for a data table, where the heck do you do the DOREPLIFETIME bit? Also if I am doing my data-table in the editor but the struct is in C++, do I need do do anything special for replication? (I found very little info on replication and structs/data tables and want to ensure I missed nothing before I forge ahead with my code)
Found a fix that seems to work for mew for now as im only making a prototype currently, just made them always relevant and it seems to work, anything i should know about making it always relevant
if there are any additional changes to the actor on the server that are replicated, or RPCs run on the actor, then the client will always receive them. Relevancy is a way of preventing an actor from always replicating when it doesn't need to, for example, if a client is really far away from an actor, it probably doesn't need to know that the actor moved, if it was damaged, etc..
so pretty much it will always update every client of what happens to it no matter where they are?
There are other factors that go into relevancy... I know distance for sure is one. The idea again is that relevancy is a means of trying to limit the amount of network traffic you're sending and receiving. If the actor is not relevant, then it usually gets culled (ie. the actor no longer exists on the client) until it becomes relevant again and the server will begin replicating it again. If you're not really changing anything on the actors, then marking as always relevant probably won't cause any harm (just a guess).
If you intend to add more mechanics on to these actors, like it looks like you're dealing with trees and rocks, so maybe you'll have a resource collection system on them in the future... Then you probably don't want to have them always relevant since they will be changing when someone goes and harvests from them.
hmmm, when it is not set to always relevant it will not show to the client unless i increase the net cull distance an astronomical amount
Hi, someone replied to me the other day but I cant find it, what's the best way to make it so when the host presses the start button for the lobby screen, the buttons disable for all clients?
Yea it's not based on the standard units, it's a much higher value for some reason.
Hi i have made a multiplayer listen server player list and added 4 players for testing. So only the Server and client itself comes up. So if i'm client 1. Client 1 and Server name comes up and rest as undefined. If i am client 2. Only client 2 and Server comes up rest is undefined. Etc etc. What is the cause? I use player state to get the player list thanks help appreciated.
ah ok so just put it extremely high?