#multiplayer
1 messages Β· Page 155 of 1
I think gamestate is the answer
are we talking about the same thing? TMap
oh I see. Does marking it UPROPERTY + Replicated not work?
im using blueprint but replication option is disabled. I just read that i can eather fill the map after onrep or use a tarray instead
but i need to have the correct info before onrep...
I'm doing some reading about this, sounds like you can wrap the TMap in a struct and then replicate the struct - I think you need cpp for that though
oh... i already made the tmap into a struct but using the struct felt useless
i guess ill try that instead
Nah it'll complain too
You can't replicate TMaps
Unless you write custom net serialization and wrap them in a struct
so i need to use a tarray instead...?
Would be the easy solution yes
You can always replicate an array and convert to a map locally if needed
sounds confusing
In that case stick to an array ^^
Instead of wrapping tmap, create a FFastArraySerializer and add your own tmap type functionality imo
Blueprints
Prob a stupid question but when adding EOS OR STEAM , can you have both or do you have to create a build for each service?
You can't configure multiple online subsystems but only one. It's done in a specific manner in one of the ini files
so one build for steam and one for epic then?
I'm only here to say that learningn how to make multiplayer makes my head hurt
idk how to do any of that haha
is there a good way to replicate the characters YAW and PITCH ?
Hi all!
Has anyone worked with Edgegap before? https://edgegap.com/gaming/unreal
They partnered with EOS a couple of days ago. What are the pros and cons of this service?
The easiest way to launch & scale a multiplayer game with Unreal & EOS. Edgegap's automated game servers & orchestration level up your multiplayer.
has anyone benchmarked a "Shipping" dedicated linux server build vs a development build? I don't distribute the dedicated server so I have just been using a development build, but I was curious if that significantly hurts performance
Hey, can i multicast but only to those that satisfy some conditions?
The situation is there are 3 players, 2 players opening the same chest. Player 1 change the chest content and the chest widget on each player's PlayerController need to be updated. If i do Client RPC, only the player 1 get the update. If i do Multicast RPC, all 3 players get the update even though player 3 is not opening the chest.
So i need a way that only who is opening the chest get the update.
Maybe i should set the chest's revelancy to only who's opening it.
Just send individual RPCs to those PCs only
Dont use a Multicast
Multicast cannot send to specific connections, it sends to all.
But like the action that's changing the content come from player 1, so idk how to send the RPC to player 2
An operation that changes the contents of a Inventory should be managed by the Server
A Client can make a change locally, but it must be also sent to the Server to authoritatively make that change
At that point the Clients would be updated with the new state.
Including the Client that made the change
You want this, so that if the Client tried to cheat or made an invalid operation, they can be rolled back to the correct state as determined by the Server
yeah i change the content in the server, but Client RPC only send back to owner?
or i can have multiple owner?
Huh?
The Client would send an RPC to the Servers version of the Chest
The Chest would make the change on the Server
The Chest would then send an RPC down to any Client that has it open
Via their PlayerControllers
You would need to manage a list of the Players who have the Chest open
So you can make those RPCs
Well how else would you know whos got a Chest open?
is there a simple way to let players see a simplified version of stat net like in fortnite? I want to show them ping / packet loss / fps
For console command open + connection string, what function is it calling? And is there a command list for their respective functions in source? I kind of want to understand where the commands come from and call
Does EOS not support crossplay between PC and MacOS? I tried to search someplaces say it does some say it does not
Wait I see this is cross store support, soooo it does not support crossplay? MacXwindoes
When i myself tried it didn't work, windowsXwindwos works and mac does login normally and also create session it's just the WindwosXMac aren't working π€
After some debugging, when using open + map in in-game console(~) it looks like it calls SetClientTravel after going through a bunch of ConsoleCommand() and Exec() functions
Yeah pretty sure open + connection string is just a client travel.
Cause that's, despite ServerTravel, how this usually is used
If you can access EOS features on MacOS and you can auth with MacOS etc., then I think it's also supported.
Might be the magic button to allow crossplay in general?
Check #epic-online-services maybe?
help please, I still didn't manage to figure it out
full logs from both client and server will help people help you
Sure.
There is the log
this is the client logs right? send server too also let it run for 60 seconds after it starts showing sent 10 packets in last 10 seconds, it i think aborts automatically in 60sec and shows bunch of errors then too
i am no expert but people here might benifit from those logs to help you π
those are logs for both and waiting 60 s doesn't give much stuff beside repeating the latest line of the log I provided
Hey @toxic falcon those 60 sec failsafe specific to your plugin or are unreal's own feature?
hello i have a custom actor that a player can interact with the with F key. When that happens the custom actor needs to do a server rpc to do some server side logic. The problem is that the server rpc won't be processed because it doesn't have a valid connection. To fix this right now i only see 2 options:
- Use the player character as a proxy to do a server rpc that takes in the custom actor as a parameter to either set its owner to the player character so we can run server rpcs or to run the actual logic
- A bit more hacky approach is to override GetNetConnection on the custom actor and just return the first valid player controller
Obviously the first one is more correct, but doesn't seem very scalable if i have 30 different custom actors that i can interact (and need to execute server side logic) because i would need to make 30 server rpcs for each type on the player character. Is there any other option that is more scalable?
Hey there
what is the right way to setup the motion warping for replication
my game is based on dedicated servers
i tried to make it to run on server for the main logic and when call the add or update warp target node i do that on multi cast event
and the on server event for logic i call that in the attack combo multicast event
here is some screen shots
@fathom aspen thanks i'll look into it
@fathom aspen you can't send interface pointers on the server RPC right? so on the ServerInteract i need to pass an actor as parameter and get the interface on the server side right?
I'm not sure if you UHT allows you to pass function ptrs to RPCs, but yeah that was the intention, you pass an actor ptr, and it will figure out the right implementation of Interact that should be called
seems to be working thanks
Hi, I have a quick question, if the rotation is not replicated by default with Pawns, why the server rotation is replicated to clients (shouldn't it not replicate any rotation, neither the server one)?
i think you should replicate client movement to the server as well
can anyone suggest some tutorials on how to make a private session using steam advanced session ?
i found 2 tutorials with steam invites but didnt work , so any idea ?
ps : private either by using codes or steam invite system that works , thank you
It seems really confusing, the rotation through the Add Yaw Input seems to only work on local controller, shouldn't it on server rotate both tanks?
If I use Has Authority to add Yaw Input to both it only rotates the server pawn instead of both tanks
no , check this video , has the same concept , https://www.youtube.com/watch?v=gG_ggXUiB_Q
Hey guys, in today's video, I'm going to be showing you how to replicate sprinting for your online multiplayer game. This will replicate the movement, speed, and animations.
More Replication Videos: https://youtube.com/playlist?list=PLQN3U_-lMANOaPmzSGLDhyWzKzwgKDz9V
#Ue4 #UnrealEngine4 #Ue4Tutorial
____________________________________________...
The problem is that major of the youtube videos is that it talks about the replication through the CharacterMovement which handles a lot of things and automatically replicates the rotation which doesn't seem to be the case of the a "raw" pawn
but most likely u'll find vids regarding replication of rotation or any movement , take this for example
Support me on Patreon: https://www.patreon.com/KibibyteCompany
Make sure to join my Discord: https://discord.gg/UfYfuFAVae
Don't forget to check out my Unreal Engine marketplace products: https://www.unrealengine.com/marketplace/en-US/profile/BrokenArm+Studios
#unrealengine5 #ue5 #ue5tutorial
In this video I will teach you how to replicate t...
modify accodingly and see how it goes
I will try it, but I still want to understand why changing the Yaw rotation on the server doesn't change it's rotation on the server side
well i cannot pin point the issue without seeing and set up u have
I add yaw input to the tank controller every tick on server side
In this case on the server screen I would expect to both tanks to rotate, but only the server pawn rotates
There is any restriction to manipulate the other player controllers even from the server?
i dont think u have the right set up there , someone else might provide a better help but i think you should make a custom function put it to "run on server " n remove the "authority node " , then attach the function to the event tick
try and see , because im not sure
in the same way, while the stabbing animation I made works in the clients, the aim animation plays only in itself, do you know why?
Ok, I have a assumption, maybe the "Use Controller Rotation Pitch, Yaw and Roll" only works for the local controller
Since direct rotating with Set Actor Rotation works normally
Hi all. Have been bashing my head against trying to make a local multiplayer "Press X To Join" screen for days now and am having an issue where my second player controller is not receiving any input after being created with Create Local Player For Platform User (or just Create Local Player). I have tried replicating the solution mentioned here (https://forums.unrealengine.com/t/problem-with-enhanced-input-and-split-screen-on-ue-5-1/714667/13?). (add a delay to assigning the input mapping context
To be clear I am using 2 gamepads, not trying to use skip assigning gamepad to player 1. There are definitely 2 player controllers present in the outliner. When I press the submit button (face bottom) on gamepad 1 I see the print string "[Controller 0] Submit" so I know that's working. It doesn't matter which gamepad is assigned to which player, Either gamepad works for player controller 1 and neither work for player controller 2 (as well as checking the input works on hardware tester).
Does anybody know why this isn't working?
hey
im showing Floating damage text to all players, i want it to only show if the players character is within 1500 radious of "world location" really advice?
what's wrong with the current branch logic?
its getting the wrong actor location
though I would probably handle showing damage locally for ez mode
is this in character bp?
because u are running it on every instance of the character
yeah
exactly
dont use get player character 0
On your branch add extra check
and Is Locally controlled
if both are true then spawn damage text
well my brain might not work well atm
not sure what the end goal is, so test it first
if you wan to display player 1 attack player 3 as player 2, this probably won't work. I dunnoe
try to test with 3 players
1 listen server 2 clients
Hello guys
When players log in, I'm saving their name in a struct with two string arrays (team red and blue). What logic do I use to access and compare this information?
My intention is that the Red team doesn't cause damage to its own team, only to the opposing team, the Blue team
As I can't access the player controller from the client, I'm a bit lost on how to do this exactly
You would do damage on the server anyway
But I would suggest using an enum for the player's team
and putting it on the playerstate instead
that way it's accessible to everyone
I will try, thank you @solar stirrup π€
If anyone feel like it, I'd love a code review on my relatively simple itemcontainer component. Goal is to have it replicated properly AND securely to prevent cheating. FRancItemInstance contains just a GameplayTag ItemId, and int32 Quantity
https://pastebin.com/YpfQCypJ
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.
I created an Enum with blue team and red team and a new playerState. Then in gameMode, in OnPostLogin I call an **event **that is inside playerState, where I set the state of the Enum
However, when I instantiate a skill and try to access the client information (of the Enum), I can't, could anyone tell me why?
It fails exactly when casting to PS_MageState (which is the new PlayerState that I created)
Sorry for any stupid questions, it's my first multiplayer game
why would the other actor be a playerstate?
you're saying "Hey, if you just hit a playerstate, set this variable"
you won't ever hit a playerstate
you probably want to check if you hit a YourBasePawnClass and check the enum value of its corrosponding playerstate
or something to that effect
Hmmmm I understand! I'll try it here, thanks! @dark edge
hey everyone I joined the server for some online mulitplayer help. I am planning on making a small arena fighting game (8 player max) in unreal and I'm adding multiplayer using blueprint. Will there be any pit falls doing this? Will I need to learn C++ to have functioning multiplayer?
networked or local?
Networked
You can create an online multiplayer game Blueprints-only, yes; however, it's unlikely it'll be optimal. Been there, done that back in 2018. Wouldn't do it again.
A few points for you to consider:
- Blueprints alone is slower than C++. (More here: https://intaxwashere.github.io/blueprint-performance/)
- If going listen server, you're making one of your players the host. That is, you're outsourcing the duty of the server to their hardware. Because your code is BP only, by default, it's going to perform worse than a C++ solution - and this is a situation where you probably want the most out of it.
- Also if going listen server, the player hosting is virtually executing two processes in parallel: the entire rendering pipeline (to actually see and interact with the game), as well as server code. That is, if running on poor hardware, even a good C++ code won't guarantee good performance, much less BP code.
- Depending on your demands, you may need some custom code only achievable via C++. Fast Arrays, custom netgraph, etc.
yes you'll need C++, depending
a fighting game will need some fancy netcode
Civilization, not so much
It might be technically doable but it'll be aweful to live like that
To complement Adriel's answer; not only a fighting game, but most of real-time games.
The only Realβ’οΈ networked game I'd even consider doing in BP only is something turn based or otherwise not very high-paced. Civ, Rimworld, stuff like that.
For prototyping and having fun with friends, you probably can make it. For commercial purpsoes, today knowing what I know and after the frustrations I had, I wouldn't spend time and energy on it at all. Don't want to be the dreambreaker guy, but hey.
Where is a good place to start and will I need to make the project purely in C++ or can I do a mix between both?
there's no such thing as purely in C++
just start working on it, you'll figure it out
that's a BIG order, I can't think of much harder to do than a fighting game with networking
Just start with BP and you'll learn where the C++ fits in
Thanks for the help. I just want to make something that people can play with friends nothing fancy or too competitive.
I mean, "nothing fancy" and "too competitive" are quite vague.
And I'm saying this because you probably can go Blueprints-only for your project depending on how far you want to go. Are you going to sell it? Do you need anti-cheat? Is it going to be listen server or dedicated server? How stressful are your real-time needs?
I think Adriel is right - kick it off with Blueprints, but do it knowing that at some point you may need C++ and depending on how you wrote things, it may mean some overhauls/big refactors to make the port.
Is there something i need to do to foliage to get the removal of instances replicated to all?
I'm calling an interface on the FISM component via a server RPC and it's not able to replicate the removal of the foliage instance to all players
you would need a stable index of the ISM element
the index seems to be consistent on server and client from what I can tell.
Here is both client and server reporting the same index for the same foliage
Damage event here
And here's the logic on the FoliageInstancedStaticMeshComponent
So what's remove instance actually doing? You might see it do something unique for foliage
it's removing the instance only on the server. it's not being replicated to clients
let me clarify
if the server player damages the foliage, the instance removal doesn't replicate to any other client
if a client damages the foliage, the instance removal only works for that one client, and the server
other connected clients do not recieve the update
so it might be that the server doesn't see the need to send the damage event to clients
you may need a different RPC
or even a replicated value of all of the dead indices per thingy if you need persistence arguably
look up the docs for RPC rules, you probably need to change what it does whether you have authority before sending it out etc
I mean, it works for actors right off the bat
all googling is showing me is that foliage isntances aren't' correctly replicated and everyone has issues with this.
I have tried using a replicated variable OnRep to brute force it, but the engine still does not replicate the removal of the instance to other clients
not like that...
I think you want something besides these that stores the replicated information
AInstancedFoliageActor is not even replicated
it not being replicated is probably whats' causing this greif. but it's so tightly coupled with the foliage system.
that's fine, you can make your own seperate replicated stuff that's not part of this class
nothing is forcing you to make this exact thing replicated, you could add a component to the gamestate or whatever that tracks this crap
hmm. let me give that a shot
also late joiners etc will need something that tells them which indices are toast
or vice versa
(if they are a planned thing)
Satisfactory didn't have that working for so long...
yeah nope. no such luck
I don't mind storing the information of which i need to remove when a player joins, but I can't get it to properly remove the appropriate instances.
is everyone just using actors in place of actual foliage for interacatble foliage in unreal?
So when I try to use the "Get Owner" node and print it as a string it returns literally nothing if I'm a client. Is that supposed to happen?
On an actor not already owned by the client
Yes, that is supposed to happen if the owner is not replicated/unknown to the client.
Or not actually set.
Anyone know how UWorld::NotifyControlMessage() gets called for remote players joining? Can't seem to find the thing that calls it. I see that UControlChannel::ReceivedBunch() has a call to it, but it doesn't stop when I put a breakpoint there
Gotcha, thank you for the response! I appreciate the help
Thank you!
What are you trying to achieve?
Nothing, I was just curious
Just trying to trace back how things get called just to know
UPendingNetGame::SendInitialJoin() has NetControlMessage<NMT_Hello>::Send() but I'm not understanding how it gets the UWorld::NotifyControlMessage() called. I'm not seeing it bound to any delegates, but I may just not be looking in the right spots
why can't i connect to my dedicated server? I use open level and try to connect, but it doesnt actually connect or add anything to logs
So it seems UChannel::ReceivedSequencedBunch() is called for each channel of the netconnection (correct me if I'm wrong) and each call their respective ReceivedBunch().
The ControlChannel's ReceivedBunch() seems to call the World's NotifyControlMessage(), but I don't know why my breakpoint doesn't work in UControlChannel::ReceivedBunch() to confirm that
Hey guys, i am having this weird bug, basically i call a client RPC from the server, when the RPC go to the client it will create a timer to wait for PlayerController.
However when the timer is ticking, i am actually in the server..? How did i went back to server?
void UInventoryManager::BeginPlay()
{
Super::BeginPlay();
if (GetOwner()->HasAuthority())
{
// Create inventory on server
TryCreateStorage();
// Create widget for player, not AI
Client_WaitForController(InventoryStorage->GetDataStruct(),EquipmentStorage->GetDataStruct());
}
}
void UInventoryManager::Client_WaitForController_Implementation(FmStorageData InventoryStorageData, FmStorageData EquipmentStorageData)
{
FTimerHandle TimerHandle;
FTimerDelegate TimerDelegate;
TimerDelegate.BindUObject(this, &UInventoryManager::Timer_TryCreateStorageWidget, InventoryStorageData, EquipmentStorageData);
GetOwner()->GetWorldTimerManager().SetTimer(TimerHandle, TimerDelegate, 0.1f, true);
}
void UInventoryManager::Timer_TryCreateStorageWidget(FmStorageData InventoryStorageData, FmStorageData EquipmentStorageData) const
{
if (GetController())
{
if (GetController()->IsPlayerController())
{
if (GetQyPlayerController()->GetMainWidget())
{
OnAddStorageDelegate.Broadcast(InventoryStorageData);
OnAddStorageDelegate.Broadcast(EquipmentStorageData);
GetOwner()->GetWorldTimerManager().ClearAllTimersForObject(this);
}
}
else
{
GetOwner()->GetWorldTimerManager().ClearAllTimersForObject(this);
}
}
}
Hey guys, i am having this weird bug, basically i call a client RPC from the server, when the RPC go to the client it will create a timer to wait for PlayerController.
However when the timer is ticking, i am actually in the server..? How did i went back to server?
Shouldnt foliage actors be preplaced in the level and thus be in sync at gamestart for all clients/server?
Am i understanding you correctly that that is not the case?
No chance you forgot to add the client tag to the uproperty or you are playing as a listen server?
Try adding a
if (hasauthority) ue_log
in Client_waitforcontroller_implementation and see if that ever prints
it's the same
im playing as client, my server play worked so i am sure
i guess i could call RPC in timer but that's like a lot of RPC lul
//- RPC
UFUNCTION(Client, Reliable)
void Client_WaitForController(FmStorageData InventoryStorageData, FmStorageData EquipmentStorageData);
UFUNCTION()
void Timer_TryCreateStorageWidget(FmStorageData InventoryStorageData, FmStorageData EquipmentStorageData) const;
my function declaraton is also fine
I am new on multiplayer and trying to do some tries on host&play but I cant pull the WB variables -it gets blank- , in the last part 4st end the print gives 1:"Empty" and 2:"ValidWBRef". Where did I wrong? π€
hmm then how can I run an event in wb from client to Server easily? π¦
Through the owning player controller
An RPC in the owning controller
But...
Ur trying to replicate the lobby widget
Which doesnt really make sense
You want the clients to have their own, and replicate the current state of the players to their individual local lobby widgets
humm will be ok if I do it in PlayerState?
I mean If I go state from client and do them Run on Server and direct it to Wb back?
It is like, go to player state and change to client to server there and go back to Widget for Server and run some commands there?
you meaned this?
π€
Its a regular lobby right ?
Where a few players join pre game and can do some selection stuff ?
yess
Probably easiest to find a lobby tutorial really
tried to follow some videos but everybody use different ways so hard to get the right way for me lol
ok I will try somethings thanks
Server is the only one with authority to set replicated variables amd have them replicate
You should check out some of the pins in this channel
Cedrics multiplayer compendium for one
if i spawn a VFX in a RPC and set it to a Variable
how will that work will each client have their own one right or
is this wrong doing it like tthis ?
I have big problem in my online game. When I shoot I do everything locally except when bullet hit ground. There is almost half second delay between bullet hitting ground and dealing SERVER damage.
[/Script/Engine.Player]
ConfiguredInternetSpeed=2500000
ConfiguredLanSpeed=2500000
[/Script/Engine.GameNetworkManager]
TotalNetBandwidth=400000000
MaxDynamicBandwidth=4000000
MinDynamicBandwidth=1000000
["Netdriver"]
MaxClientRate=3800000
MaxInternetClientRate=3800000
NetServerMaxTickRate=32
What could cause this latency?
Or could it be because I use "Windows development server"?
Is testing server travel still unavailable in-editor?
I just tried and it crashed.
And if yes, how can I test it, do I have to make a build for it? Seems too messed up, because making a new build every time I have an error or need to make a little change, will take ages.
i am still trying to figure out what is the issue with the widget. this is my dilemma: call rpc from controller at begin play, to spawn characters, and after the pawn is possessed, i try to create the widget:
@stoic wing not the same controller and widget
Each player running their own instance
the problem is that the widget of the second player to join is also displayed on the server. so as soon as the 2nd player joins, the server widget switches to the widget of the joined player. why is that happening?
They don't live in the same world
Just to answer the initial question it's not the same controller and widget
In the server if there are 2 players there will be player controller 0 and player controller 1
Meanwhile in client machine they only have their own controller. Controller 0
in the widget i draw the render target of a scene capture component on the screen, but as soon as the 2nd player joins, the server widget displays the same render target as the 2nd player
So controller 0 in listen server will point to their own controller while the client machine controller 0 point to their own controller
i see
but then i really dont understand what's happening :/
What's the issue
It's hard to debug without having the project and multiplayer is not making it easier.
I would say if something doesn't behave the way u think it should. Just trace back and see which code should run on server and which should run on client
so. this is my character BP.
i use this pixel SSC (scene capture 2D) to render a low resolution render target and i use the widget to display this render on the screen
but as soon as a 2nd player joins, the render target of the server changes to the render target of the joined client
Seems like u r creating another scene capture then
U want to make sure that the piece of code runs once on each player maybe. I'm not sure what the goal is
This sound something that should be handled locally too
i can explain hopefully: the goal is a 3d pixelperfect camera. i snap the scene capture component on a grid to achieve pixelperfect camera, but then i move the rendertarget in a widget every frame, so it moves smoothly, not jumping by "pixelart pixel" size
yes i want to handle it locally but i am a bit confused
i can send the project files if u want to check it
My take is that it should be something done locally on each character when they join
If u created another render target in the server ( which u can check ) then that's Ur issue and u need to isolate the code
that is my goal but i dont know how to make sure it happens locallyy
i dont create the render target during the game, it is already in the content folder. is that an issue?
i call an rpc from client to spawn players on the server, it works
Yea don't know what does what. Really hard to debug from here
Good find tho, make sure to test thoroughly with 3 players if listen server
thank you for the help, i will keep testing it
bumping this
how can i check this?
Render target is just a comp
You can get all the players and check with get comp by class
not sure if this is what you meant . so i tried with 3 players. only the last player widget displays the correct player. and if i quit with the last player, then the "new" last player's widget starts to work properly
How can i make my flashlight aka the spotlight, only be visible to the owner of the flashlight?
so other players dont see it
Just don't replicate it
Enable/disable on the owning client only and make sure you don't replicate anything that would turn it back on
ok, and how can i make a different light that only other players see and not the owner?
How can I make sure that a client does not move on the server given a certain comparison? I have a state on a character (Sleeping or awake) and if the state is not awake it shouldn't be possible to move. I can just not call "AddMovementInput" if the character is on a state, but obviously this is client side only and that can't be trusted. Do I need to hook into some component code somewhere? Setting the movement mode doesn't seem to do anything
For some reason when sliding, client will go in the air while server will stay on the ground, bIsSliding, bIsCrouching & CurrentSlideForce is replicated
// NetMulticast, called from a Server function
void APlayerCharacter::HandleCrouch_Implementation()
{
if (bIsCrouching)
{
// Crouch
Crouch();
// Slide
if (bIsSliding)
{
// Add Forward Force
GetCharacterMovement()->Launch(CurrentSlideForce * GetActorForwardVector());
// Add Counterforce
CurrentSlideForce -= CounterSlideForce;
// Disable Movement
bCanMove = false;
bUseControllerRotationYaw = false;
}
}
else
{
// Uncrouch
UnCrouch();
// Unslide
bCanMove = true;
bUseControllerRotationYaw = true;
CurrentSlideForce = SlideForce;
}
}```
Hey guys im working on my NPC rotating towards player function, im using a timeline atm with RPC wich i got told is a bad way* any tips on how to do it ?
Coldsummer i talked to you before about it hence why i wrote it down so im dealing with it now *
Ok but how can i make the light not cast shadow on the mesh itself without turning of cast shadows for all lights?
Figured it out for any future searchers
As it turns out, it indeed is a bit more complicated then I initially believed
Replicating Foliage Instance Static Mesh Remove / Removal:
As a character, or character component:
- Perform trace to determine which instance requires damage (we just need location for now, not the index)
- In a server RPC spawn a new REPLICATED actor (likely the replacement actor)
As the newly spawned actor:
- When the replacement actor begins play, perform a sphere trace at the location of the original hit (small radius of 50 should suffice)
- Cast to FISMC (or your custom FISMC)
- Get the hit index and remove the instance
So they're not synced at all
Spawn a new replicated actor at some initial location determined by client -> locally trace for the correct index and remove it ...
I guess you can just remove the hit index from the initial client trace locally, and do the spawn actor for everyone else
That's a more concise way of putting it.
I was never able to get the initial client to remove the index themselves
It just wouldn't replicate to anyone else. I'm guessing because the client doesn't own the instance foliage actor, and thus the RPC was dropped
I'm sure i could have routed it through game mode / game state, or created a component on the player to handle some of this
please do π if there's an easier way I'd love to know. lol My way feels a bit hacky
Just to be sure we're on the same page: the foliage is spawned in the level at editor time right ?
Not some runtime shenanigans ?
correct.
also just edited my message to add that the spawned replacement actor had to be replicated. Should be a given, but just in case.
Where it would be good place for the loot drop mechanic in MP game i've been considering game instance?
game instance or game mode
I'd probably take game mode since that runs on the server and game instance is client too
why does joining my dedicated server cause it to close?
it causes the dedicated server to close
That literally gives us nothing to go on to help you
my bad it took me right as you were typing that to realize, let me reword.
When try I connect to my dedicated server, I get booted back to the menu and the dedicated server closes with a consolectrl exit
nvm that was the wrong log
okay nvm once again, it gives the same error on the server
except it isn't a error, it's just closing when i try to connect
Hey, according to this, should i mark every Actor possible into DORM_DormantAll ? For example my inventory items.
Are you sure thats whats happening, there is nothing in the log to suggest anyone connected at all.
Can you step through it with a debugger?
You should consider optimizations to every Actor for network performance regardless of what they are.
But specific optimizations to specific Actors depends on their purpose
If you read the dormancy documentation you linked, it suggests only Actors that do not change often be set dormant.
For example. If you have Items that are Actors on the ground, the only time they would change is when they are picked up (i would assume).
So they would likely be a good candidate for dormancy.
Items in an Inventory might change often.
You can change the dormancy whenever you like
So Items in an Inventory can be dormant if the Inventory is closed.
And when its open you can mark them as awake
These are just examples by the way.
It really depends on the game and its needs.
It's kinda vague that you said often. I mean, how often is often? 1 update per second? 100 update per second?
The player not gonna change inventory item 100 per second, more like once per 2s
Its vague because its not really something you can just draw a line in the sand for.
Changing "often" can depend on something like Player input.
Obviously real Players can only provide inputs so fast.
But Players can fake inputs
With a macro or something
So how do you put a number on a scenario like that
An Item Changing might be it being "used" (whatever that means) in the Inventory.
If I spam the input to "use" the Item, its going to change at an arbitrary rate
You cant generalize that
So you push it out a level and say something like, all Items in an Inventory are not Dormant if the Inventory is open.
Because at any time, at any rate, they might change.
Also keep in mind
That dormancy becomes less important the more you utilize Push Model
As with Push Model, the Actor only builds its list of properties to replicate based on if they were marked dirty.
So if nothing was marked dirty, it will be skipped pretty quickly.
Yes there is still overhead involved with checking if there are any dirty properties, but its another optimization taking a different approach that reduces the effectiveness of dormancy.
You should still be mindful of using dormancy correctly though
Even if you use Push Model as well.
Optimization sound like something a beginner shouldn't touch lol
Absolutely agree.
You will also learn that early optimization is a waste of time.
Once you have built depth to a system, meaning, it has most of if not all of the desired features.
You can understand it as a whole
And make better decisions about where and how to optimize it.
Optimizing (beyond the obvious) during development of a system can be essentially thrown out and wasted if you end up refactoring later when you have noticed your initial design is insufficient and you need to take a new approach.
Build the thing.
Get the thing working.
Iterate on the things design until its solid.
Then optimize the thing.
Is there anyway to make get base aim rotation replicated better. Its super laggy and makes the camera movement feel crappy. Or is there a way to make get control rotation replicated
Sound like you are trying to do some weird things, send the code where you need your control rotation replicated
Typically the Character Movement Component just do all of that stuff
So because I have blends of the upper body animations and lower
the upper needs to be replicated so other players can see
but Get Base Aim Rotation is relpicated automatically
but its replicated bad
its really laggy
Anyway, i have a question.
I have an item that have 10 different property, each connect to a different type of widget change. Say i change all 10 properties of that item in the server, and use OnRep on each property to change the widget. It will work, but my widget will have to refresh 10 times. Is there any way i can say like "On each update, wait for all 10 property to be replicated, then if any changes, update them all at once." ?
Now, i am not using RepNotify for this reason, but for each update i make an ItemData struct and just send all the data the widget need through a RPC. The problem with this is the widget display and the actual item in the inventory is not synced. So there is a brief moment before the widget got display and the actual item is replicated. If the player try to use the item in this brief moment, it will kinda just crash. Sure i can check nullptr, but it's a bad design anyway.
So i need to find a way to utilize RepNotify so that it doesn't throw 10 refresh on my widget. Any idea?
Then don't replicate it to the owner, only to other clients, because you need the other clients to see, right?
how would I replicate to other clients
Get Base Aim Rotation already replicated character rotation
Im trying to replicate character rotation without Get Base Aim Rotation because It laggy when you use that
What do you mean by it's laggy? Laggy on the owner client or on other clients
theres alot of choppyness both for the client playing and what the other clients see
Looked not-choppy for my human eyes. Anyway when you get the rotation on the owner machine, it should be a local value but not a replicated one
No you missunderstand
This is getting the rotation for each client
and putting it onto the server for others to see
if I use Get control rotation it gets rid of the choppyness
but doesnt allow other clients to see
im not sure what are you doing, because mine just work without any replication
the cmc just do everything
oh shit
I forgot to mention
Im doing a true fps so im on the 3rd person BP
so do i
its have nothing to do with true fps or not
are you using get base aim rotation or get controller rotation
GetBaseAimRotation.Pitch
and do you have any custom events using multicast or run on server or anything?
because mine is also pitch
everything is get from current machine
no data being passing around
look, it the same thing .Don't mind the pre-event graph thing, it's something i stole from lyra and have nothing to do with multiplayer
what the hell is wrong with mine
wait what version of UE5 are u on
just try to look around, eventually you'll find something
Ooh i fixed it
just had to have a is controlled locally
so it checks if its on multiplayer or not
Bump. I'm still looking for an answer for this question
hey sorry to bother again
what was your fix for makeing sure the camera cant clip through a wall
Iβve defined an **enum **with two teams: Team A and Team B. In my GameMode, after a player logs in (using the OnPostLogin event), I assign them to one of these two teams and save this information in their PlayerState.
How do I access this team information in the GameState to determine how many players are on each team. Specifically, I want to keep track of the player count for both Team A and Team B?
As a side note, my ultimate goal is to implement a scoring system where, if all players on one team die, the other team scores points.
GameState provides an array, called PlayerArray, that gives you all the PlayerStates of connected players.
So i need to find a way to utilize RepNotify so that it doesn't throw 10 refresh on my widget. Any idea?
There's no way to skip this - not with RepNotify. I mean, by having these 10 RepNotifies, you have to expect a refresh on every change. You can come up with some entangled solution to get what you want because in C++ lands everything is possible, but I believe your problem is in your design.
Thanks, I'll try to use it!
Honestly though, refreshing your UI on each/every change is not a bad thing per se - this is a declarative approach, and believe it or not, widely used when building UIs. It'd get bad, however, if these widget refreshes you are saying are doing expensive, sketchy stuff; saying lookups and all.
me thinking that you should alway initialize your variable like that: int variable{};
Guys, I need to have my character's head rotate towards where he's looking at, how to do that please ?
Do you have your character's head rotating already but is having problems replicating it or...?
No, I just don't know what should I do to set up that, like I need a direction to understand where to look to do that π
Ok so for now, that's multiplayer unrelated. You better ask #cpp or #blueprint.
I have an idea. What if i wrap them inside of a FStruct?
It works. π
And it gives you the atomicity you're looking for.
You are, doh!
But unless you convert your Item altogether to be a FStruct, you may face some challenges to keep the two states in sync. I'd move it altogether to a big FItemState struct. =p
There are problems with the approach above, however. Serialization, diffing & performance, pretty much. But that's a subject for later.
is there any documentation on chaos and multi? specifically managing stateful destruction for late joiners etc.
cant seem to find anything
They don't overlap.
People sometimes use dirty flags for this
a simple way is to have a boolean that's called something like bMarkDirty
and when any property is changed, mark that boolean as true
Then when all is said and done, only send the rep notify out when the bool is true, and reset it back to false
There are a few techniques you can go with, here are two:
- Have a replicated boolean like
bDestroyedthat triggers chaos for late-joiners; so what you do is like, only show the game for them once all your destroyed stuff gets destroyed. In the meantime, these people will be behind a loading screen or something. - Have a destroyed version of a building and that's what you replicate.
Have seen the two approaches in production.
That's a good one, except for invalidation. Hate that part.
What do you mean by invalidation?
ah ok, i was going to initially go about it that way but i thought it felt abit crude if not simple. thought i'd check incase there' some fancy way to efficiently serialize state or something
I am not sure how this will solve my problem. Even they are sent all at once, the widget still gonna refresh 10 times anyway
I just dont get the technique in general
Yeah I mean, I'm not a chaos specialist, but from what I've seen, that's pretty much it.
Here's the gist: you have X props/variables/whatnot. You mutate them as much as you like. Once you're done and want to refresh your UI, you do bDirty = true and this is when your properties get propagated.
where does this happen? on the server or client?
That's not exactly trivial in a networked scenario.
u can use atomic struct replication @twin juniper if u want it to get replicated as 1 thing
one more problem is it's not always all 10 property changed, so how would it know when to mark dirty
Go with this
https://vorixo.github.io/devtricks/atomicity/ u need to implement ur own net serializer
really ugly and lots of boilerplate but its good
You don't exactly need this if you don't care about perf. Am just anticipating this for you.
the atomicity is nice though
can tuck it away somewhere so dont have to look at it π
But that link is not about atomicity
That link is about making it performant
Atomicity is just collocating data close together
Data that make sense together; data that otherwise wouldn't make sense alone.
ye but it tells u how to ensure atomicity
It teaches you to build a NetSerializer so you just replicate what changed etc
i dont even know what is atomic stuff so it may is a good time to get started
There's not much to it
it sounds fancier than it is
well thank god
When you have those 10 properties of yours separated, they're loose; when you put them all inside a struct and you replicate this struct instead, you're making it atomic. That's all.
before i knew aobut this i had all this spaghetti logic checking replicated properties and making sure it was "fully replicated" with on reps and shit and it was a pain
then i found u can just write some other style spaghetti so it just replicates as 1 thing
but the atomicity way is less spaghett imo
There are some semantics here, however. Just bundling properties together does not make it necessarily atomic per se. Email and Password, for example, in a login form. If you send them separately and "simultaneously", there's no guarantee of ordering nor the arrival of one or another. They simply don't make sense separated. So you just bundle them into a FLoginData that makes integrity guaranteed. Now, bundling together Email and CharacterPosition3D is hardly atomic, unless you have a specific case where the two make sense together. Anyways, a matter of optics.
Just wraping them in a struct not gonna work right? Sound like i also need to do NetSerializer
It's going to work. NetSerializer is to make it optimal.
By the way
There's an Atomic USTRUCT specifier
USTRUCT(Atomic)
struct FMyStruct { ... }
Indicates that this struct should always be serialized as a single unit. No auto-generated code will be created for this class. The header is only provided to parse metadata from.
Hmm, I think it won't work
It's weird though; this is the docs for it from source
Β―_(γ)_/Β―
Yeah go with this https://vorixo.github.io/devtricks/atomicity/
Problem w this approach is that your packet size may increase across the board
Like always, there's always a gotcha/tradeoff hehe
WTF when did they add that
It was there in 4.26
that'a a true unreal moment right there
I believe nobody is using it lol. This is the search result I have in the editor. The only result is the one example I wrote lol
Too good to be true lol
i bet its bugged somehow
π
well actually according to that article iris stuff atomically replicates by default
but yea only downside to auto atomic replication is ur gonna have a fat packet that gets sent out if you decide to cram loads of stuff in there
I was about to paste this lolol
but in 95% of use cases not to worry
Can we opt-out?
dunno, idk what iris even is if im honest
I mean I bet we can but hey
i dont know what is iris too, should i get into that
the only thing that i read was "100 players" then i am like fk that im out
well it sounds like its just better
what are the downsides to opting in
documents do not seem to tell ..
ah right i just noticed the top part
they said that about everything, metahuman, the procedural tool,..
Probably not
AFAIK when Iris is ready, from what I've read, the integration will be quite seamless to your current codebase.
Iris is a new underlying networking layer
It does not change anything about how you normally interface with replication or the network in UE.
It just changes how the data itself is transported and reasoned about
AFAIK
Tell me if i get this right, the reason why my case work without atomic stuff is i always send my data all at once, so if i have packet loss, i'll just lose all of them, so it doesn't really matter if my data is atomic or not?
Atomic is like you send 2 relevant data but not at the same time
And 1 of the 2 can be packet loss
@twin juniper Property Replication is Reliable, you will always get the correct state eventually.
yeah but i dont want my widget to refresh more than 1 time, that was the initial problem
anyway i should be able to continue in my journey, thanks a lot @gui and @GIRU
Yes, that's right - it gives you data integrity
But you don't need to go atomic; that's what I was saying. You probably don't care about this.
@twin juniper @gloomy tiger the atomic keyword in USTRUCTs doesnt do what you think it does (it is only for asset serialization and doesn't have any usage for replication). If you want struct atomicity without using Iris you gotta netserialize it in a single blob like i showcase in the article. Iris seems now to make structs atomic by default :)
The thing with structs is that you might have states in the client that never existed in the server. Maybe this isn't a problem for you - or maybe it is. You know tools in the toolset!
by making the struct atomic, you'll know that all the states you'll receive in the client always existed in the server
This is a lie, unfortunately
Any custom net serializers you've written will need to be rewritten to be compatible with Iris, which is the biggest teething point so far.
Getting reply from Vori sensei himself.. What a day to be an Unreal Slacker
Going back to your original post @twin juniper, atomicity is impossible here anyway because you have actor/object references.
References to other objects can never be atomic. Unless those objects are permanently resolvable on the client, You will get multiple updates or some updates that are missing state.
has anyone written about this anywhere? information on Iris is still very much lacking
not AFAIK, just something we landed on while trying to move to it
tl;dr version of what to expect?
Been a couple of months since I looked into it gain but the Tl;DR is the symmetric NetSerialize methods are no longer used, instead serialization looks for templates that have been defined for your type, and calls those functions instead. They've also split off serialization from packing/quantizaton
They also tend to be a lot larger sadly π¦
Like FHitResultNetSerializer is like 500 lines now
Is there a way to see if Iris is working or not? I enabled the plugin, compiled with the SetupIrisSupport(Target); in my projectβs .Build.cs file (wasnβt positive thatβs where to do it but it worked?), and then copied all of the DefaultEngine.ini stuff from the epic doc.
that sounds annoying. the perf differential better be worth it
I will add this bit to the article as a note!
That's why I always discourage mixing stuff like the fast array serializer and UObject* references
Makes it a headache race condition wise
yeah, i mean atomic is fine for POD types but anythimg with a pointer.. bleh
Still could be useful in some cases though
am i wrong to assume that replicated properties with COND_InitialOnly don't need to be push based?
Silly Question but what's the best way to have the server add an item to an inventory array but also let the client know it was added
how can I rotate camera boom on simulated proxies when bUseControllerRotationYaw is false? Help please.
Would BeginPlay call wait until the properties are replicated? Also would there be a difference about this between actors placed on the level vs. actors that are spawned during gameplay?
Nope, they technically don't
Unless you enable some obscure setting that i'm pretty sure is disabled by default
It doesnβt βwaitβ per say, but replication is bundled up and sent at the same time so if a server spawns a replicated actor and sets variables right away a client will see them in the beginplay
Actor replication guarantee: when an actor replicates to a client for the first time, its replicated (unmapped/non-uobject) properties are guaranteed to be there. However, the rep might happen before or after BeginPlay(). It'll be on the same frame as the BeginPlay() call at least.
So it'd be safer to do it in rep notifies anyway
But yeah, BeginPlay() won't wait for the replicated properties
only true for runtime spawned actors
Yea not map loaded
Actors placed on the level are "safely" named, or statically named, meaning you can reference them by path for replication
Actors spawned are dynamically named and the server sends the path & a net guid for them when replicating them
All in all: not much difference, both get net guids assigned to them anyway
However, actors loaded from the level don't get destroyed when their actor channel closes
They stop replicating but they'll still exist on the client
Spawned actors would be destroyed
Thanks for the answer and the additional information. Especially this one answers some questions I had on my mind earlier as well
Hello, how can I create a server-side function in cpp to execute a Destroy?
What are you trying to do
Destroy the item on the ground, after picking it
Your pickup code, where does it get executed
Ah, locally I guess, just create some functions
{
UE_LOG(LogTemp, Warning, TEXT(" AAAAAAAAA Interacted with: %s AAAAAAAAAAAAAAAA"), *ItemToAdd->ItemStruct.ItemName.ToString());
if (IsValid(ItemToAdd)) {
int32 SlotForItem = FindSlotForID(ItemToAdd->ItemStruct); //Buscar slot con = ID y espacio de al menos 1
int32 SlotSpace = 0;
int32 AddAmount = 0;
//Validamos el item (objeto)
if (!IsValid(ItemToAdd)) {
return AddAmount;
}
//Solo se entra al while si se encontro al menos 1 slot con el item de referencia
while (SlotForItem != -1 && ItemToAdd->ItemStruct.Amount > 0) {
//Se calcula el espacio en el slot
SlotSpace = InventoryItems[SlotForItem].ItemStruct.MaxStack - InventoryItems[SlotForItem].ItemStruct.Amount;
if (SlotSpace < ItemToAdd->ItemStruct.Amount) {
//Se le resta al item lo que le faltaba al slot para llenar el stack y se deja el elemento de array en su max stack (por colapso)
ItemToAdd->ItemStruct.Amount -= SlotSpace;
InventoryItems[SlotForItem].ItemStruct.Amount = InventoryItems[SlotForItem].ItemStruct.MaxStack;
//Se suma a la cantidad agregada
AddAmount += SlotSpace;
}
else {
//Se suma la cantidad de forma directa al elemento del array ya que no colapsa el *STACK*
InventoryItems[SlotForItem].ItemStruct.Amount += ItemToAdd->ItemStruct.Amount;
AddAmount += ItemToAdd->ItemStruct.Amount; //Se suma a la cantidad agregada
//Cantidad del item en el suelo pasa a = 0
ItemToAdd->ItemStruct.Amount = 0;
//Se destruye
return AddAmount;
}
//Se sigue buscando algun slot con misma ID y espacio minimo = 1
SlotForItem = FindSlotForID(ItemToAdd->ItemStruct);
//Se verifica si el Item en el mundo sigue siendo valido, caso contrario nos salimos de la funcion
if (!IsValid(ItemToAdd)) {
return AddAmount;
}
}
//No quedan slots con la misma ID y espacio, ahora se buscan espacios vacios
if (FindEmptySlot() == -1)
{
...
You'd wanna make sure you execute this on the server
Use Server RPCs if the client triggers it
Ok, but how can I create a server-side function? In blueprints I just clicked on it and set it to run on the server side and that's it, how is it done here?
UFUNCTION(Server, {put Reliable or Unreliable here as well})
Thanks π
UFUNCTION(Server, {Reliable})
void DestroyItem_SR();
``` is well?
Don't include the {}
Server, Reliable
It was just there to tell you one or two other options that you need to put
So I'm sending a WeakObjPtr<AActor> of a parent actor, which is null when there is no parent. I am faced with an issue where there was in fact a parent that got replicated, it simply didn't get spawned on the client yet. Is there a way for me to differentiate between the case where the WeakObjPtr is pointing to an unspawned actor, vs where it's actually null?
thanks
Yep, it was too good to be true. 
That also explains why I found 0 occurrences of USTRUCT(Atomic) in the codebase, lol - anyways, thank you for clarifying.
Thanks for clarifying. Well, if that's the only thing required to get Iris in motion, I think it's... less bad? But now that we're talking about it, are you using Iris? If so, I'm curious about the state of it.
Haven't used it enough yet to get an accurate picture unfortunately. Some others have had much more luck though:
https://brickadia.com/blog/devlog-3/
It's really not a big deal unless you have a ton of custom serializers.
And the need to use custom serializers for atomic replication is gone under iris
Good for them. Too bad this post just teased me lol.
Regardless - one last question; the NetSerialization thing - will it be backwards compatible, at least? Or things will just stop working?
If you don't provide a custom serializer, it jsut falls back to the standard replication path - but that excludes your custom serializers for the "standard" path
Yeah this is a big win tbh
Ah, aight then
Not too much to lose I think
I read through this and got to the small part about Iris, and was like, "what's the big deal? I don't see such a big gain like the text is describing". Then I realized the old graph is in ms and the Iris one was in Β΅s π±
I had to make some small improvements to Iris to get here
unfortunately vague language
anyone done a day night cycle so I have all the logic done in my "Time of day" Actor my sun rises sets with a moon everything works as intended im not sure what needs to be replicated to the users I have multiplayer all set up but Player 1 sees a different sun location then player 2 and vice versa depending on whose been playing longer the time of day actor is not updating to match the dedicated server any help would be greatly appreciated I have tried to push the time variable to my GameMode to no success also sent it to the game instance should i be driving the day cycle from the GameMode? im lost lol
I'm failing to see what time of day and replication has to do with each other.
i think i have a disconnect between someone who was testing my game disregard
This is what our game does:
We have a replicated float CurrentGameTime in our GameState that goes from 0 - 24; the sun adjusts its position based off this CurrentGameTime, which is managed by the server. And that's it.
thats what i have too
im testing with 2 more laptops side by side with different steam logins
π€
like i said it could have been the other user not understanding what i was asking
Where's your CurrentGameTime? Who is setting its value? What's the algorithm you're using to set its value?
i just confirmed when PLayer 1 is joining the server its at noon and when player 2 joins they see noon when player 1 sees 6PM
the current game time is set in PIE using an exposed to editor i set the time before play
so i should be driving the Current Gametime From the game state to set the variable in the Actor time of day im guessing
Currentgame time onrep -> set sun position?
Does anyone have any information about why Get current players is not working?
Not exactly but
Whos beginplay is that?
I cant see the onrep
Id also have local 'prediction' and just semi regular updates from the server
thats the actor for the time of day
in the class defaults i have the actor set to replicates and always releveant
Beginplay plays on all clients and server
You should gate atleast the set node so omly server sets it
Clients simply follow it
@hoary spear
Timer can run locally aswell
Sorry i can slap together some example code soon
Putting kids to bed atm
no i think i got it ill have to packagae and see if this works
Hi !
I have - finally - a working **VOIP **with Steam Subsystem !
Thanks to VOIPTalker I'm able to change player's voices and spacialization at runtime.
Now I would like players to have multiple voice outputs !
ie. P1 and P2 are in the same room. P1 and P3 have walkie-talkie. P1 says "hello" with walkie-talkie in hand.
-> P2 should hear P1 regular voice
-> P3 should hear P1 modified voice from its walkie-talkie
Does anyone have an idea on how to make that happen ? π₯Ί
sounds like this will help:
https://forums.unrealengine.com/t/route-real-time-audio-input-to-an-object-location-in-3d-world-coordinates/273563/2
This is complicated due to the microphone input component. The old VOIP talker API is not utilized widely and is definitely an older system. Youβd need to write some C++ code to attach a source effect to the VOIP talker output. We use the VOIP system in EOS (Epic Online Services) for Fortnite. I implemented some gameplay code that allows us to ...
Hello, I want to make a flashlight in multiplayer. One that only others see and the other that only the owner sees. As you see, number 1 is for the others to see and the owner will not be able to see it, and number 2 is the other way around. Please, how can I make this work? I've tried using different kinds of replicating methods and it worked for the clients but not for the server.
Maybe check to see if the player is being locally controlled?
Then if it is, set the intensity to 0 instead of setting the visibility. If you are replicating this actor & component, that is why it isn't working for the server
hello, i'm making a first person multiplayer coop game that could have dozens or hundreds of puzzles. Is it a good idea to make each puzzle a pawn that the player controller possesses so it does camera transition automatically, uses its own control scheme and also disables input from the main first person character?
in theory there shouldn't be much network overhead if i don't possess them no?
just the initial batch of variable replication
and then it should stop updating
until i possess it
Will try
There is an option for "Owner No See" and "Only Owner See". Use those.
I tried but theres no option for light components
Only meshes i think
One sec, let me see how I did it
You can just spawn the flashlight in target machine locally (by setting the flash light actor to not replicate)
Yes thats what i did and it worked but know im stuck on how to make the other light only be visible for others and not the owner.
I'm looking at this now. And yeah, you're right. There's no need to use ClientHandleMoveResponse, I will update it. This makes it much cleaner for derived classes too, with the Super chain
Anyone gotten Iris set up have a second to chat?
@thin stratus Looks like it should go in OnClientCorrectionReceived instead, this is called only from ClientAdjustPosition_Implementation and only when passing these checks:
if (!HasValidData() || !IsActive())
{
return;
}
// Make sure the base actor exists on this client.
const bool bUnresolvedBase = bHasBase && (NewBase == NULL);
if (bUnresolvedBase)
{
if (bBaseRelativePosition)
{
UE_LOG(LogNetPlayerMovement, Warning, TEXT("ClientAdjustPosition_Implementation could not resolve the new relative movement base actor, ignoring server correction! Client currently at world location %s on base %s"),
*UpdatedComponent->GetComponentLocation().ToString(), *GetNameSafe(GetMovementBase()));
return;
}
else
{
UE_LOG(LogNetPlayerMovement, Verbose, TEXT("ClientAdjustPosition_Implementation could not resolve the new absolute movement base actor, but WILL use the position!"));
}
}
// Ack move if it has not expired.
int32 MoveIndex = ClientData->GetSavedMoveIndex(TimeStamp);
if( MoveIndex == INDEX_NONE )
{
if( ClientData->LastAckedMove.IsValid() )
{
UE_LOG(LogNetPlayerMovement, Log, TEXT("ClientAdjustPosition_Implementation could not find Move for TimeStamp: %f, LastAckedTimeStamp: %f, CurrentTimeStamp: %f"), TimeStamp, ClientData->LastAckedMove->TimeStamp, ClientData->CurrentTimeStamp);
}
return;
}
The only one I'm not sure about is bUnresolvedBase
After it passes these checks it calls ClientData->AckMove(MoveIndex, *this); and then OnClientCorrectionReceived and then begins actually applying the corrections
So it does seem like I should use OnClientCorrectionReceived otherwise we could be applying stamina changes that fail sanity checks?
That said the engine only uses OnClientCorrectionReceived for drawing debug stuff
I have a little question about multiplayer side. Actually, i'm preparing a plan for my new simple game, and I would like to know, if I can begin the game and test prototype by solo game and later integrate the multiplayer is that a thing that could be accomplished or I need to create the game with online minding first?
Start with MP
Retrofitting MP can be done, but it is extremely extremely (yes twice) painful
Because general structure of things break once MP is introduced
I'll hold off just in case. Ping me tomorrow
Only exception is if you're willing to ditch the prototype and start over once you're happy with it I guess, which can be a valid way to go about it
UCLASS()
class AStorage : public AActor
{
GENERATED_BODY()
public:
AQyStorage();
void Initialize(int InStorageSizeX, int InStorageSizeY, int InTileSize, EStorageType InStorageType);
UPROPERTY(ReplicatedUsing=OnRep_Data, BlueprintReadOnly)
FStorageData Data;
UFUNCTION()
void OnRep_Data();
//- Array
UPROPERTY(Replicated)
TArray<FInventoryTile> Tiles;
UPROPERTY(Replicated)
TArray<AItem*> Items;
}
UCLASS(BlueprintType)
class LASTDROPGAME_API AItem : public AActor
{
GENERATED_BODY()
public:
AQyItem();
void Initialize(AQyStorage* InParentStorage, TSubclassOf<AQyItemActor> InItemActorClass,
FIntPoint InLocation, FIntPoint InSize, int InQuantity, bool InIsRotated);
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(ReplicatedUsing=OnRep_Data, BlueprintReadOnly)
FItemData Data;
UFUNCTION()
void OnRep_Data() const;
};
Hey guys, i have a question about designing inventory.
My current inventory is: A big thing that store items is AStorage. It has FStorageData to store its own variables that is related to widget displaying (SizeX, SIzeY, TileSize). When the Data is replicated down, the OnRep will call a delegate and display the storage. AItem is pretty much the same.
The problem occur when i tried to open a storage. An empty one would be fine, because it doesn't need AItem->Data to be replicated. But if i open a storage with item in it, i would need AItem->Data somehow.
I can use a timer client side, but it gonna delay the widget display timing. If the timer rate is low, it gonna impact performance. Or i can wrap everything inside of a big FRealStorage struct, then use that to replicate and display thing. But then i would lose the pointer design which i need. Or i can have a class that only store a truct reference..?
Do you guys have any idea with this?
It's easier to read if you specify c++
````cpp`
You must have a bug then, because i did
Maybe it's just my phone, not at PC
I'm not understanding the issue tho, is the server only replicating when the storage is opened, causing a delay for the client to receive the data via replication and thus a delay with the UI showing what's available?
Wait that actually make sense
Okai thanks then i will do it mp before
But using client data would generate edge cases. Like if someone tried to add an item to an inventory right before you tried to open it the the server, and when the OnRep fire, it may be looking for a nullptr because the item is still not replicated
I guess i can really add a timer there because they are edge cases
Thanks Vaei , i think i got the gist
I think your UI simply needs to update in real-time, not be something that is setup then left alone, make it change along with any information that changes (so items can appear/disappear while the storage is open)
And maybe replicate the information before they open it as well, you'll still need to do the above for edge cases - or if another player takes something?
Just give it a small net cull distance, so if they go near it, it replicates usually before they get close enough to open it
How would one prevent a client from sending movement? Or rather, how would you prevent the server from accepting said movements? (move and look)
These go through the MovementComponent - all the other actions go through replicated functions (with validate methods) - so I can bail out there. How would I implement that with the movementcomponent? I can't just disable it because I want the gravity to keep acting.
Anyone know of any out-of-the-box way to monitor PlayerArray client-side? That is, when it changes. I know that is pretty much bookkeeped by AGameMode; am just making sure I am not reinventing the wheel by implementing my own stuff.
No way out of the box that I know of. But it is inside of AGameStateBase. The AddPlayerState and RemovePlayerState are virtual methods. You can override them and broadcast your own event inside of 'em
The AddPlayerState and RemovePlayerState are virtual methods. You can override them and broadcast your own event inside of 'em
Gold. Thank you! β
Is syncing Mixamo animations possibly for online multiplayer?
Yes.
hi I'm currently working on a game with multiplayer, but listen server only. I was attempting to convert it to a dedicated server structure. May I know if there are common best practices for making it such that the entire code base can be run as a dedicated server and also listen server?
I know about the basic stuff like checking if "can display cosmetic events". But for example, in many places in my project I currently use "Get Player Controller (0)". Is it normal just to put this behind "Is Valid" nodes to make sure there aren't any exceptions on the dedicated server?
Get Player Controller (0) makes sense for things that are for the first local player controller, but you have given no context for why you want just the first player controller here
I use it generally to get the current player's controller (be it on server or client).
that is not the current player, but the current world's first player controller
the current player is something that depends on the context
from taht page, it seems like the closest I should replace it with is this node?
it was a 1v1 game, therefore getplayercontroller(0) would always return me the respective client/server's player controller
ah I just saw there's a c++ function GetFirstLocalPlayerController(). strange that that isn't exposed to BP
That is just 0 again
The point is that you usually don't need that node
Cause you can get the controller, if needed, usually via your current context
May it be the Pawn you are in
Or the PlayerState
Get Controller on the Pawn would return something else than GetPlayerController0 depending on where you call it
Client calling it on their own Pawn would be the same. ListenServer calling it on their own Pawn should also be the same.
But server calling it on a different pawn would result in Get Controller returning the Controller of that pawn and not of the ListenServer
And Get Controller called by a Client on a different pawn would just be null
You can use GetPlayerController0 in cases where you really just want the world's local first PlayerController. But that is a specific choice in a specific case.
If the server for example should respawn the current pawn reference of some client and also in the end repossess it, then you can't just use GetPlayerController0 cause that's the wrong controller then. You want to Get the Controller of that pawn
There are several places in my project where the playerβs controller is not immediately accessible. For example from the game state, or from a WBP, or even from some other actor in my world
How should I go about getting a local player controller reference in those cases? Should I be passing in the controller and hold that reference on initialisation?
Why would the controller not be available to the WBP? Are you not passing it in when you're PC is creating it?
All widgets accept a PC
And you can just use GetOwningPlayer to get it
They shouldn't be PC dependent then imo
For example if I have a health bar component on a tree in the world. And on damage, i want to check if the instigator is the local player controller. I was using get player controller (0) as the == check
But thatβs just an example. Iβm sure thereβre other cases where actors in the world would like a reference to the local player controller. I could probably find a way to manually pass in a reference. Just that I was used to using get player controller(0) as a convenience function to getting the player controller in single player games.
Hey guys is there any way to read root motion and expose it as a variable ?
like a vector
Being velocity?
I post it here so I can replicate it later
That is why
But if anyone has already a workaround tell me
Animation Montages... How would do if I want to trigger the animation locally on the client immediately but replicate to the rest of the clients via server Multicast?
Using server multicast event I guess my local client animation would be triggered twice? Once when starting locally and once when replicated.
Is there a way to replicate to the "other" clients only?
Hey guys, is there a pretty way to trigger OnRep function even when no property is changed on the server? Like ForceNetUpdate kind of style
I can probably make a RPC since no data is changed anyway
You can set it to repnotify_always, if that helps?
It will onrep even if no change occured (but the var was set)
Would APawn::IsLocallyControlled() return true for an AI that runs on the listen server?
You can call an onrep directly locally
Which is not over the network, just in case it helps reduce code duplication etc
Hi, so I have setup dedicated servers using playfab and am able to connect multiple clients via matchmaking, is there a way to browse and search these lobbies instead of directly connecting to an available one?
I think using OnClientCorrectionReceived here is totally valid
Totally quoted the wrong message.
But well
How did you do it?
In unreal engine what is the hierarchy in which classes are initialized? like at what point in a dedicated server setup can i be sure it is ready to accept players?
I'm not exactly sure of this, but I imagine once Game Mode's begin play fires, then it should be able to accept players by that point seeing as the Game Mode is what handles players joining.
I see ok well in gamemode itself i used the startgame() override and called the function after the super call just to be super sure(im sorry for pun i deserve to be banned ik)
Hey, i'm trying to spawn a replicated Actor from an ActorComponent on my PlayerCharacter.
The component should then either directly or via server RPC if it has no authority, call a function on the spawned actor, my question is: does the function in the spawned actor need to call another RPC or would it still be the server calling that function?
Any tips, advice or pointers in the right direction would be awesome!
Hello Comrades! We are working in unreal engine many years, but I still can't get best way to create inventory. Which type of item is best?
- Structure
- Object
- Actor
- DataAsset object
what are u prefer? why?
Personally I use a struct and data assets. Basically just a variable for the data asset and a numerical quantity variable. But every system has its pros and cons. Using data assets I canβt generate unique items at runtime but for my purposes that doesnβt matter
data asset for item templates, structure for item instances w/ FInstancedStruct for data composition, UObject for inventories that holds item instances
Just to let you know, if you don't already know
Iris is now compiled in ue 5.2 by default
and Mover 2.0 is available in UE 5.4 Dev branch
I do know. But Iris isn't production ready for me yet, so I'm staying on the ol' tried and true.
Hello everyone, I'm trying to make an object throwing system with a projectile. The object server is also pretty smooth. For clients, it's jerky. I couldn't solve my problem. Is there anyone who can help?
It has been done π @pallid mesa you might want to be aware of this change too, we've replaced ClientHandleMoveResponse with OnClientCorrectionReceived for Stamina. It was quite ugly in my own project, because I'd have to call UCharacterMovementComponent::ClientHandleMoveResponse instead of Super and then reintroduce everything from the super classes π
thanks vaei - i... made this change myself but never retrobacked it to ya - completely forgot
All good haha π
I mean, how could you?! π

Uh, wait a minute, I think 5.3 might have changed, need to add preprocessor stuff. Yeah their arbitrary gravity stuff (which I'm grateful is finally here)
doesnt work too well
Yeah I don't think they've completed it yet
Bit late, given we have Mover 2.0 coming
fn doesnt use mover, so...cmc will still be getting some love
True
I wonder if they will eventually change to it
They did try making CMC async (and don't think they quite got there), maybe if Mover 2.0 is async they will use it
It was an interesting example of how to build async movement code actually
Good lord this is so ugly

These new macros don't have UE_VERSION_NEWER_OR_EQUAL_THAN either
And... actually... these new macros don't even work
Thanks for trying Epic 
This is on 5.1, am I using it wrong?
I will just do this #define WITH_ARBITRARY_GRAVITY ENGINE_MAJOR_VERSION > 5 || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 3)
hello, what is the best place to handle the change of controller on a pawn? if i use OnRep_Controller sometimes it doesn't trigger on the client, in the past i also think i had problems with NotifyControllerChanged
I was under the impression a dedicated server had no playercontroller, however when my player joins a game, first I'm getting a ROLE_Authority calling some methods of my playercontroller class, then when that's done, some methods on a ROLE_AutonomousProxy, can anyone explain what's going on, please?
Dedicated server has every player's playercontroller
the dedicated server has all of the player controllers, but it doesn't have one for itself
since it's not a listen server
so no client
Oh ok, thanks for clearing that up!
NotifyControllerChanged also doesn't seem to trigger on the client when OnRep_Controller doesn't trigger
it seems to be this piece of code that sets the controller to null without calling the OnRep_Controller or NotifyControllerChanged
Have you tried using SetPawn from player controller
I don't remember exactly where that gets called
the possess on the server should handle everything
Hey guys, so Im thinking about creating multiplayer for my game. I understand that this is a newbie view of the problematic and many had this idea and failed, so I would like to ask this community, what are the big obstacles, what is the best architecture, where are the best guides and docs etc. Thank you π
@glossy storm learn to build from source
I know how to do that
always do
then do steam sessions and AWS with a simple main menu and server browser
ok, what if target hardware is oculus, should I focus first on Steam sessions or go with different approach?
yah i only know how to do steam sessions with dedicated server server browser stuff
my builds are windows only sorry i couldnt help
no problem, thanks for reply
Also if there is anyone with VR multiplayer experience in Unreal I would be willing to pay for consultation (sorry if this request offended someone ), I really want to talk to expert before diving into learning process myself, because from experience it would just save me a lot of time.
I'm looking for really simple tutorials or projects that would teach making a multiplayer game, any recommendations?
Ideally something like Rock,Paper, Scissors.
Hey guys, is there any video or article about designing anti-packet-loss system?
What?
Or just simply don't do chain actions based on multiple packet?
wdym what.. im just asking
seem like nobody is talking about what is packet loss or how to deal with them
The only bit i found is in
https://vorixo.github.io/devtricks/atomicity/
How can I make a set visibility only for a player that enters the overlap of a sphere? I made a system but when a player enters, the visibility changes for all players
you send a Client rpc from server to that player
with overlap you are just running it on all machine
Would I have to move everything to a function that runs client-side?
You cant stop packet loss. You can only retry sending what did not arrive.
Packet loss can occur for any number of reasons.
Reasons you cannot solve with software.
IE: physical line faults
In this case, the Engine already handles this for you.
The reason no one talks about it here, is because its not something that can be dealt with outside of what the engine already handles.
Oh, i didn't know that the engine auto resend them
For replicated properties and reliable RPCs yes
Thanks Matt.
Hey guys, is there a good way to make OnRep function also run on server? For now, i am just manually do a server check and call them each time any value changes, it feel hard to keep track of them and keep the sync.
Thats not a #multiplayer question?
No, you must manually call them in C++, there is not automatic mechanism.
Setter functions and only change the value through that setter.
Then do the server check inside of the setter
hello i have a boat that moves through a spline (like a elevator) , everything is replicated and multicasted. but im experiencing a jitter on the client end. in server it works fine , anyone can give me tips how to remove this jittering on clients end when they are above the boat?
How do you guys generally deal with trying to use replicated variables on client-side very early in the game's lifecycle? for example I'm trying to access a replicated variable on a WBP's construction, but the variable hasn't been replicated yet so it's returning null. What's the best practice around this? I've seen some code "delay until next tick" until the variable is no longer null, but that doesn't seem right.
I wanted to subscribe to an event dispatcher on an object (and that object reference is a replicated variable on my player controller)
Well, you could setup a delegate that gets called when that Object is replicated, sub to that first, then sub to the delegate on the Object in that callback.
Alternatively, if the Widget is dependant on that Object existing, perhaps you need to create the Widget when its replicated, not before.
for option 1, you mean like on a RepNotify?
Yes, in the OnRep, you would broadcast a delegate that says the Object is ready.
The Widget would sub to that first.
is this generally how you would handle replicated variables that you need to access early on in a game's lifecycle?
in general I was also looking for a way that unreal can tell me "ok, this client is done with initial replication for all variables/actors that are relevant to him". But I can't find a way to achieve that.
Replication can initiate and take arbitrary time in a non deterministic order. So that broad of a concept just isn't really possible.
What constitutes as initial?
from null to no longer being null (at least for my use cases). I get your point, and I realise there's probably a reason for it. It just feels awkward to handle early in the lifecycle of the game starting up.
What is the Object you are replicating?
Whats its purpose?
If this is a special manager Object of some kind, like a Team Object or whatever, you probably want a system that broadcasts its availability anyway
ah ok yeah. though I have a number of these "manager" type objects. so I guess the best way is to just specifically do a repnotify and subscription for these specific classes...
Is there a way to connect to a dedicated server packaged in Windows with an iOS app?
while i have your time, do you mind giving your thoughts on my question I asked yesterday? Regarding never using GetPlayerController(0) in multiplayer games
You should generally avoid GetPlayerController(Id)
Same with the other framework class counterparts
Like GetPawn GetPlayerState
Etc
not even getplayerstate?
I mean the Id variants
ah i see
Where you are passing the Id of the Player they belong to
yeah, but I do have an example of a situation where I'd like to get a ref to the player controller from an arbitrary actor in the world
GetPawn and GetPlayerState that are specific functions of another class like PlayerController or Pawn is fine to use
in single player games I obviously can do the Id method
For example if I have a health bar widget component on a tree in the world. And on damage, i want to check if the instigator is the local player controller. I was using get player controller (0) as the == check
^ Copied from my message yesterday
Hey, i didn't thought of that. Thanks!
Why? The Widget knows by default who its local PlayerController is?
because I'm handling damage dealt on this tree, so it'd be on the actor. Only if the instigator is the local PC, does the widget component show up
I need the reference to local PC on the tree Actor, not the widget
Yeah well you said nothing about a tree, you only referenced the Widget
In the case of an arbitrary Actor that isnt owned directly by the local Player
Then yeah, you need to determine the local player some other way.
"a health bar widget component on a tree in the world". For example imagine the health bar on a tree in fortnite. It only shows up when the player attacks the tree
i see ok... so there isn't some easy reference. hmm
thanks!
Sorry I must have skimmed that tree part after reading Widget
up
So i just set up this peer to peer hosting and whichever the client is doesnt have any of the fire rate variable or anything Ive set
only the person who joins
the stats are replicated
its like
there not replicating for the host
so i found out why
the host is using the default values
but i have no idea how to fix that
I'm currently encountering an issue where, upon running the iOS app built on my Mac, it fails to connect to a dedicated server hosted on a Windows machine. The connection consistently drops, and the following error message is repeated in the logs:
Here's a breakdown of the steps I followed:
- I created a dedicated server using the Unreal Engine source code version tailored for Magic Leap in window
- I brought the entire project to my Mac, and I opened it using Epic Launcher version 5.3, without the need for the Magic Leap plugin.
- Subsequently, I built the project for iOS.
Details about my environment:
- Mac OS version: [Sonoma 14.3.1]
- Windows version: [Window 11 pro]
- Development tools and versions: [Xcode 15.2]
- Unreal Engine Source code 5.3(magic leap2)
you aren't even able to connect are you?
When I run the iOS app and see the server status change, ios app try to connect but it feels like being blocked.
OK i will give you everything i did to completly remove version mismatch, NOTE-what i am about to give you is a 100% removal of version system and mismatch all alltogether, you should only use it for development for later phase overwrite it with custom logic that works across platforms and stuff
I used these bcz i was facing issue idk if they were same as yours or not in WindowsXMac
Default engine.ini add this
[URL]
net.IgnoreNetworkChecksumMismatch=1
In my game instance's C++ class
header file
UFUNCTION()
uint32 GetGameNetworkVersion();
the .cpp file
uint32 UPanoverseGameInstance::GetGameNetworkVersion()
{
return 111;
}
i think the above code solves your network version mismatch all together too so you prolly DONT need the below function as i have it commented out too but i will give just in case you decide to use it for something in future
header
UFUNCTION()
bool IsNetworkVersionCompatible(uint32 LocalVersion, uint32 RemoteVersion);
.cpp file
bool UPanoverseGameInstance::IsNetworkVersionCompatible(uint32 LocalVersion, uint32 RemoteVersion)
{
return true;
}
Now we come to GAMEMODE you are connecting too, here also there's a prelogic funtion that verifies your stuff before letting you join
header file
virtual void PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage) override;
.cpp file
void APanoverseGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
ErrorMessage = GameSession->ApproveLogin(Options);
FGameModeEvents::GameModePreLoginEvent.Broadcast(this, UniqueId, ErrorMessage);
}
@near granite
as i said this i im pretty sure this is removing lots of fail safe for weird version mismatches so do replace it with good logic for production use π these only for development
Putting the answer to my question that no one could answer.
So I tried seemless travel and it didn't work.
However, in a hopeless attempt after trying everything, I disabled the firewall .. and everything worked..
I reenabled the firewall again later after closing unreal, and reopening it this time .. windows popped the firewall permission thing and everything works correctly again.
I might be missing a simple solution here but is it possible to let some players pass through an object and not the others?
If I would disable the object's collision on the clients, the server would still block the movement through it. If I would disable the object's collision on the server, then everyone would be able to move through it
This could be solved by playing with the Pawn's collision settings but then the players could pass through each other as well
Would creating a new collision object type, setting the mesh I want to be passed through as this type and playing with specific pawn's object response to this channel on both server and client an optimal solution or is there a better one?
We have a multiplayer game and are working on the HUD setup. I like to use βGet Owning Player Pawnβ in the Initialize function of a WBP and then bind to pawn specific event dispatchers such as βOnDamageTakenβ, βOnItemPickupβ etc. This seem to be a nice way to decouple the widgets and have them only listen to event and refresh UI elements on events. However, in a multiplayer setting the event dispatchers are almost always server called and when you bind in a UI context it only binds on the client version of the event dispatcher. Obviously, you then need to call each dispatcher on client as well then but is this really good best practice? Does anyone have any insight on UI architecture in a multiplayer setting?
I'm not sure what the best practice would be, but the way I follow is broadcasting events in multicast RPCs or OnRep functions, if clients are also in need to know about that event is happening
If I would disable the object's collision on the clients, the server would still block the movement through it
Why don't you try setting client's collision from server then
For example if you show every player's health on a widget, broadcasting the event on the OnRep function will notify every player that one specific player has now an updated health value. Binding widgets to respective PlayerState's events will make the widget update itself according to the value changes. Or if you want to show a pop up saying "30 seconds remaining", you can call the broadcast in a multicast and any player that receives the broadcast can create/show the widget on the screen
By client do you mean the pawn's collision?
Yup
the client version of that pawn, set it from server
send rpc for that request or whereever you like
Right, this should be the simple solution that I was feeling like missing
But it confirms that it's not possible to achieve the logic by playing the mesh's collision, right?
Using custom collision i am sure you can achieve something but even in that if you want to change the collision response dynamically based on some of your game's logic then at some point on another you will need to change the collision of client pawn from server
I see. I was thinking about letting the actor I want to be pass through decide and store the state of who can pass through and who can't, that's why I was focusing on changing that actor's mesh's collision settings. But I guess letting the pawns decide and store their state of if they can pass through or not would be more logical since changing pawn collision looks like a robust solution
Thanks
Hello,
how do I get the local player controller(better the owned player controller i guess) if i dont have a pawn yet? i tried this but it says -1
I'm not aware of a clean pure BP solution for this so I'll say just use the player controller getter node with the id/index, which can work properly most of the time but could cause problems if you use seamless travel with listen server, iirc. The proper way should be to use UGameInstance::GetFirstLocalPlayerController() which is only available for cpp. So creating your own blueprint callable function that returns the result of that should be the best solution
dont know c++ yet. yeye i know..i gotta learn it for mp π but for now i wanna get as much done as possible without before i spend time on that π
Oh also it seems like a widget so using GetOwningPlayer would be better than GetPlayerController with index
it aint a widget, its the HUD_class π
The HUD version should be GetOwningPlayerController node
its basically a "character selection screen"...
player joins...gets that screen and selects the characters according to his steam id that he created on that specifc server etc
hm,lemme see
ha,youre correct...weirdly i assumed i tried that one, and couldnt find it...worked immediately now. thanks π
When a player joins, the server will have ref of the new player controller in Game Mode :: Post Login
but the server aint supposed to do something, the client is->do a call "give me all my created chars" π but layso's solution worked... i knew the node he refered to and i thought i had tried it and it didnt work,thats why i came here to ask π well seems like i didnt...or typo and i didnt see,dunno π
It's a bit more work, but you can do OnRep_Notify on replicated variables if you don't want to create a dedicated RPC for certain events.
That allows you to nicely call the dispatchers on the client whilst respecting the server authority.
The lazy way would be to have some PlayerStateUpdated event, and the UI just updates the entirety of the displayed info. Negligible overhead - depending on how much data ofc - and have each of your OnRep invoke that.
I see, but some of these are not really relevant for all players. Like to show the pickup text or health is only show on individual HUDs so it doesn't have to be broadcasted to all clients.
You gonna end up having a mixture of RPCs and OnReps
Anything that is State Related will be communicated via OnRep
Which will call your Delegate
Anything that is a one time event will be an RPC
Which again calls your Delegate
Which one is which depends on your context
Health for example is a State, and changes to that would run throug hthe OnRep variable
One can argue that a "Flash Screen Due To Damage" would be a One Time Event, but also is connected to Health going down, so you could set it up with both.
I would probably use an RPC for that specific one
But again, that one could be done by just comparing health values
RPCs are theoretically very rare for UI fwiw
Most of your Data for UI is a State
So they will most likely be an OnRep driven Variable
@zinc canopy
To add; OnRep_Notify will be called for the relevant client(s) receiving the updates, not necessarily for all clients - assuming you're using UE's replication system. And RPCs can also be targeted at specific clients.
The implication here is these events will be localized to the client of interest, you're not wasting resources.
Hey. I'm trying to figure out why sprinting is so jittery for the client that is sprinting but the other clients pov it's smooth. I think I replicated everything right.
https://paste.ofcode.org/Ppngkj8ZKHCNbQM64pEZDL
On shift press the Sprint() calls on release the StopSprinting() calls
Keep in mind that this is absolute wrong :D
If you need Multiplayer Sprinting, it has to go into the CharacterMovementComponent
We have a repo in the pinned section that has examples
I'll check it out
Thanks for great explanation. @thin stratus So what about this setup? The player pawn has a health Actor component (which is also used by creatures and such). The component has a health float value which is updated by server with OnRepNotify. In rep notify we call the event dispatcher OnValueChanged which I guess will fire on the relevant clients? Then we bind to it via GetOwningPlayerPawn in the UI. To me it feels quite clean. No real need for RPC then.
That is correct
I assume you already handle any sort of race condition between UI and Pawn replication
Hmm, you mean if health is updated in very short intervals and some ping
i want to assign a different and random skin for each player that connects to the game. how do i do this. when i do it this way everyone in the game has the same skin.
well that's because everyone run their own logic
so the shuffle in player 1 machine and player 2 machine doesn't necessarily produce the same result
if you want to sync with the same skin, the obvious step is to let server run the logic and tell each player the result
Your local pawn might not be valid on your widgets' Initialize/Construct/PreConstruct functions due to them not being replicated or even spawned on server yet depending on your spawn/possess/HUD logic
So when you try to bind events that resides on Pawn, you might want to bind PlayerController's possessed pawn changed event to try bindings again, if pawn is not valid on your first try
Or if you have a widget that is always on screen and swapping pawns on death/respawn scenarios
True, haven't had that issue yet though. For this case it is only the player HUD which I is only valid as the player is alive. But I Think I will continue with this approach, I really like having the UI as its own entity and mainly listen to events. Not being called from the player pawn class.
is that architecture good for a game with a lot of players?
You mean the CMC stuff?
Unless you wait for 5.4, and start learning Mover 2.0, you don't really have the choice.
No, I mean if you spawn the HUD on the PlayerController, locally, you aren'T guaranteed to have a valid pawn yet
Or your pawn gets destroyed and respawned
What's Mover 2.0? Is that like another architecture just better than the CMC?
You basically want to handle the Pawn Setup via the OnRep pawn of the Controller if possible
Mover 2.0 is Epic's step away from the CMC and its limitations. It uses the network prediction plugin afaik, so it moves the prediction code outside the CMC, and it should be easier extendable
But it will only ship with 5.4 I assume
And who knows what bugs it might have
You'd probably still need to manually implement the sprinting into it
And we have no date for 5.4
Assumption is at GDC
ight
Can you explain the steps a little more clearly, like which events should I replicate and where should I connect them?
Character skin can be a rep notify variable.
- Server decide which skin the character will use by shuffling the array (On server machine only).
- Then assign the return value of the shuffled array to the replicated variable
- OnRep -> Set skeletal mesh
if you don't know how to do that, probably a better idea to read the pinned articles
ty
Okay, so I'm having trouble replicating component references. I've got a bunch of interaction logic stored in its own component, which has references to other components on the same pawn, but when I run two players on a listen server and try to interact with stuff with player 2, UE complains afterwards that the component references are null
Player 1 has no such problems, which implies that for some reason the references are null on the server on the replicated client pawn
Okay I managed to solve the problem by assigning the references from the pawn to the component instead of the component doing it by itself
Trying to replicate an audio component, since the Sound UPROPERTY isn't replicated how can I load in a sound on the client?
I've currently got it so that the owning actor will supply it with SetSound, after loading in a replicated soft object pointer, but I want to be able to check if it is currently playing before requesting the next sound to be played
For some reason, the bIsPlaying bool is replicated so it is blocking me from doing it locally to each player
Don't replicate the audio component
Instead tell the players to play XYZ sounds whenever you want
Or better have them play it on their own without replicating anything, if possible: generally you can run cosmetics like sound based on other gameplay events already happening on players
Yeah, I set the replication off on the audio component and it works flawlessly
Not unreal specific, but what's up with all the awful launches of live service games where no one can login? Why is there such a problem with scaling up server capacity? Helldivers 2 is a good example recently.
now the costumes I have selected appear correctly for everyone, but I think they are selected at the same time so several people can have the same costume. how can I solve this?
Probably should be discussed in #programmer-hangout - but they only expected like 50k concurrent players. They're getting hit with like 800k. The code they wrote does not scale to that amount. It's not just simply buying more servers.
I'm sure @chrome bay can give more concrete issues that happen in a real-world launch with a large playerbase. Things you think work fine end up...well not.
Don't place the logic in the character then as that will run on every single character in the map.
If it's a listen server then you can just add branch and get is locally controlled
But if it's not, then might as well have the logic in an actor that is only in the server
quick question. I tried to implement jumping in the character movement component and tried to change bPressedJump but it didn't allow me. So to confirm, am I doing something wrong or should I just do the jump() and stopjumping() in the character code?
