#multiplayer
1 messages ยท Page 2 of 1
Check this not the previous one
oh so I should set it replicated on server then multicast collisions?
Alright thanks but I still want to get it working using this method
first before I try learning the other one
To get something working the incorrect way is a bad habit
If it's a state, use repnotify. This sure sounds like state to me.
You would repnotify MyStaticMesh. You would multicast PlayExplosionFX
Yes you should be able to. Travel with ?listen
If an OSS is implemented, such as Steam then yes
If not, then no. It's done by IP addresses which is bad, but good enough for fast testing
Yes. That's why you got IsNetRelevantFor. Override it and use that state in there
Thanks, I will give it a try!
u mean, as long as ip doesn't change - controllers netID will remain the same regardless even if i restart game?
and as i can suggest, the one who gives netID - online subsystem?
NetId is given by an OSS. Even if you restart the game it's still the same.
If multiple players are playing with the same remote IP address, the wrong player could take over another disconnected player on their network which is not the correct way to handle disconnects
But I don't see a shipping game without an OSS
is it safer to use playerState's name?
It's safer but still a bad habit. The only unique identifier you should be using is the NetId
Look at AGameMode::AddInactivePlayer for reference
You should be overriding that if you want a different behavior
okay, thank you
NetID are safe because the OSS has access to identifiers that are truly unique for specific accounts. For example. NetID for a Steam user is their Steam ID number.
Not sure what Null uses. I don't know what Epic's are, but I know Steam's are your Steam account ID number. Epic likely has a similar number per account, just less visible.
got it, thanks
can someone clarify something for me about multicast RPCs
I assumed when you call a multicast rpc, the code inside that RPC function is executed on the server aswell as all client machines
but the behavior I'm getting, is that the code is only being called on the server
it executes for all clients on the server, but not on the actual client machine
A Multicast should only ever be ran on a server version of a replicated object. And then yes it should run on every machine that object is replicated to. If you run it on the server on a non replicated object, it will only run on server. Likewise if you run it on client on either a replicated or non replicated object, it will only run on that client.
thanks for clarifying, I think I found my issue
I was sending a multicast RPC on BeginPlay of a replicated actor
but none of the clients were getting it
I guess RPC's on BeginPlay event are a bad idea
probably too soon
Your RPC likely reached client before the server had a chance to replicate the object to client.
makes sense
when is the best time to send an rpc to the clients?
I mean I can add a timer to delay it
but
seems dirty
I want to send it as soon as clients are "ready" to receive it
There likely is no surefire way. If you need a sure RPC, multicast probably isn't what you're looking for. What is your usecase for it?
oh is that so? If I add "Reliable" to the multicast would that not cover it?
my usecase is as follows:
- player joins server and sends his nickame (sent as an option ?NickName=etc...)
- server receives the nickname in GameMode::PosLogin and stores it in the PlayerController
- then the character of the player is spawned on the server during beginPlay, I was sending a multicast rpc to all players letting them know the nickname of the player that just joined
Not really. The issue is design theory. Mutlicasts are usually for one time things that server needs to dictate that aren't stateful. For the same thing that is stateful you use a replicated property. The reason for this is because you cannot promise timing to clients. One client can get the RPC up to 250ms after another client. One client might connect after the RPC, and never get it and be missing the required state.
I honestly don't have a lot of usecases for good multicast use. Simplified chats maybe, where you don't have to care if new joiners see the old chat.
I was using the beginPlay event on the server to check when new players join, but thats just too soon I guess
If you want a one time initialization of something, you can make client tell server that it's ready, and pingpong Server/Client RPCs reliably back and forth to init something. But generally speaking replication is usually the best case in a ton of scenarios.
I tried doing that at first but ran into other issues
because I was calling an RPC from a simulated proxy which unreal does not allow
For your use. That generally sounds like a single Server RPC to send the nickname. PlayerState can store the name and broadcast it both on Beginplay or OnRep of the property. Just check if it's a valid non empty name before broadcast. That'll cover pretty much all cases.
well the thing is, I'm not sending the nickname of the player that just joined to himself, infact, I need to send it to everyone but himself, so other players will see his name
Well, no, that would break.
thats why I thought about a multicast; new player joins, send his nickname to all other players
New players would see every join immediately with that. I guess you could Client RPC loop to all controllers except the one the name is for.
yea I want players to see when a new player joins
Would likely break for new game, but any player who joins after 2+ seconds would be seen by everyone already connected.
oh that is interesting, I didnt know I could loop through all the controllers on the server
how can I do that? using c++
ah you mean, on the GameMode::PostLogin, store the Playercontroller on a list/map of a sort?
UE5
ah wait now that I think about it GetAllActorsOfClass function might work I guess ๐ค
Nah. Sec
for now delaying this multicast with a timer fixes my issue but I'm trying look for a cleaner solution, would be nice if unreal had some sort of event that could tell me when a client is "ready" (has been replicated) so I dont send RPCs too soon
for (APlayerState* PlayerState : GameState.Get()->PlayerArray)
{
APlayerController* LoopController = PlayerState ? Cast<APlayerController>(PlayerState->GetOwner()) : nullptr;
if (IsValid(LoopController))
{
LoopController->MyClientRPC();
}
}
Replace APlayerController classes with your controller type that has the RPC.
And you can add a != check for the one you don't want to RPC
ahh I see GameState holds a player array
You can always access every player's Pawn, Controller or PlayerState through that. PlayerState's Owner is the associated controller, and Playerstate has a PawnPrivate property to their connected pawn.
I haven't gotten that far yet as to create my own GameState class, still in the early stages, but will get to it soon
You don't need to. It's default framework.
Just need the controller with the RPC, everything else is already in place.
yea I know theres a default instance of it but I will need to create one eventually too since I need to store some stuff specific to my game's state, but good to know that regardless
about this, do you know if theres some event that will tell me when the client has been replicated? it would be useful also for other stuff not related to this issue
would this do it? https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/AActor/PostNetInit/
Always called immediately after spawning and reading in replicated properties
That I'm not sure on. I've never had a case where I had to care about that. ๐
I see, I'm gonna give it a try and see whats called first, this or beginPlay thanks for the help anyway ๐
The first place it's safe to call RPCs on PlayerController is OnPostLogin
If that was your question
Client has been replicated
That's not a meaningful statement
Actor has been replicated to client
That's the one
BeginPlay SwitchHasAuthority Remote Pin
I am calling some RPCs there already but not this one, this one when the player character spawns on the server( when that character's beginPlay is called)
yea when the actor has been replicated to client
Yeah pretty much BeginPlay but using that authority macro with the remote pin
hmm but that still will get called during beginPlay, no?
If you have a reference to that spawned actor where it's replicated then you can have it as an OnRep
BeginPlay is called on both server and client
yea I know but only the server knows the player's nicknames
so the server needs to send it to players
It doesn't get called on client without it being replicated
Nickname is something that would be stored in the PlayerState
unless I delay it with a timer instead of doing it immediately on BeginPlay
And would be replicated
As I said you know an actor has replicated to a client using the two ways I already mentioned
I thought about that but I think replicating something that would never change (like the nickname) may not be the best thing to do
Whatever you are describing is being something particular to your setup
I need to know from the server, when the client has been fully replicated
during BeginPlay seems to be too soon
It does actually. What If a new player joins late?
so I was wondering if theres another event after that
RPCs aren't stateful
Also that replicates like one time
As long as it's not changing it won't be replicating
Again you're saying statement that doesn't make any sense. A client isn't an object. Objects replicate. Clients don't
Yeah that makes sense
Correct
What you're describing is a classic problem where its solution is a replicated property stored in the PlayerState
yea I think you're right
I have a vague memory that there is a system in place for this already.
Sec. Testing some stuff with an overridden character component and I'll see if I can't find it.
I've noticed the playercontroller has a GetName() and SetName() functions if thats what you mean, but I haven't had any success overriding those values
This was still for the introduction stuff, right?
@clear island Ah. I thought I remembered that right. APlayerState has a playername. The Onrep for that calls HandleWelcomeMessage(). HandleWelcomeMessage broadcasts a localized Text along with the playerstate in question. Which can be bound to things like chatboxes, or HUD class for popups, etc.
ahh I see, that might just be what I need then
This all basically starts at AGameModeBase InitNewPlayer, which calls ChangeName, Which calls SetPlayerName on the PlayerState. You could easily override InitNewPlayer, and copy the rest but leave that ChangeName line out until your client sends their name and call ChangeName then. I think it'll work about the same.
interesting, I'm gonna look into it, thanks!
When using Clientside CMC movement, it seems Pawn->GetVelocity(); is incorrect on the server even though it's moving at the correct speed
Is there a way to retrieve the correct velocity that the client is actually at?
It's about 3x less than it should be on the server so it's quite a significant difference
I might do a multiplayer gamejam but I haven't done anything in mutiplayer with UE, would that be time consuming?
there isn't much gameplay it in
guess it would have to be peer to peer
There is no p2p in Unreal. The most close configuration to that is called listen-server
And yes this isn't going to be a 1+1=2
It takes time to get your head around Unreal's networking
Here's the starter pack: #multiplayer message
yes
I mean go for it
but it'll be 5x harder than you think
anyone using playfab for backend have a clue on how to reduce stacks from online inventory properly? using ConsumeItem is limited to just 1 item instance so it would stack up a lot of api calls
guessing I can't have it done in a few days? lol What I want to do is have one player place objects together, then the other player would have to do something to those objects.
you can do it in a few days if you drink a couple of energy drinks on the way and listen to some nightcore songs on 2x speed
If you think of an idea you could whip up in an hour, you could prolly do it MP. If you already knew how the MP works, it'd be a lot easier.
are all PlayerStates and their Pawns() available in all clients?
I understand some of it from doing a multiplayer tut a while back, really just duplicating code and making everything replicate lol
Question: When I try and connect over the internet it doesn't work but it does work on my LAN, using Epic. I've tested it a few ways. How do I trouble shoot this? I've trying checking LAN on off on both join/create session.
Disregarding relevency yeah
By default: PlayerStates are always relevant, pawns are not
Also there are other cases where it's not
It's not only relevancy
I mean from inside a PlayerState I can do: GetPawn(), is that pawn available even for simulated proxies on the client?
Could be it taking time to replicate PlayerState at start
It's not NOT availible, but it could be on the other side of the world and thus not in relevency range
What are you trying to do?
Yes, unless the pawn is destroyed or not relevant
I see
not doing anything in specific at the moment, just trying to plan my next steps
I need to make an inventory for my multiplayer game, how would I do that ? Should I follow any tutorial about inventories ? What should I replicate and what should I not replicate ? Any good advice about how to do it ? I need to go for a Minecraft Like inventory.
Use this channel search. You should be seeing too many examples, tips, ideas, etc.
Also don't follow tuts, YT ones especially
I watched alot of them and everyone of them felt weird to me and looked wrong to me the way they do it and also most of them aren't the type of inventories I'm looking for. Most of them make RPG inventories style with some slots being specific to some objects (like potions, weapons,...) and most of them didn't have a hotbar
if i have a run on server event are all events triggered from that event downstream server only as well ?
What should I type in the search bar, isn't there any other resource teaching how to do an inventory system compatible with multiplayer ?
All of my inventories are just arrays really.
Are you sure?
All a standard "slot based" inventory is, is usually a replicated array.
The multiplayer aspect of it is only just a matter of handling how the client interacts with the server's copy of the array without letting the client tell the server what is in any particular slot.
Eg. You don't let the client say "I am moving a Ultra Rare Powerful Item in slot 1 to slot 2" but instead just tell the server "Move the item that is in slot 1 to slot 2".
Start from this @vagrant grail , build up
like should all inventories (of all players) be replicated to all players ? Like I think players will be able to cheat if they can see what each person has in its inventory
Only replicate what is needed.
If they get executed then yes
No reason for player B to know about Player A's inventory if they're not interacting with it.
That's too vague for me ๐ฆ
Do people need to see everyone's inventory all the time?
How is it too vague? If player B is not interacting with player A's inventory, should they still get the data sent to them?
Nope
There you go. Then it is not needed.
i mean unless they can trade, should they ever interact with one anothers inventories?
Often times, I just replicate the inventory to the owner.
More than likely not. I'd have a third container to handle the trades where players present what they want to the other player.
There will be a way to trade stuff in a place but it will be through a graphic interface with slots and both sides need to confirm the trade after putting the items
ye or you can drop-trade if you have droppable items
You can't change replication condition at runtime anyways
but people could throw items from their inventory to the ground like in Minecraft
and if another player goes on top of it he gets it
Should the inventory be its own actor that I add to players or I can do that directly on the BP_Character ?
Do a component. That way you can add it to other things as well.... Like storage chests.
Ok it seems like it's a thing. I remember seeing this in this past, had to look it up: RESET_REPLIFETIME_CONDITION ๐
Though I won't change it
Could someone give me a first step to laucnh my self because I'm stuck on what to start with. Like if I do the UI first is it a good step ?
I would have a basic UI just for testing and focus on getting the prototype done
This is my advice, and ah a note too
so about this, I've been doing some testing and it seems when I do GetPawn() inside the PlayerState of simulated proxy, it will return null unlesss I'm doing it on the first player that joined the server, in that case its not null for some reason
and it is relevant btw (both players are right next to each other)
so the conclusion i reached is that GetPawn() inside a PlayerState of a simulated proxy can return null at times, even if that proxy is relevant
ok, so on GameMode::PostLogin I'm getting my player nickname and storing it inside the PlayerController
then, on my Character (Actor) I'm polling during tick for when the playerState becomes available on the server
that is on the server, you can see I'm getting the nickanem from my playercontroller and storing it on the PlayerState Nickname variable
that variable is replicated
it never enters that SetNameTagText block of the code
keeps saying its null for some reason
but only for the second player
for the first player it works just fine
I'm also using a dedicated server btw, if that matters
so basically my process is:
- open server
- open game client1 and join server
- open game client2 and join server
- client1 sees client client2's nickname
- client2 does not see client1 nickname
Okay that's normal
You are trying to get the pawn on client which gets set when APawn::OnRep_PlayerState gets called. What if PlayerState hasn't replicated for that pawn @clear island
You are doing it too early so it hasn't been replicated yet
I thought about that but then I tried adding a 3 second delay to that last line CharPlayerState->Nickname = PlayerController->PlayerName; but the issue still happens
I used a timer
You shouldn't be doing delays anyways
yea it was just to test
That's not how you solve it
Take this and see how you're going to fix it. I don't see anything particular about your setup. It's literally a game with OnReps
what I find strange is that the PlayerState itself is not null, but the Pawn is
I dont understand how such a thing could be possible, PlayerState is related to the pawn itself as I understand so I dont get it
I'm not using OnRep_PlayerState btw
that poll I'm doing is during tick
on the server
such as: when its available on the server I set the replicated "Nickname" property because its the server that has that information
I wouldn't even have a NickName on PlayerController
Would have it only on PlayerState
the only reason I have it on PlayerController is because that is what I get in GameMode::InitNewPlayer
the playerState itself sometimes is null during that event
so I chose to store it on the PlayerController
and then tried to pass it on to the playerState with that poll
I dont think I can use OnRep_PlayerState because that is called on the client and the client doesnt have the name of the player that joined
Would probably have as part of a LocalPlayer subsystem. But yeah that should do the trick too
to give more context, what I'm trying to do is just some nametags above players' heads
Ok then why you're doing it in Character?
Why not PlayerController?
the nametag widget is part of the character
There's where PlayerState gets spawned on server
Good. There's a property already in PlayerState called PlayerName which is replicated and all.
Inside Character I would wait till OnRep_PlayerState is called, and in there I would pull that name and set it as the name for the nametag
As easy as that
yea tried that too ๐
its the same issue though
It's not the same issue
during On_RepPlayerName I have to get the pawn too
and at that point, its null again
You are literally using all classes to get something really simple done
Don't overcomplicate
Again why do you need the pawn?
well 2 classes atleast I need which is my character (which has the widget) and the PlayerController which has the name I received in GameMode::InitNewPlayer
because the widget is attached to the pawn
Ok then do it inside the pawn
You see that there is no event that guarantee you the pawn is there
Why are you determined you wanna make it work that way
Plan B
actually I tried to using just the pawn first, but I had some issues too a few days ago, but tbh I dont even remember what those were, so I guess I'm going to try going that route again and see what happens
meh, still no luck
I tried this on the Pawn
then on the server as soon as I have the player controller:
this sets the replicated Nickname property which is inside the pawn
then on the client:
there's something triggering about On_RepNickname rather than OnRep_Nickname
also the playerstate is not 1:1 with the character
not too worried about naming at this point ๐
it is with the controller, in fact the controller owns the player state
hmm I see
also you can't guarantee replication order of actors
the character/pawn does not own the playerstate
you can possess different pawns during the course of a multiplayer match
You don't need to implement subobject replication for components, this is done for you
So the character part is redundant I assume?
MP question : Is it better to possess a vehicle pawn or have your character control it without possessing it?
so I finally achieved my goal doing it all from the pawn only with the code I posted above, and I now notice where it was failing
this variable was null, apparently this UWidgetComponent::GetUserWidgetObject() function returns null during the first few seconds on the simulated proxies for some reason
the overheadwidget variable itself was not null but the userwidgetobject returned by that function was
need to poll for it
I already knew about playerstate, gamestate being null for the first few seconds but this one was new to me
Possess it. Also you can't add movement input unless you are the owner.
yeah but what if i want to shoot while im driving? all the ammo info / weapons is stored in my player inventory.
if i possess it i cant do any of that
When you want to shoot while driving, un possess the vehicle and re possess your character and then you can have a shooting state in the server which will move the vehicle in the last velocity direction before un possessing.
Well technically you can keep the character possessed all time and do vehicle movement through rpc to server but you might seem some lag in that case.
Or a better way if you want to do turns while shooting is, posses the character when shooting and only during that duration, you can control vehicle through server rpcs, minimizing the lag times.
in gta online the player character never actually possesses the vehicles, and have all the freedom to shoot or throw items from their inventory, i want it to be like that
.
as long as your vehicle movement component is not tightly coupled with the PlayerController
all you need to do is SetOwner of the vehicle to get RPCs to work
and push the vehicle's input component on the PC's input stack
and how would i know if im doing the RPC's correctly or not
you don't have "No owning connection for..." warning spam in your output log
only problem with above approach is that engine has a bug with input masking
and i think it affects EnhancedInput as well as old input system
basically, if your first component on stack has something bound to say W, and lower priority component has Shift+W
higher priority IC consumes the Shift+W input and lower priority one doesn't work then
it is just a few lines of code to fix the engine there though
@worthy knot
@chrome bay Just re-read your article on OnRep weapon firing counters. Just curious if you were designing a basic replicated weapon today, is it fine to do stuff like this (muzzle flash / fire anim) with unreliable Multicast RPCs rather than OnRep vars?
Reason being is that in general OnRep stuff seems to be stateful
Whereas Multicast RPCs are nicely one shot and transient
Or is the benefit that you don't want loads of multicast RPCs being sent for fast firing weapons, rather the latest OnRep value which will only trigger the FX once?
arent multicast rpcs super costly?
I'm not sure about super costly, in what way? Bandwidth?
I always thought of rpcs as top priority messages sent across, is it really necessary to use them for stuff like visuals?
Oh I see, I haven't used that yet. I guess I'll have to look into it
damn doctor, i need to know more about all this
The burst method is stateful by design, because third-party clients in my case need to know whether the weapon is still firing when the receive burst info. This is so they can keep ticking the firing simulation and avoid stuttering/jitter by getting multicasts and/or property updates at variable times. Whether a shot was fired at all, and whether it's still firing is packed into the same property. If you do this with a multicast, you can't guarantee that the "stop" fire event will reach them.
Unreliable Multicasts go down the same network path as property updates btw, so they too are prioritised, respect net update frequency etc - but the point here is the burst counter is replicating both a state and an "event".
Automatic/high ROF weapons for instance will keep ticking the firing sim so long as bFiring is still true, and will trigger at least one sim if the burst increments once.
That's not clear in the article though, I should add that
Also, sending unreliable's means you can potentially fill the buffer up with RPC's, instead of just a single property update. Property updates are gathered at the end of the network frame, whereas RPC's are dumped into the buffer when you call them. You could throttle other properties/RPC's by doing this
how should multiplayer cooldowns be done? if theres a low cd on an ability, potentially there could be huge dps variance because of lag
You can always have the client request to re-use the ability while it's in cooldown.
I believe WoW had a kind of "do this thing next" if it was used close enough to the end of the current action / cooldown wearing off.
wow uses a queueing system
but its fairly complex
any client side solutions are hackable
I haven't played it in 10 years Shrug
One would assume so?
Sounds like the components are not replicating their activated status.
If they were replicating their status, they'd be spinning and moving properly!
You might try destroying the actor and creating a new projectile, as if the bat was actually a gun that destroyed itself when it fired. But that seems overkill.
Iโm doing something similar with my projectiles. I have a client side only โfakeโ projectile that spawns and triggers sfx and vxf while waiting on the server to spawn the real projectile. This reduces the feeling of lag for the shooter, but Iโm now dealing with double sound because of the multicast firing projectile effect meant for other clients is also happening for the shooter.
Pass the shooter with the multicast delegate and have it ignore itself?
I managed to enable Owner No See and it works for the mesh but canโt get the last part working so I donโt hear the sound
So the shooter actor? Controller?
Maybe just pass the net id of the shooter?
Pass the character reference
It will be converted to a netid automatically and converted back on the other end.
Or the Instigator reference, I suppose.
You can pass any replicated object to an rpc and it will work fine.
I always thought it would be this huge character object that would eat up a ton of bandwidth
If it was replicated directly, that is. Subobjects that aren't components, probably not.
...what have you been doing so far?
You're just passing an ID that gets converted to a pointer or something. It's tiny.
If I text you my address, I don't actually send you my entire house. I just tell you how to find it.
Yea I understand how that compresses things but I didnโt realize that was happening in the first place. Makes sense now though.
If you don't know that, though, Adriel, it makes sense to think that the entire object is sent, like it is with structs.
Is there a way to disable the client to join the dedicated server when testing in editor? Working on login system and dont want to waste time on compiling
Is there a collective name for classes that client "owns" like PlayerState, PlayerController, APawn?
Need it for a function I'm writing so it's not long as hell
Not really.
Turn off auto connect to server
But you're better off just launching
shidd
you can make bat files to launch a client and server
Maybe ClientAutonomousActors?
Sounds good! ๐
seems that this option was removed in UE5, cant find it in editor preferences
Okay this is a bit weird. I run a function on the server to spawn an actor (with an ASC). in the same function i set a gameplay tag on the actor. Now the weird part. If i use AddReplicatedLooseGameplayTag(GameplayTag) The tag only activates on the client simulated proxy. But if i use AddLooseGameplayTag(GameplayTag) it only shows on the servers actor instance. (that does make sens since its not replicated) but why does AddReplicatedLooseGameplayTag only applies to the client and not the server?
hey guys, im having a bit of an issue with a shot registering twice on the clients and only once on the server(which is what is suposed to be happening in the clients)
what i am doing is basicly a raycast, and if it hits the mob i subtract HP from the mob
the HP variable is replicated
My MP experience is quite limited. but did you try to only run the HP substraction on the server?
it also only does this weird behaviour the first time the mob is hit
that would be my first guess too but im doing something similar with characters and it works fine
sure
AProjectArenaEnemy* enemy = Cast<AProjectArenaEnemy>(results.Actor);
if(enemy)
{
enemy->HP -= damage;
BulletOwner->hitNotify = true;
}
else//if its not an enemy or a player than its the world
{
if (hitDecal)
{
FRotator rotator = FRotationMatrix::MakeFromZ(results.ImpactNormal).Rotator();
GetWorld()->SpawnActor<AActor>(hitDecal, results.Location, rotator);
UE_LOG(LogTemp, Warning, TEXT("decal spawned"));
}
}
}```
so i do a raycast and it checks if the resulting actor is a anemy
and i just subtract the hp
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AProjectArenaEnemy, HP);
}```
this is just the replicated var
its counted twice on the first hit in the clients but its fine in the server
This doesn't tell me much
What calls this stuff
Get me into the whole picture
i spawn an actor which has the raycast
the actor spawns, raycasts, then dies
do u want the spawn code or the whole raycast code?
I want all the code since the moment you shoot the shot to the moment you apply that damage/health decrease
I want to see RPCs
Functions
Authority checks
gimme a sec let me setup a pastebin
Provide people with the full context so they can help you. Else you're just shrugging at this server and we're too
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ok so this is the character that shoots the projectile, i only copied the relevant parts
the whole "shoot" chain
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
this is the hitscan bullet
any ideas?
it was an authority thing like @pliant moss said
i had missed
Little tip, directly setting things like health leave you open to refactoring code later on. You should use setters, then you can respond to events and check inputs and the like.
Your SetHealth function could check if it's enough for the player to die and kill them, for instance.
isnt this going to run on both the server and the client? BulletOwner->hitNotify = true;
i know, its just testing for now, on the characters i have a proper "receivedamage" function
Alrighty! ๐
i think so, but i left it that way in case theres lag in the network so that the player gets the hit confirmation regardless
from a game design perspective it feels better
Yeah, and i forgot the word for it but the server needs to correct the client if the client is "wrong". there is built in functionality for that in the Character i think (Prediction is called i think)
Ok so you are doing this inside a tick function. Do you know it's executed on both server and client?
I couldn't tell where you're doing it because the code in the second file looks weird
Your best gamble here is literally to debug and see where it's breaking
i already fixed the issue, it should be executed in both places but i got a authority check so it only executes in the server, i had it in begin play i think but i was having some issues that i cant remember and switched it to tick
with a gate
and the issues got fixed, now im just being lazy and i dont want to move/search to/for a better function
does player remain remain alive when open new level? or it reset?
Pawns gets destroyed and recreated upon traveling
i have main menu game mode, where player select character before joining server. when game starts, it open new level. but i want to get variable values from old level
so game instance?
because it is multiplayer
If I had my article done by this moment...sigh
That's like one way
You've got PlayerState with a function called CopyProperties
You can use programming subsystems
i have two game modes. one game mode is for main menu, and other is for gameplay
Though this only works in seamless travel
but player state is same in both game modes
so when i again open new level with different game mode, does player state reset?
It doesn't have to be same. Shared variables can be in a parent PlayerState where two different PlayerStates inherit from
Almost everything does by default
Upon seamless and non seamless traveling
Though you have a very short period of time where you can copy properties from the old instance of the player state to the new one
Same goes for PlayerController. OnSwapPlayerControllers
So my TLDR is this
If you are seamless traveling: use CopyProperties inside PlayerState
If you are hard traveling: use GameInstance/Subsystems/SaveGames
You could just have sub-levels right? Or streaming levels or whatever
Our game is procedural so we don't do any loading ever beyond initial startup
Can't you just have your pawn etc in the persistent level then swap out levels under it?
Yeah that could work too if you got sublevels
you can just not spawn the Pawn until your spawnpoints are in place too
player is possessed but not moving
this is only happened when i open this map from main menu map by selecting map
but when i open this map manually in editor and run game, input works just fine
what could be problem?
this is how i am opening this map
game mode is also set correctly
btw does this mean I can persist same reference of pawn to the destination level: #multiplayer message ?
I thought this function is used to persist client-only actors as it's called on client 
great i already fixed using this.
Sometimes answers are one search away
Hi, I got a problem with Multicasts being ignored by clients after the first time
I have a multicast that's fired when a character is possessed by a controller (in the ACharacter::PossessedBy method), which happens after they spawn, the multicast is responsible for giving them the correct material, depending on their team ID (stored in playerstate)
This works fine in round one, but from round two and onwards, when new characters are spawned using the same logic, the multicast is executed on the listenserver, but not on the connected clients. So on the listen server all characters have the correct color, but on the clients they all have the same, default color
So the multicast executes normally in the first round, but after that the clients never receive it
Yeah I saw this when I looked through this chat, and it seems useful for late joining, but in my case all playercontrollers are in the session when it happens, I'm not switching maps, controllers, or anything
The most confusing thing is that it consistently works the very first time I spawn characters and send the multicast. it only stops working after that.
Even if you don't allow late joining, multicasts were not designed for this
Whatever you're doing is stateful and that needs replication
I suppose you're right, I'll see what I can do
Also you are calling it early on which there is a very high possibility where it could not get executed. The first point where you can get RPCs to work reliably is PostLogin
Though at that point the pawn should be possessed and all, still I wouldn't take the risk
Why even RPC this? Why not use an integer repnotify to determine which color to set each player?
Seems like exactly what you'd use a repnotify for
You're right for sure, frankly it's been written like that for a few months and always worked, which is why noone in our team touched it
Only recently these Multicast calls started behaving like this, and now here I am trying to clean all this up
@pale hazel Definitely switch over to repnotify for anything that has to be called when relevancy becomes apparent
I will and see if that works out, thanks
How am I supposed to be changing levels in multiplayer? I have a lobby and a destination map. Just using Open Level disconnects everyone. I see stuff on ServerTravel but I don't know if that is the solution and I am having trouble figuring out how to use it
seamless travel
ExecuteConsoleCommand function and Command parameter be ServerTravel <MapName>
Can only be called from server
Should I do that with seamless travel or without?
Either way all clients will follow server. Though the preferred way to travel is seamless
do I need ?listen as part of the command?
Nope. That only if you want to make a player host a map, so he's a listen server
seems like clients just stay in the lobby, any idea why that could be?
My wild guess as I don't see code: You are calling ServerTravel from client
Oh shit
This is your lucky day: #multiplayer message
You can't call server RPCs in actors not owned by client, i.e GameState
Read that compendium fast
that link doesnt work
@thin stratus help!!! Your website is down 
its been down for awhile
Multiplayer support is back
otherwise I would be using it lol
Always download. There has been rumors that the internet is going to be down for a while soon

For example I have Laura's blog downloaded for offline use
Just in case I wake up and not find it
well at least I have one now
I was using GameState so that all players could easily see which maps were selected, so I thought I could load a map out of it seeing as it was the server
guess I'll move that into the gamemode
Well if you want some shared info placeholder that isn't specific to a player that's almost GameState
GameMode won't let you do RPCs too
then how am I supposed to load a map as the server, lol?
I just need the server to take clients with it
Literally make sure you are on server and do that ServerTravel
In my Character class
Can be either in Character, PlayerController
Doesn't really matter
This is the correct version
I don't know what triggers a server travel in your case. But in my case it's a key press which is client side generally, so I RPC to server
its just a UI for me
Ok that's client side too
I am confused as to why my other RPCs work though. Things like map previews do seem to update correctly for clients. I was routing those through GameState too
You need to let client side controller which is the owner of your UMG that you clicked that UI button so it triggers an RPC inside the PlayerController which does the servertravel
They just don't
You were faked into thinking they do

I have a multicast in the gamestate that was clearly working
That works
what can the gamestate do?
"too" here was a bit misleading. It's still correct though
It's written in that compendium
So sorry to interject; I have what I hope is a quick question.
I created a multiplayer VR game in JS, using websockets, and it was insane, and I never want to do that again, lol.
I'm wondering what the easiest possible way to get started making a multiplayer situation in ue5 is? (with blueprints)
Is it to just literally work through the docs?
Or, should I go the other way around and hack Lyra?
A lot of stuff. Server RPCs is just none of them
If you don't know UE, don't start with Lyra. Because the networking bible site is down currently ๐ญ, use this: #multiplayer message
Lyra is too complex when youโre starting out imo
I feel blessed everyone's using my copy now 
Thereโs other far more basic multiplayer templates out there
I've built 3 games in ue5
but the compendium lists Run on Server, Run on Owning Client, and Multicast as RPCs
You are telling me that isnt true
Ahh okay
but none of them are multiplayer.
so clearly I am misinterpreting the document
Okay cool. That link is still your new bible.
Just read this for RPCs honestly: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Yes
got it
What did I tell you as not true?
I just don't get it
what about the idea of buying a kind of pre-set up networking system on the marketplace; is that a way to just get up and go with it?
They are all RPCs. GameState can only call Multicast RPCs, not the other types
Pretty sure like everyone just does their own because it's so darn easy in UE
ok THAT is what I was wondering
oh ok
Well multiplayer is just replicating all the actors and properties that need to be replicated across the network for all clients to see properly. The server remains the authority and can be either a player (listen server), meaning someone โhosts a gameโ for others to connect to, OR you use a dedicated (headless) server which is just a terminal running somewhere on Amazon server or something.
that's cool to know
not sure why you couldnt just say so lol
GameMode can't call any as it's not replicated
There are some stuff that makes using the subsystems easier, yes
that makes sense too
alright, I guess I'll use the compendium and give it a shot, and if I start crying I'll come back lol
you will cry
๐ฆ
the nature of multiplayer is such
This video is also awesome btw: https://www.youtube.com/watch?v=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...
the blueprints arent actually complicated, but the concepts and little rules are what kills me
I mean that's just multiplayer in a nut shell, no one who knows what they are talking about ever said it was easy haha
Only if we could just get rid of latency and cheaters ๐
The biggest thing to understand when it comes to multiplayer is that thereโs only really one true instance of the game running and itโs the server who runs the real game. All the connected clients are simulating the game world locally and simulating the movement of other playerโs characters as the server sends out packets along the network.
Friggin' light speed is too slow, am I right? ๐
๐
Or dedicated servers actually being affordable for small teams / games. That would also be very cool.
So when youโre playing your favourite online game and thereโs lag spikes which cause your character to stutter and rubberband all over the place, whatโs happening is that the server and client disagree with where the current playerโs location is. Since the server is the authority (to prevent cheating) it issues a movement correction teleport and the result is what players usually call lag.
imo for cheaters
if your game is casual ive noticed that in games with a smaller playerbase they lack a cheater problem if theres a vote kick system in place
ive not seen a single cheater in quake live / diabotical / dirty bomb
If it's a PvP game and it gets big enough cheaters are almost always unavoidable.
or if thereโs a way to farm gold and then turn around a sell gold for real money, then youโll find lots of cheaters too
true, riots anti cheat is really great and ive still seen about 4 hackers
though i think all got banned
The one big game I'm aware of that is PvP and doesn't have cheats in the main concept of the game is Rocket League.
oh yeah, cant really do many traditional cheats in that game
In the regular game modes all you can do is find exploits in theory. But this obviously isn't viable for like any other game xD
It just happens to be nice for RL haha
They are, if your game design works with community servers. Think Valheim or GarrysMod or Minecraft
Well yes, but I was referring to hosting them your self.
Yeah that's pretty much a no go unless you got money.
how does one set values in the PlayerState?
Like you would set in any other class
basically I want clients to pick a color, and I dont know the order of events to actually get that choice over to the PlayerState
I assume it is owned by the server
BeginPlay of PlayerState is a good entry point
I have a separate issue where the server is getting a duplicate UI, I dont remember how I fixed that last time
I thought having a function that just constructs the ui on owning client would work but it doesnt
HUD is generally the class that constructs widgets
If you do things on Begin Play for the player controller, it executes on the server (the host!) and the client's end. So it's calling that function twice as your server is telling the client to run it and the client is also running begin play themselves.
You need to use HasAuthority or IsServer checks.
how can I force just the owning client to run it?
does it even need to be a replicated function then?
Probably not, unless you want the client to wait for data to be replicated before creating the UI.
ah good to know
Even then, perhaps not an RPC to do it.
Correct.
Well if this is player controller, you could probably do IsLocalPlayerController
Then only when true create the UI (if you only want it created on the local controller)
If I change game modes, do the player states stay the same?
no, but you can grab the Event CopyProperties to move over data
What do you mean by widget? UMG or 3d widget component?
Ok UMG is client only, so each player will have his own UMG widget
Though they can share the data and both widgets can pull from that data source
recreate or just update it on all clients
Yeah there should be some sort of interaction with the server. Clients can't talk to each other directly
Especially that local PlayerControllers don't know about each other
quick question about organization in code, how do you guys organize your code to account for delayed initialization of components? things like playerstate, gamestate, controller and sometimes widgets take a few seconds to fully initialize so I poll for it during tick, but once you get to a point where you have many of these variables that can have delayed initialization, things start getting quite messy,when polling for so many stuff, so I'm just curious how do you guys do it?
PostInitializeComponents
does that guarantee that playerstate, controller, gamestate and stuff will all be ready at that point?
Neverrrrrrrrr
It's per actor and it guarantees that components have been initialized
There is no global function that guarantees all those have been initialized
yea thats why I use poll during tick
but the code is growing out of control
with so many variables
so just wondering how other people do it
If you mean guarantee that it replicated then that's another story we had last night
Use OnReps
If you mean initialized on server then you have to know the order of actors creation
yea for clients, I'm relying onReps to detect that
there's things however that are initialized but not 100% ready sometimes
as I discovered last night, for instance UWidgetComponents will be initialized because I'm creating it on the constructor of my actor
but, it wont be ready
not immediately atleast
I'm not sure what ready means
when I do UWidgetComponent::GetUserWidgetObject()
that will return null for the first few seconds
so thats just another case where I'm polling for it during tick
whenever that returns something other than null, then I have a boolean that tells me bWidgetIsReady
its these delayed initializations I'm talking about
but after a while having to create a boolean for every case like that gets messy
it works, but its not very organized
I suppose theres no other way around it, not a big problem anyway
You literally said what your issue was. The component has to be there as I said, though that widget isn't
This function is what you need
This what calls it
Like literally it's a matter of discovering the source code
Also you never access a pointer without checking if it's null
The check and what you do on the result of that check are important, too.
Silently failing null checks are super bad.
my issue yesterday was that my nickname onrep was being called before my widget had been fully initialized (despite being created on the constructor), the widget itself was not nulltpr but when trying to get its userwidgetobejct with GetUserWidgetObject() it returned null for the first few seconds, but yea I wasn't aware of that update function, I think thats what I need, thanks
yea thats why it took me so long to find the issue, I was doing null checks so I never really crashed but I wasnt doing any logging on those checks
There's a good chance that this is what you need:
Play around with it. See what calls what
hmm yea, gonna have to try, I wonder if I can call it during the constructor
the fact thats its not called by default makes me think I cant
You don't call it. You should be able to bind a delegate to it so it's called when it gets executed
Anyone successfully used PlayerController->SetIgnoreMoveInput in multiplayer? When being run on the server it works for the host but not clients. I'm looking for a way to "freeze" a player in multiplayer, the only way I have found to work is by setting the movement mode on the character pawn's movement component Char->GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None); But I'm hoping there's a different way, this doesn't feel like the "correct" way of doing it to me.
That's the function I use when my players die, but there's no "StartMovement" function, at least not that I can find
How would I reverse it?
Yeah you're right it's only when players die. I would also probably try SetInputModeUIOnly
That's clientside though, you could cheat out of that. Not that cheating is a major concern for my game, but there's gotta be a serverside way of doing it.
I guess I'll stick with movement mode
I just don't get why SetIgnoreMoveInput doesn't work on the clients, or what the point of the MovementState is either. I also tried MovementState.bCanWalk = false, which didn't work.
CMC is a nightmare
Stick to the traditions
I mean if that's what everyone is doing then sure ๐
After declaring an RPC call, I noticed there are two ways of calling it. You can call the Funciton as the name is declared OR you can call the Function_Implementation().
Does calling the implementation mean that it only runs locally?
Correct
In the current module I'm writing, I'm using I think 2-3 actual nullptr if blocks, the rest are check(). I've traced down errors extremely quickly.
(in 280 odd files.)
I really need to get into the habit of using that more often
ok I still can't get my levels to load on both client and server
you'd think it would be simple but somehow this is hard
@rotund onyx Does your GameMode have bSeamlessTravel enabled?
no
Probably should do that
I need different gamemodes and player controllers though
no I mean like I dont want the gamemode to persist because I need to use a different one
same for player controllers
The GameMode wont persist if the level your moving to has a different one.
I just need clients to not disconnect
bSeamlessTravel specifically fixes that.
He literally told you how to do it
Keep in mind that SeamlessTravel does not work in the Editor.
I'm just reading the list of persisting actors from that compendium and trying to figure out how it works
It will anytime soon 
It probably forgets to mention thats only the case if they are the same type.
ah conveniently omitted
Even if they are the same type, for example GameMode. Runtime data won't persist
It persists to the transition level by default
Not destination
There are a lot of nuances to Seamless Travel.
Its difficult to understand until you understand it lol
Yeah it's really. I started writing a post like a month ago and I can't finish it xD
20min+ read time lol
Anyone able to explain why set actor rotation through a server->multicast only works when the server executes vs when the clients execute?
When the above code executes for the server, it rotates for everybody. When the code executes on the clients, they only rotate locally and neither the sever or other clients can see the rotation
Pretty much using the base ThirdPersonCharacter. I don't recall changing any CharacterMovement settings
I thought the same thing when I first implemented it. Both the GameMode and PlayerController will change to the new levelโs. The only thing that truly persists are widgets.
now thats an interesting tidbit, I guess I need to remove my widgets after loading levels for once
This might help https://youtu.be/h3A8qVb2VFk
Michael Prinke is back on Inside Unreal to talk to us about the ChunkDownloader! We'll walk you through how to do a basic setup of ChunkDownloader, and why you'd use it. We'll be covering how to break up assets into Pak files, how to integrate ChunkDownloader into your GameInstance, and how to test out the system on your local machine.
ANNOUNCE...
To call a server rpc from client, you must be owner of that actor.
Thanks. That happens every now and then. Shitty Wordpress...
To be fair, chunk loader is more for loading the pre-packaged game from a server if you have no distribution
That was mostly useful for Mobile
Where you couldn't (still can't?) upload big APK files
So you upload a small one and download the remaining chunks ingame.
I would love to know if you find a way to do this. So far I have found no way that doesn't require port forwarding. You will not be able to directly replicate assets, partly because UE won't do it natively, partly because they will be much too large to simply replicate by checking a box.
I just saw he mentioned about post client build.
My bad.
I do know steam lets you download and use workshop items at runtime, maybe that can be a way around the issue if you don't find a better way
I'm still trying to figure out my thing from earlier. I want players to pick some simple settings (just represented as strings in my project) before joining a multiplayer lobby, but I don't know how to get them loaded properly.
Someone said to store them in a config and load it after getting into the game but atm all it does is load it on everyone's playerstate and obviously I don't want that. The replication of this has gone totally over my head and I could use an example if anyone has got one
Should be back online, thanks for reporting!
Also the console have the following errors
MyStaticArray: illegal qualified name in member declaration
type cast: truncation from const int32* to int32
@unique sparrow Use a TArray<int32> ?
So I can use regular tarrays without changing their size right?
Well pushmodel doesnt support array replication anyway.
Really?
It treats it with normal replication rules
Isn't this macro for that use case only?
Unless its changed Im pretty sure its not supported.
It maybe WIP still ๐คท
Unless you can find an example in Engine Code i doubt its actually usable.
You may want to look at FastArrays
They don't maintain order ๐ฆ
Maybe I should try with Tarrays?
FastArrays are similar to what you want with PushModel
Yes but I need order to be maintained
Then your out of luck.
Should have worked though๐ค
๐คท
Never used it, didnt know it existed.
Doubtful it works.
Or there is something missing from the explanation of how to use it.
I guess that is the case
Use DOREPLIFETIME_WITH_PARAMS_FAST_STATIC_ARRAY
They should have updated the example though
Oh wait let me check
Ohh man.... I literally spent two hours why it won't work. Thanks a lot!!!
Is there a guaranteed order of replicating player states and game state to clients and player controllers and HUDs BeginPlay events on clients?
Hello, I Have A Problem, I Have An Attack Move Set Up Where Everytime You Attack Your Character Moves A Bit, Now Im NOt Sure If I Should Use Switch Has Authority Or Just Normally Replicate The Event, It iS Being Called Through The Anim Bp Btw here Is A Screenshot Of My Bp. Everytime I Test It Either Makes Both Players Move Or No One Will Move
No those are not guaranteed.
Adding impulse on the server would just be fine.
You might consider adding impulse for the autonomous player too in case you see lag, but you then also need to make sure that server replicated movement don't make it jitter due to lag. Anyways just doing that on server would be all fine though.
ok perfect thank you
Is there a way to delay/disable new connections to a dedicated server while changing map?
How do I get a controller from a gamemode? My kill counter variable is stored inside of a controller which I need to get to display it on the HUD
If it's on a client you want to get that information, it's not possible.
Game modes don't exist on clients.
You should store state information on the game state class.
Then you can use the game state's player array to get its players.
Its per play kill counter though
And, again, the states of players should be on their player state class.
If its on state wouldnt it be conjoined with all other players instead of being each players individual kill counter
It doesn't matter what it is. If you are in the game mode and are trying to feed information to a widget, this will fail in multiplayer.
It doesn't matter where the data is. It's the game mode that's the issue.
You can set values to be only relevant to their owners, so they will only be sent to the owning player.
Ok, how would I get a int variable from a controller within a function
You need to get a reference to the controller.
I believe UMG widgets have a "get owning pawn" or something.
Get that, get their controller and then cast it to your player controller and get the int.
I'm getting html Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetOwningPlayerPawn_ReturnValue". Node: Cast To BP_Controller_Mouse Graph: Get Kills Function: Get Kills Blueprint: WP_HUD
Are you doing on tick? It is invalid when the game just begins.
You can have a valid check
This is within my HUD get Kills function
Are you calling this function on tick?
Or bind?
Is that creating a widget every tick? Nvm
That might get executed even before the player properly initialized
Why you sending a client rpc? Just do in player controller begin play
locally
To clarify, begin play is called on both server and client, so you need to make sure it's only called on the owning client's side (or on the server if it's a listen server's local player controller)
Also do it in HUD begin play. No need of controller.
The kills is stored in the controller
Get controller reference from hud and pass
I mean cast the controller to yours and then pass the kills value by accessing from it.
How?
There is a variable in the hud called PlayerOwner, get it and cast it to your player controller and then you can access the kill from it.
Also HUD beginplay is only called on client so no need to do check for if the player is locally controlled.
It's not called on the server which is nice, that is, if you set the hudclass in the PC.
I think this works thanks
Is there a way to order OnReps?
I have 2 components on the same actor
On server I set value in comp A then value in comp B
but OnReps fire on client in wrong order
value on CompB then value on CompA
That might not be the best solution. What if the second attribute is armour which was increased, then until the rpc comes, the player will be fighting be taking damage at lower armour.
That is a little bad design I would say where one replicated variable depends on another replicated variable. You should avoid such cases.
Maybe in some cases it might make sense but I can't think of it out of the box right now.
well it's very hard to untangle, they were not designed to be related, they just got related AFTER we needed a specific edgecase fixed
and I would like to avoid costly refactoring just to fix a small issue
Are those values always set together on server?
not together, but in the same frame
Yes it's wacky. Was talking in general
Also you need to call an RPC for every connection
Which also sounds weird
If they are always set together. I mean if A value changes then B value is also changed on server, then you can have short delay on client to make sure you have updated values.
Yes
I was thinking of explicitly calling multicast in the CompA, since it will arrive before the OnRep
but IDK if late join replication won't be fucked as well
There's no guarantee that the updates to the values will be sent in the same frame or, indeed, anywhere near each other.
Yep that is still the case
It'd be fairly simple to set up a client-side state when the values are replicated. "ReadyToRecieve" "ReceivedA" "ReceivedB" or so.
And only trigger the functions you want when they are both done
Yes that is a solution. Before that I would suggest if you can somehow remove this dependency. Otherwise you can go with quick fixes.
Yes. That is a better solution.
It can have gotchas in cases where - First A & B set together, works fine, then only A is set & sometimes later B & A are set together & then B reaches first then you will have the old value of A.
So better remove the dependency.
sure, but like I said they are not really dependant in all cases
just in 1 edgecase
so tying them together completely would lead to more issues
If you can make sure that if value A changes, then value B also changes in server or vice versa, then do as Daekesh mentioned
hi there - it might be a long shot, as the problem is with the code i have not written and don't really understand network/replication but maybe:
in NetworkPredictionServiceRegistry, when GetDataStore hits this ensure
npEnsureMsgf(ModelDef::ID > 0, TEXT("ModelDef %s has invalid ID assigned. Could be missing NP_MODEL_REGISTER."), ModelDef::GetName());
is this something simple to fix or requires the intervention of a programmer who actually wrote it/understands that?
Why is the event AnyDamage not being triggered here when I use F?
Have you overridden TakeDamage function somewhere?
AnyDamage is not a virtual function that you are overridding & is called from TakeDamage itself which is known as ReceiveAnyDamage in c++.
If you have overridden TakeDamage, then make sure you call ReceiveAnyDamage to get it working
I deleted the anydamage event
You use C++?
Then I guess it should work unless you have overridden TakeDamage and not calling ReceiveAnyDamage.
Didn't saw you are calling on client. AnyDamage is only called on server
You need to apply damage on server
not on client
I have one more ApplyDamage node but thats it
You are calling here on input F, if you are playing as client it will only run on client and not server.
How would I force a node to execute from the server?
This is just a note that it should be called on server.
Custom server rpc event
call it from there
Hello, can somebody tell me what is wrong in here? Client runs "Open" but "Open" can't run "ClientOpen".
You don't own the door so you can't send rpc
I also tried to call rpc from here to character and then open by casting to door
Client still can't do anything
Show how you do that
Seems right, did you try debugger or print statement? Which event is it not reaching?
i'll try to detect whats wrong with print and i'll tell you
Just first make sure that custom event open door is called on client
Just add a print statement there and see if says client
fails here
it does
Ok then check along the path whatt doesn't
Although this shouldn't be handled by multicast. Opening door is a state and should be handled via OnReps
I suggest you after fixing this to work to get a better understanding of rpcs, shift the logic using RepNotify
Otherwise when a player gets relevant later or rejoins, He will still see the door as closed
What if you plan to extend the game? You will have to redo all stuff.
okay i get it
still if its called from clientside it fails here
but when serverside calls it it goes further
function that gets look at actor https://blueprintue.com/blueprint/ngsg2ob7/
input action calls it
it is
components too
only interaction comp is not
Can you show it somehow? I dont get what you mean
in a multiplayer game, where do you guys attach your ui/hud?
gamemdoe
Unless that's a multicast
That was not what I said
GameState is not client owned and you can RPC
Multicasts
You are wrong
Yes from server on GameState
You can also from client iirc but it will be local
You can be. That doesn't make it right
What? Client calls a server RPC so it executes on server
So i have to make a RepNotify boolean on interact set it to open/close (as server) and when it changes call open door in bp_door?
You can only call a Server RPC on something you own, which doesn't include the GameState
Multicast that is called on server-side GameState is executed on server and all connected clients
Multicasts can only ever be called by the Server
A client asking the server to call a multicast is a pretty obvious security issue too
Haha I didn't say this xD
Yes
You can call multicasts
I didn't say that
You can never multicast from a client anyway
Sounds like a semantics thing really. A client cannot call RPC's on a GameState. The Server can.
Yeah that's why I said iirc it will be local if called from client
A client can receive multicast RPC's from the GameState however. It will not receive Client RPCs
It's clear
What was the question again ๐
This how it all started
You see your problem
You don't say complete sentences
That can very much misleading
Ok that was next sentence xD
You can keep going back to the chat and trying to find me wrong
I think you both are getting things a bit mixed up, relax. You both got the same spirit lol.
Also I answer in this chat regularly. You are welcome to prove me wrong at any point
Both of you're are trying to say the same thing but are confusing each other haha
:/
Yes that's the only thing you're good at trash talking. I get to block you now so I make sure I don't see lame messages in this chat
You literally messaged me a few days ago from another account trying to understand my history, and now you're with new account trying to brag with your skills. Not on me boy
Danii
Just for the reference:
Guys.. Just stop please. If you don't like each other fine by me and the rest I assume, you both had the same idea but both didn't seem to understand each other's intentions. But this is just really unnecessary.
To be fair, you can call an rpc from anywhere on any system, it's what you call it on that matters (with respect to if it actaully runs)
It may run locally.
Most RPC/multicast related stuff still runs, but it gets executed locally yeah (although is likely not behaviour you want).
You absolutely can, @quiet rapids
Even multicasts can be called from client, though they will run locally. so my "iirc" was even correct
A multicast one on gamestate will run quite happily, locally.
A server one will do nothing, however, unless it's run... on the srever.
Yes they will.
The only things that are dropped entirely a single-cast RPCs called on the client to the server on an actor that isn't an autonomous proxy on that client.
That does not include a listen server calling a server rpc on a different client's actors.
Even though you might expect that to fail because "oh, not srever, we're the client at this point!!!111"
Listen Servers are weird honestly xD
Lets make everything a dedicated server, easy fix.
Make a good game, then get bought by Epic the moment you're going to go bankrupt and all problems are solved ๐
You can spool up a dedi server locally still to fake a listen server ๐
Hey guys I am still struggling to get my players' selected color to load when they join a server.
Currently I'm trying to get them to load their config when they join a server but it doesnt seem to work properly, because everyone only sees their chosen color on all other players.
How are you 1) sending this colour 2) storing this color 3) retrieving this color
I am trying to store it in the playerstate so it is easily accessed by everyone
I may have posted this in the wrong channel, would anyone know how to solve this local multiplayer spawning issue #blueprint message
the color in config I can represent in whatever way. Currently its just a text doc with a string
Why would you not use the config stuff?
Save it to an ini file?
So how are you sending the color to hte server when you join?
Just marking the value as config should store the value and read it back automatically.
In BP at least, you have to do an extra step to save in c++
honestly I havent even heard of that
I'm not suire what the default config is for games.
I'll worry about storing it later
But there will definitely be a way to do it
I know my text doc works because the color does load
That's fine.
it just loads on all players instead of just the owner
So how are you sending it to the server?
Nothing there sends info to a server
how should I do that?
how do I make sure only the owning client loads their file?
I dont want the server overriding it
Use the player controller
the begin play, don't use a timer
check if it's the local controller
Then run an 'execute on server' node
The parameter being your chosen colour and whatever else you want to send.
On the server end, set the value for colour (and whatever else) in the player state connected to the controller and make sure the variables are set to replicate
Your MP options should load once, at the start of the game instance, not every time you join a server
You can store them on yoru game instance (where you can set them as config variables) or a user settings class somewhere
I'll give it a shot, thanks
Hello, do somebody know why the child actors are not replicated here? This is how I spawn them.
Are you using child actor component?
There should be a pop-up when joining the server, "Are you using child actor components?" If you click yes, it just bans you.
You're probably spawning on client too, don't do that. Spawn a replicated actor on server
I wish we had a nice way to embed actors tho.
A prefab sort of thing
Modular stuff is a pain with the Actor/Component split.
