#multiplayer
1 messages · Page 683 of 1
yes, and its supposed to
if you don't wish to play some effects from a repnotify, include a timestamp, and sync them between server/clients
You know replication has nothing to do with GPU at all, it will only consume CPU and network. And you can see how much replication processing decreases FPS from Unreal Insight
there is no difference between recently changed property and property changed hours ago
changes are not timestamped themselves
and client decides on firing repnotify or not,
Yeah i get that, but the point is whether or not it is fired for events before the client connects
the actor property is changed from the CDO value
when actor first replicates, it replicates all its delta properties in same package
which will trigger RepNotifies, if they are configured to fire
ah okay and then if the value is that same as it was in the CDO, the rep notify doesn't need to be fired
you have one bit of grace there, RepNotifies for changes that happened before the client joined (initial replication) will happen before BeginPlay on clients
(before the client joined = initial replication)
on clients, its PostNetInitialize that calls BeginPlay, and that is called right after the initial RepNotifies
(for replicated actors)
side note:
if you do deferred actor spawning on server
you can set some variables before you finish spawning, before begin play is called
and that allows you not to have to branch the logic on BeginPlay for client and server
as both can then inject some replicated properties and call set/repnotify prior to BeginPlay
makes for much cleaner code for actor that require some data injection at the time of spawning
I'm working on my firing still. When Fire from the client it is only accurate when I'm in view of the server. I'm using predict projectile trace from the weapon class itself. What do you think I could be missing.
Anyone had luck with making dynamically created components net addressable without replicating them?
Need to conditionally spawn some components without replicating them and it'd save a lot of work, they get saved to the same pointer in the same class so i think there might be a way to force it
sup. i've been doing some research on NetSerialize for a struct but i'm not able to find the answer on google.
i'm inheriting from a struct that requires me to setup NetSerialize and i have a TWeakObjectPtr<AActor> TargetActor field that i need to send over the wire. do i just need to write the actor to the buffer using Ar << TargetActor and i'm GTG? or will this have problems deserializing?
About the thing i just asked about. It seems to just work by setting SetNetAddressible() as long as the component name is unique for that actor.
there is a way
normally component is net addressable if it has a stable name on a net addressable actor
you would need to spawn a component on both the server and client (on the same actor ofc), with the exact same name
then call SetNetAddressable(true)
Yep, that works! Good stuff.
@vague spruce i recommend giving the FHitResult::NetSerialize a look
its an excellent example of how to do NetSerialize
as i have it understood, actors that are replicated on clients are proxies. AI are simulated proxies. if something specific needs to happen to an actor on every client, you probably need to do a multicast to all of the server's clients. if the simulated proxy doesn't exist on a client, then the pointer would just be NULL. that's my understanding at least, it's very likely i'm wrong
proxy is just what the engine calls their role
what i mean to say is that the actor is server controlled and all of its behavior lives on the server and is replicated to clients. that's my understanding of proxies within unreal
replicated actor on client is actor like any other, it has a NetGUID that matches the server instance, and an actor channel
right right, it's just another replicated actor
that allows it to send RPCs and get updates to replicated properties
many thanks on the suggestion to look at FHitResult 👍 huge help
How can I optimize pedestrian NPC on open world multiplayer game?
anyone has an idea ?
Hi all, I packaged development server and launched in my local machine and when I join using open 127.0.0.1 from my editor then I can join the game hosted on the local machine. However when I built the development apk and try to connect using open 127.0.0.1 or 192.168.0.1, I cannot join the server from my android. My pc and android are connected over same wifi. Why I am not able to join?
I need help please someone. Stuck on this since more than a week
I can't move forward unless it is solved
It would be great if someone can guide me to get through the issue I am facing.
I'd suggest 2 things.
Firstly, make a windows client package and make sure that can connect to the server. Ideally, try it from a second machine on your LAN.
Secondly, inspect the logs on the mobile device and the server for anything suspicious.
There are no logs for the android as I haven't connected to the server yet.
I guess the issue is port forwarding.
Can you help me with that/
?
Any ideas how to get windows client to connect linux dedicated server.
Client error message UEngine::BroadcastNetworkFailure: FailureType = NetChecksumMismatch hints that game in server and client missmatch but full rebuild(s) did not help. Everything works agains locally run windows server. Linuxserver is crosscompiled on windows.
It doesn't matter if you've connected, you need to start diagnosing the problem, I'd suggest starting with the 2 things I mentioned.
why isn’t the client possessing the pawn that it is supposed to be?
is it intended behavior for the "skip owner" replication not to skip the owner if it is the listen-server? That's what I notice when using this condition
If the owner is the listen server, then you're setting on the server anyway.
Are you able to show some code as to how you're possessing the pawn?
Ohh okay thanks! I was thinking it meant "run condition" vs "replication condition" moreso (the server isn't replicating to itself in the first place!)
@gaunt cliff is the new inventory item not replicated somehow? If so why bother with a second message over the network, can't you trigger things client-side without your broadcast event?
No its replicated
I'd like to update the UI based on the inventory
if you add a new skill the icon and info pop up in the inventory
afaik UE4 doesn't have reactive programming
so watching for value changes isn't possible
however broadcasting them is the solution
but for some reason, trying to broadcast them (even with a UFUNCTION(Client, Reliable) ) doesn't work
it only prints on server
Run some code on Begin play, run some code in a variable's onrep... You don't need to send the info twice
Not sure why you're having issues with what you did try though, you'd have to send full code I guess
its on RPGCharacter.cpp
can I DM you ? @hoary lark
i use AController::Possess
i checked again and the pawn is being possessed by the controller
but i can’t seem to move the pawn at all on the client now, any ideas?
Anywhere I can read the 'separate process' PIE session server's console output before it crashes and the console window closes?
Yes, PIE advanced settings -> network emulation settings
You can add this line to DefaultEngine.ini
[PacketSimulationSettings]
PktLag=120 ;Ping
Or console command:
net pktlag=120
@vernal cobalt You need to call possess on the server version of the controller. If you're doing that, something is off with your input bindings.
If it's a turn based game, sure. If it's realtime, anything over 140ish is probably pretty bad.
I wouldn't intentionally kick them. If they want to try to play at that latency, let them I suppose. Intentionally kicking them is going to be bad business. You're going to see reviews popping up like "Devs enforce strict network, I have to pay $100 a month in my area to get good enough net to play this game"
with dedicated servers the only person who will be suffering is the client (unless the server is having issues..)
I mean. 1 to two seconds is a mildly different story. Even international latency is like 350 at it's worst through satellite relays. Two seconds is reaching some standard timeout ranges. Serious gamers aren't going to care, as they'll make sure their net is good enough to stay < 30-60. Average players can stand up to 100ish. 150 is kinda pushing fast paced boundaries. 200 is pretty much unplayable for fast paced games, but is perfectly acceptable for anything turn based, or less APM spamming required.
the player will d/c automatically if it gets too severe, engine handles that (you can adjust those timeouts/limits), but i would not kick someone for having a bit of lag.
I'm trying to change a Value of a Actor from Player i was actually trying with a array but it didn't worked so i decided to test a single value and it still don't work
tried using GetRemoteRole() but it didn't worked either
Think you meant to use something other than < ROLE_Authority
@sinful tree that would fail tho
nvm was thinking netmode, role has auth last..
just check if (GetNetMode() == NM_Client) { ServerRPC } else { blah }
also ensure your actor is replicated, and its owned by the player issuing the server rpc
i am of two minds about that, HasAuthority() is simpler and faster to type in, ROLE_AUTHORITY has different syntax coloring which makes it easier to skim through later
tried this and also HasAuthority() but it still don't work
does the client calling the RPC own the actor?
you do know about ownership right?
didn't knew about that
how would i do that? the actor needs to be placed on the level before the game starts
on the Editor
did something like this gonna test later
it's not good for multiplayer but i will just test
?
Hey all, so I'm having a problem with CMC and Client Prediction. What I'm trying to do is a jump with a buffer with the game running on 60fps.
The way it works is if you release jump within a time frame, 5 frames in this case, you would do a low jump at the 5th frame. If you don't release in that time frame you normal jump at the 5th frame.
Currently whenever I jump, regardless of the type, it will hit the 5 frame mark on the client, but never reach the server and stay on frame 4 so no jump and client corrected.
I haven't tried using a timer yet (though I may have too) because I want it all in tick.
any help would be greatly appreciated
Is there a good tutorial on advanced sessions Find Sessions
What is the simplest way to let two people on internet connect for 1v1. Do I need to setup an amazon gamelift (or similar)
I am wonder how this works at a high level. For example, does Epic or Steam run a free server everyone can connect to. Otherwise how do you do p2p even without specifying IP addresses
use Steam Lobbies or EOS Lobbies
Steam Lobbies are easy, and steam does nat punchthrough
i don't know much yet about EOS.
what information from the player is needed? just add those to events parameters
My question about NetChecksumMismatch seems to be asked here several times, but not a single answer 😦
why it is need to know?
for scores?
why just not destroy sword and then create one ?
Hi, I am using wheeled vehicle and they seems to jitter when playing multiplayer. One possible solution is smoothly interping the location and rotation when new replicated movement is received to the client. So is there a function which I can override to do this stuff before the movement is updated on the client?
There is a virtual function called PostNetReceiveLocationAndRotation() but is not called for simulating physics. Is there an alternative ?
He is a wheeled vehicle
That's not my issue.
anyone?
Is this node true on the server too or it is true only on owning client/autonomous proxy.
local multiplayer how to make second xbox 360 controller attach to second create player
if you play as listen server then this node will be true for the server player. Will return false for other players when called on server.
Can you elaborate what you want?
I followed this tutorial https://youtu.be/3lN2eZIgAQ0 to spawn two players
UE4 / Unreal Engine 4 Multiplayer Playlist:
In this collection of videos, we will cover setting up a project for both local and networked multiplayer projects.
This Video:
In this video, we create a flexible player spawning system for local multiplayer games.
Links:
Udemy Game Prototype Course Coupon: https://www.udemy.com/unreal-engine-4-lear...
It spawns two players. However, only one of my two xbox controllers works
for local multiplayer - two player actors controlled by two xbox controllers
actually it's really weird if i alt+tab back and forth then it works
/**
* [server] adds a projectile to inventory
* @param ProjectileClass Projectile to add
*/
void AddProjectile(TSubclassOf<ARPGProjectile> Projectile);
/**
* [client] used exclusively to broadcast Projectile Addition to Inventory
* @param ProjectileClass Projectile to add
*/
UFUNCTION(NetMulticast, Reliable)
void BroadcastProjectileAdded(TSubclassOf<ARPGProjectile> Projectile);
cpp:
void ARPGCharacter::AddProjectile(TSubclassOf<ARPGProjectile> Projectile)
{
if (Projectile && GetLocalRole() == ROLE_Authority)
{
Inventory.AddUnique(Projectile);
}
BroadcastProjectileAdded(Projectile);
}
void ARPGCharacter::BroadcastProjectileAdded_Implementation(TSubclassOf<ARPGProjectile> Projectile)
{
OnProjectileAdded.Broadcast(LoadProjectileDataFromClass(Projectile));
}
void ARPGCharacter::RemoveProjectile(TSubclassOf<ARPGProjectile> Projectile)
{
if (Projectile && GetLocalRole() == ROLE_Authority)
{
Inventory.RemoveSingle(Projectile);
BroadcastProjectileRemoved(Projectile);
}
}
@violet sentinel sorry for the ping, just making sure you're here 🙂
so your broadcast_impl is not called on clients?
nope its not, only on server
set breakpoint there, check if the method is being executed twice (one on server, second on client)
also broadcasts must be called from server too so you can move it under authority check in AddProjectile
Add_Projectile is called from SpawnDefaultInventory(); which is server only function
void SpawnDefaultInventory();
void ARPGCharacter::SpawnDefaultInventory()
{
if (!HasAuthority())
{
return;
}
int32 NumProjectileClasses = Projectiles.Num();
for (int32 i = 0; i < NumProjectileClasses; i++)
{
if (TSubclassOf<ARPGProjectile> NewProjectile = Projectiles[i])
{
AddProjectile(NewProjectile);
}
}
// equip first projectile in inventory
if (Inventory.Num() > 0)
{
EquipProjectile(Inventory[0]);
}
}
is it called early?
there may be the scenario
server spawns actor
server makes inventory
server broadcasts inventory
client yet to create actor so nothing happen
client spawns client actor
...
thats why broadcasts are bad choice for that
making field replicated would be preferred
with FFastArraySerializer if it is a complex struct
its called on BeginPlay
doesn't matter
client would initialize much later
never trust beginplay in mp
you can add a log in beginplay to see when client actor is created
and in server init inventory
you would most likely see server:onconstruction server:beginplay server:spawninventory client:onconstruction client:beginplay
just to be clear, I plainly use UE_LOG and it will prepend server/client right ?
yeah you can
i do own helpers for current world name or you can use Kismet PrintString that has instance name automatically added
LogTemp: Warning: Construct
LogTemp: Warning: Begin Play
LogTemp: Warning: Spawn Default Inventory
LogNet: Join succeeded: DESKTOP-XXXX
LogTemp: Warning: Construct
LogTemp: Warning: Construct
LogTemp: Warning: Begin Play
LogTemp: Warning: Spawn Default Inventory
LogTemp: Warning: Begin Play
LogTemp: Warning: Spawn Default Inventory
I suspected the first 3 messages are server, the other messages are client 1 and 2
so you are most likely right
tldr: use Replication for sending STATE, use Broadcasts for sending EVENTS / Actions
and inventory is obv a state
hummmm
Okay let's go to a different part of the code where the issue is the same
however it has no relation to events happening in begin play or not
void ARPGCharacter::ServerHandleCooldown_Implementation(TSubclassOf<ARPGProjectile> Projectile)
{
// if neither LastFired OR Cooldown is set, just return true and it will be set after projectile is shot
if (!LastFired.Contains(Projectile) || !Cooldowns.Contains(Projectile))
{
bCanShoot = true;
return;
}
float ProjectileLastFired = LastFired[Projectile];
float ProjectileCooldown = Cooldowns[Projectile];
if (GetWorld()->TimeSeconds > ProjectileLastFired + ProjectileCooldown)
{
bCanShoot = true;
OnProjectileCooldownEnd.Broadcast(Projectile);
return;
}
bCanShoot = false;
}
OnProjectileCooldownEnd is never broadcasted to clients
which is an action/event by your definition, so this use case of delegates is correct
whats the declaration of method / ufunc
UFUNCTION(Server, Reliable)
🤦
are cooldowns long?
I tried 2-5 seconds
well, you found why it is not called on clients i assume
but if I was making it i'd have it on both client and server:
on client side as cosmetic timer that locks use button or whatever (check cooldowns on server on attack action)
on server: if shot set server timer that locks the action and trigger client cooldown via broadcast or direct RPC
or/and by replicating bool bCanShoot
well. the event is called on server
and you need for client to do same?
ufunction(client,reiable)
void ClientNotifyCooldownEnd(TSubclassOf<ARPGProjectile> Projectile);
ClientNotifyCooldownEnd_Impl(TSubclassOf<ARPGProjectile> Projectile) { bCanShoot =true; OnProjectileCooldownEnd.Broadcast(Projectile); }
after
OnProjectileCooldownEnd.Broadcast(Projectile); // this would be the regular server call
add
ClientNotifyCooldownEnd(Projectile); // this will call on that client
so that exact client will receive notify
instead of broadcast that will go to every client
playing around with it it seems that other broadcasts are working
the only issue is the one with begin play
where would I call SpawnDefaultInventory to avoid the issue ?
nowhere, make the inventory replicated property
I am using the Possess node from my player controller to allow a player to take possession of an already spawned ship. Running a custom event that executes on server. It allows my player to possess the new pawn and move around but none of the other clients see the new pawn move. The ship pawn is set to replicate.
It's a pretty simple setup and there seems to be a lot of arguments out there about the right way to do this.
is it spawned correctly from server?
Well it is placed in the level from the start and other clients can see it. They just never see it move when the first client takes possession
does the pawn have "replicate movement" checked? what movementcomponent it using?
so FloatingMovementComponent ? it does not have replication support afaik
you need to implement it
Oh... well that's unfortunate. Also, not mentioned anywhere I could find
Weird. It seems like a very common thing to want to do.
pretty much always implement own movement component for anything other than Characters
it isn't really much
either that or try using Controller location/rotation
or make user input handlers send rpcs to server with movement commands (depends what game is)
Well I'm not that well versed in Unreal so it might be more work for me 🙂
To be fair, the movement controller wasn't really doing it anyway. I am having the player control a spaceship but I want the movement to use acceleration
I'll try to look into rpcs and controller location/rotation
then you definetly need movement component
Which does not support replication?
Or is that just the movement component from the defaultPawn?
is PostNetReceive called before or after replicated properties are set
I think I found a jitter issue with all rotating replicated movement physics objects. Is anyone able to confirm this?
Physics isn't deterministic. So client will almost never be identical to server. So if server replicates a new state often, it'll make the client look like it's jittering.
I know, but it shouldn't be getting out of sync a couple times a second just by rotating
There's no jitter when it's just moving forward
If you're really intent on replicating physics objects, then make a struct of Location, Rotation, Angular Velocity, and Linear Velocity. Interpolate these values from client's current to the server set replicated values on tick. If it's too close, set it explicitly instead of interpolating. Doing this will allow you to replicate less changes, even as low as maybe 5-10 times a second, and will keep client pretty much in sync of with server.
This will give the client a visually similar experience to the server, though it'll still lag behind of course. You can optimize by disabling tick on the objects that aren't moving, and enable tick in the OnRep.
I've actually got that working as my backup solution, it's just not ideal as it really does lag behind enough that it's noticeable when pushing objects
At least with the way I've coded it, as it uses a short buffer so there's no stutter
Realistically, you'll probably have slightly better gameplay code with a projectile component.
I hadn't thought of that
It can be pushed and bounce in a similar manner to a physics object.
Is there a way to set how long it takes for the client to timeout from the server?
Semi sure that's an ini file setting somewhere.
Vague google search says to set the ConnectionTimeout value in DefaultEngine.ini. So the following for 10 seconds I think?
[/Script/OnlineSubsystemUtils.IpNetDriver]
ConnectionTimeout=10.0
ye i found that link too, default seems to be 60 seconds tho which seems a bit weird
im trying to debug some timeout issues and a thread says that you need "networking" and "sockets" as dependencies added, i understand networking but isnt sockets suposed to be included with the "networking"? i mean, u cant have networking without sockets, would not add the "sockets" dependecie make a diference?
What happens if I try to move/rotate a replicated actor on the client-side? Will it do nothing or will it just update on that client until it gets overridden by the replication from the server?
I have a replicated actor that is turning towards a target angle using a RInterpConstantTo. Seems to work fine on the server but on the client it seems to be really choppy. I'm running the RInterpConstantTo code both on the server and the client, so I'm thinking that maybe the reason for this is that the SetActorRotation does nothing on the client, and I'm just seeing the angle update when the rotation replicates from the server.
I think this "just update on that client until it gets overridden by the replication from the server" is correct
Idealy custom movement stuff should be handled on a custom movement component, if you cant be arsed to do that you should try calling the same function both on the server and client as you are doing.
if its not working there are some variables that you can set that might help
but those are on a movement component and you didnt specify what your trying to move even has a movement component
if it does try: bIgnoreClientMovementErrorChecksAndCorrection = false
also
bServerAcceptClientAuthoritativePosition
Hmm interesting. I'm using a PawnMovementComponent so it doesn't have those properties.
If I disable my code from running on the server too, everything works fine. So it seems to be some kind of interference from the server that is messing with the client-side prediction.
saw your graph in #cpp it looks like your rotations are incrementing in 1.4 degree increments (360/256) so my first guess is that you or the engine are simply compressing rotation values down into bytes (I would expect the server is likely to do this before it replicates actor transform to clients), i don't know how or where it does that automatically though
@molten matrix change AActor->ReplicatedMovement->RotationQuantizationLevel
Interesting, I’ll try that! I was thinking the replication was happening when it jumped by ~1.4, but maybe it’s replicating a lot faster and it’s compressed down so it can’t change on the client side until it jumps up by 1.4
Beautiful! @hoary lark , that solved the issue. Thanks so much 🙂
If I spawn an actor from a client, and the actor has replication enabled, will that same actor spawn on the server, so I can immediately start calling RPC's and stuff?
(answered by google, short answer is no spawning on client side if you want replication)
You'll have to send a RPC to server and spawn it there
yeah, looks like it's not generally a good idea to spawn actors from the client due to cheating concerns
hey , guys i got quick one . I want to display username of each player as Render Text . but some how all players displaying username of current playing client
here is a code
why is that happening ?
Is there some simple way to allow character on client to smoothly follow the server location when server updates character location on tick?
I tried fiddling around with MaxSmoothUpdateDistance and NoSmoothUpdateDistance in the character controller but those settings don't seem to have any effect on the movement
What I want is to move my character on the server along a curve and to replicate that movement smoothly to the client
Interpolation ?
Hoping to find something that is more built in to the charactermovementcomponent
Is there a way to clear the movement inputs sent to the server if player is adding movement input while movement replication is off?
hey guys
for a local multiplayer shooting game with 2 people, would you use TCP or UDP?
Well, if you're using Unreal, UDP? Cause Unreal doesn't use TCP
is there any network professional here i can ask him few questions in private about UE4 project ?
Hi, when I was playing multiplayer PIE, then when I possess the vehicle on the client, the vehicle IsLocallyControlled returns true on client and false on server which is the expected behaviour and everything works fine. But now when I packaged the dedicated server and hosted it locally and joined by using open 127.0.0.1, then after possessing the vehicle, IsLocallyControlled for the vehicle returns true for both server and client!!!!! It is really unexpected. Can anyone help me with why this happening?
Because of this my net cull distance is not working properly. Can any one tell why IsLocallyControlled returning true on both server and client when playing over dedicated server hosted locally? On the other hand, PIE as a normal client works all well.
On debugging I found that on local the vehicle is possessed by the correct player controller but on server it remains possessed by the AIController.
I assume the aicontroller should have been automatically unpossessed as I am possessing the vehicle pawn on server only.
if you joined it locally then the client and the server is the same computer
No thats not true.
Play as clients starts a separate independent server behind the scenes.
but you still play it on the same computer, ie the same ip\
You would think that it would still return differently. Since they're two separate applications.
Cause even on the same computer, there are two different pawns, one in the server application, one in the game application.
im not sure, its been a while since I've done any multiplayer
If you are not sure then you should be careful while commenting such things as some new persons might get on the wrong track.
I still think that is true, but anyway, also respect the time of other ppl and don't ask anyone directly
If you still think it is right then you probably need to learn more yet. Anyways goodbye 🙂
maybe, yet you're the one struggling
Haha says the one who hardly have done multiplayer lol.
This is really damn silly! Lol.
id really appreciate if you could stop pinging me, also don't make any assumptions about me
So don't put your butt in when you are not sure about anything. Good day Mr.
Guys. Really. This has nothing to do with Multiplayer anymore. #lounge it, or something.
why do the connected clients keep trying to send the ServerRestartPlayer RPC to the server?
If you’re running a packaged game on your computer to test it’s starting in standalone and when you connect to the server it’s running over lan, but since it’s the exact same IP it’s like a listen server. You need to test with two separate computers using two different IP addresses. Maybe a VPN would be useful here. Also two different steam accounts if you have steam integration.
does anyone know how to call a client function from the server? for example, I want clients to show a menu when HandleMatchIsWaitingToStart is called, but im not sure how to reciprocate that in the clients
Initially sounds like something you'd multicast from GameState.
That or setting the matchwaiting as an OnRep is probably better. Letting client's GameState handle that in the OnRep.
got it ty
hello, when I press the event, I try to notify the server and notify the interaction from the server, so I will ride the wolf, but it does not work, where am I making a mistake?
can be staticmesh components replicated on network individually ?
their transform* ? if they are physics based
You can replicate non AActors but don't think what you are trying to do is a good practice:
https://jambax.co.uk/replicating-uobjects/
I guess multicast is the problem
You need to possess or do other known tricks to control another pawn
can you give an example
Games like Squad (military milsim) just control the vehicle in the player's pawn/character, driver and passengers just attached to the seats and some of their inputs are disabled for movement
When driver pawn presses WASD, the movement input sent to vehicle instead of CharacterMovementController
You either need to possess the wolf or do what I explained above
Multicast is redundant there, you also need an OnRep instead if you want to have persisent state
A late joiner will not see the player is attached to wolf because multicasts are "fire and forget"
But OnRep variables are persistent
no i can already do them
but it doesn't work in multiplayer, it works in flat connection
When you mean 'flat connection' does it mean "offline" or "listen-server without clients"?
The game crashes when I open the onrep variable
yes
Btw check my repo: https://github.com/intaxwashere/basictransformreplicator
i don't know english language
I'm wondering about best practices around updating reference variables on the server that need to be used on the client. For example, I have a character reference in my controller which I use to configure render targets, some controls, etc on possession/respawn. This gets updated via RepNotify to the client. If there is latency or flow doesn't go as expected than things break. Its very brittle obviously. So I added validations for the references I rely on in the client and IsNotValid results delay 0.1 sec and then it retries validation. Only after these validations pass do I do anything relying on the Character ref. This seems to help but also seems hacky. So is there a "proper" way to do this to avoid shooting myself in the foot in the future?
They delays are probably unnecessary. A pointer won't OnRep until it's resolved on the client. Doing this all you need to do is call a single function whenever any of them OnReps. Check validity of all, if one fails, do nothing, if they all succeed, run your setup.
Well the refs become invalid because the actors they refer to get destroyed or the player should no longer possess them - like during a respawn where they get a new character and weapon.
They become "pending kill" or something
So the RepNotify updates multiple times during a respawn event for instance
Having a problem where when I try to open a level with listen in options, it immediately closes and returns me to the previous level. Anyone know what causes this? It only happens in Standalone or Packaged formats
Hey, I'm new to UE, I had multiplayer spawning working perfectly, and then I made a few seemingly unrelated changes, but now it looks like the multiplayer clients and server are sharing the same controller. The game mode has not been heavily modified, nor have I overwritten any defaults except choose player start. Event OnPostLogin has the correct player controller, but it is not being assigned to the client. Is there an easy fix?
What makes you think that the clients are sharing the same controller object? I bet any amount of money they are not.
@dark edge Well I guess I don't know 100% they are, but when I print the name of the controller from a local only function, the same name returns. Also killing one player respawns the other one, and puts the killed player in a state where it's missing a character. The debug panel also shows 4 player controllers, but only two of them (_Player and _Player on server) are displaying much action in the debug
Every client only has one player controller object existing, only the server has everybodys
That's what I thought, but I'm mighty confused as to how both the client and the listen server are printing the same controller name from a local function. I've done something wrong, clearly. I'm currently writing a spawner off the postlogin function to see if I can fix the issue
@dark edge Am I taking crazy pills here or do I just completely not understand how Self works? I've tried printing this in functions that run on owning client and functions that don't replicate. There are two different controller names when OnPostLogin is triggered
Maybe the display name is just returning the name of the class itself, but if I use the same function on the incoming controller from EventPostLogin it returns different names
The names probably get synced up after onpostlogin or something like that. Don't rely on the friendly object names for anything.
Gotcha, is there a better name I can track for debugging?
also, packet loss is measured in %... 40 will obviously be absolute hell because you're dropping 40% of packets. No (realtime) game should expect to be playable under those circumstances.
I test with pktloss %1-3
but 1 is enough i guess?
netpktlag is ~250
But I expect my players to have lesser than 150ping in the game
netpktlag != ping value
iirc 1 netpktlag == ~3.5 ping
someone should correct my values though, i might be wrong
should multicast functions be defined on the server?
can someone explain how I call a function on a playercontroller from the server?
Run on owning client event
okay but what if i want it to be triggered by a server function
like the gamemode transitioning to HandleMatchWaitingToStart
Can you not pass a character reference to a run on server event? I'm passing a character reference and it's coming out blank in the event
Is the character spawned on the server, or was it spawned on the client?
Spawned on the server
Then it should technically work.
You get a reference to the player controller within your game mode and call a run on owning client event on that particular player controller.
Ty
If someone is willing to screen share for a few minutes and help me understand why this multiplayer spawn isn't working I'll send $20 via paypal. I've been banging my head against the wall for hours. I'm apparently doing something incorrectly but I cannot seem to identify what that is
I'll post there
I'm not able to set visibility correctly here on the clients
I'm trying to spawn an item on a player's FP mesh and hide it for all other players
currently with this setup, the server replicates correctly to all clients, however clients do not replicate correctly to other clients, or to the server
hey, thank you for all the help!
No problem 🙂
{
if (GetLocalRole() != ROLE_Authority) {
ServerDash();
return;
}
if (!bIsDashing && GetMovementComponent()->IsFalling() != true) {
//If we havent dashed yet, and were not in the air then we can dash
bIsDashing = true;
ClientDash();
//Stop dashing after our dash montages length ends
GetWorld()->GetTimerManager().SetTimer(DashHandle, this, &ASCharacter::StopDashing, DashMontages[0]->SequenceLength / DashSpeed, false);
}
}
void ASCharacter::StopDashing()
{
bIsDashing = false;
GetWorld()->GetTimerManager().ClearTimer(DashHandle);
}
void ASCharacter::ServerDash_Implementation()
{
Dash();
}
bool ASCharacter::ServerDash_Validate()
{
return true;
}
void ASCharacter::ClientDash_Implementation()
{
APlayerController* PC = Cast<APlayerController>(GetController());
if (PC) {
if (PC->IsInputKeyDown("W")) {
DashDirection = 0;
}
else if (PC->IsInputKeyDown("D")) {
DashDirection = 1;
}
else if (PC->IsInputKeyDown("A")) {
DashDirection = 2;
}
else if (PC->IsInputKeyDown("S")) {
DashDirection = 3;
}
else {
DashDirection = 0;
}
}
GetMesh()->GetAnimInstance()->Montage_Play(DashMontages[DashDirection], DashSpeed);
}```
Hi i have this dash animation code
dash direction is an int that can choose which animation to play
the server is fine
but the client can only dash forwards
dash direction = 0
when it tries to dash any other direction
it glitches and stutters but still dashes forward
dash direction is replicated
without dash direction everything works fine server and clinet can see each other dash
any ideas
help
There a way to speed up RPC calls or this is depending on client ping?
if anyone is wondering i was able to get it working by calling using a bunch of overloads ```
void ASCharacter::Dash()
{
APlayerController* PC = Cast<APlayerController>(GetController());
int DashDirection = 0;
if (PC) {
if (PC->IsInputKeyDown("W")) {
DashDirection = 0;
}
else if (PC->IsInputKeyDown("D")) {
DashDirection = 1;
}
else if (PC->IsInputKeyDown("A")) {
DashDirection = 2;
}
else if (PC->IsInputKeyDown("S")) {
DashDirection = 3;
}
else {
DashDirection = 0;
}
}
ServerDash(DashDirection);
}
void ASCharacter::StopDashing()
{
bIsDashing = false;
GetWorld()->GetTimerManager().ClearTimer(DashHandle);
}
void ASCharacter::ServerDash_Implementation(int Direction)
{
if (!bIsDashing && GetMovementComponent()->IsFalling() != true) {
//If we havent dashed yet, and were not in the air then we can dash
bIsDashing = true;
ClientDash(Direction);
//Stop dashing after our dash montages length ends
GetWorld()->GetTimerManager().SetTimer(DashHandle, this, &ASCharacter::StopDashing, DashMontages[0]->SequenceLength / DashSpeed, false);
}
}
bool ASCharacter::ServerDash_Validate(int Direction)
{
return true;
}
void ASCharacter::ClientDash_Implementation(int Direction)
{
UE_LOG(LogTemp, Warning, TEXT("Direction were dashing is %d"), Direction)
GetMesh()->GetAnimInstance()->Montage_Play(DashMontages[Direction], DashSpeed);
}
bool ASCharacter::ClientDash_Validate(int Direction)
{
return true;
}
hello, I have a fast array property and set the array item value at editor window, but when game start, it will not replicate this item if changed at runtime
so , does fast array can only replicate items that are generated at runtime?
Hi guys! When a replicated actor is spawned on the client, all the replicated values will be available before the client fires begin play, does a replicated component do the same? I'm having some trouble accessing replicated values when the component fires begin play
Don't rely on stuff being available or not at beginplay. Beginplay is just an event that runs on the machine when the actor is ready for play. On clients this can run on the same actor multiple times based on relevancy. Replication can happen long before or long after Beginplay for a bunch of reasons. If you have things that need to do things when they're ready, just make a function to handle that based on whether it's ready and valid. Call that on Beginplay and OnRep. Now no matter which event happens first, your thing will be ready.
Thank you!
You could calculate orientation by velocity
That way you dont pass anything with server rpc
Since velocity variable is already replicated
Velocity also calculated based on player input
Wondering if anyone can help shed some light on replicated moving platforms - I've got an elevator - and all the replicated features work, however I had to do a lot of voodoo to prevent the character from jittering all over while riding it. Now they just slowly sink towards the floor, and then back up again towards the later half of the ride.
TLDR; Is there a good way to sync the movement of a moving platform and the clients?
I'm not certain for Unreal Engine as this is something I want to look into... but I believe there is something called "early mover physics"? I'm not sure if its a general term but I've heard it used in Halo modding videos to explain why everything is so smooth on things like gondolas, elephants and scarabs.
I've heard people in Unity just setting the larger moving object to be the smaller ones parent... so like if a player steps onto a moving platform, the player is set as a child of said platform. Could try that?
I have no idea how effective that would be for replication though.
I'd have to make sure that the parenting/de-parenting is pretty seamless in order to not make it obvious - but I can certainly try it. I also thought about simply attaching the pawn to the elevator car as well
I have a slightly abstract question around start-of-game logic/setup. Here's what I want:
- When the game starts, it sets up some stuff around the level dynamically for two teams, creating actors appropriately and linking things between them.
- When a player joins, they will be assigned to a team and they should ideally figure out the references between the previously created actors. Hypothetical example: Each client should know of the dynamically created rooms, and each client should know of the traps in each room.
I have a solution right now that semi-works. In BeginPlay on my GameMode subclass, I set up the level and create the actors. As part of this process, I also set up the references between objects correctly. Instead of having these references calculated on the client too, I replicate them. On PostLogin, I calculate the team and assign it to the player.
This has two major issue that I've encountered so far:
- Replicating these references is a bit silly. They never really change and every time I add things to this startup process, it usually fails for a while because I forget that I need to make sure it's replicated. It could just all be done deterministically done on the client.
- If I switch from using a standalone server to using a listen-server, the game breaks. This seems to happen because in a listen-server PostLogin is called before BeginPlay on the GameMode. This is an issue because assigning the player to a team relies on some things that are being set up in BeginPlay.
So I guess what I'm wondering is: What is the best way to set this up. I think maybe I'm looking for two things:
- A place to put initialization logic that will run before PostLogin for a listen-server.
- A good way to kick off the "Figure out how things are connected in this dynamically created level". I could send an RPC in PostLogin, but I'm worried that the actors haven't been replicated down to the client yet at that point, and I don't want to create a race condition.
They should. It'd be the same thing as a replicated StaticMesh asset.
I'm not sure why all those various actors are referencing one another ... You are probably missing out on a use case for a manager to handle the dependencies that you have created - would need more info to help you properly on that one.
On the order of things and RPC question you can have each player send an RPC on BeginPlay, so the server knows when they are ready for receiving
@verbal tendon , regarding the RPCs: Sending an RPC on BeginPlay wouldn't necessarily mean that the client knows about all the created actors. The flow goes something like this:
- Game starts
- Server creates a bunch of actors
- Once all the actors have successfully replicated over to the client, the client calculates some stuff.
I'm not sure how to properly have the client wait until all the things have been replicated over.
This is for the RPC actor. All actors that are params of the RPC ... There is a config option that will delay RPCs which have params that haven't been fully replicated, until they are. So if you have a limited known set that's how you could do it. Server knows how many actors it has created - have the client count locally and when it's ready, send RPC to server.
Those are two potential approaches, there are others. The best solution depends on the specifics of your setup.
That's really useful, thank you!
I'm interested to hear more about the manager use-case you mentioned. I'm not concerned about the actor references, but maybe I should be? It's essentially just references like: Room A has a property with the list of e.g Traps in that room. Each trap has a reference to the room it's in.
Will your game support hotjoining or save/load for play sessions?
If I have a TArray that is replicated, and each element is a USTRUCT, and I am not using fast array replication, will each element struct be sent completely (all members) whenever any of its members is modified?
Good question. I haven't really thought that far ahead. I would imagine no, but maybe hotjoining? I'm guessing if the answer is yes, it would complicate things down the line since I'd have to make sure things get linked together properly when you load a session or when someone hotjoins.
hi calling restart player from gamemode is duplicating my ui how do i fix this
Check if it's valid before adding it to viewport
cant do that since the ui still uses info from the dead player
ok so
i have this code
my health bar and inventory remove from parent
everything works and replicates
however
the client gets duplicated ui
the server does not
whats happening
the clients ui doesnt seem to be destroying
how can i do that
If the call to remove from parent is running on server then that's probably the issue
Tell the client to also remove the UI
The server shouldn't really be doing anything UI related anyways unless it's locally controlled
ty that guided me i got it working with a client rpc
Guys what is the ideal ping for lan dedicated servers in ordet to deploy it to aws??.Recently I hosted a free tier server on aws and it was laggy.On editor testing the ping says it is 10 ms for lan dedicated servers.Is it ideal??
Plz tag me if you are answering.Thank you
Hi. I am implementing a feature where if players get frozen, they can mesh keys to get unfrozen. Each key click will reduce the freezing time by 0.1s of otherwise 5s. Should I send RPC for every click? What could be a better approach?
Hello folks, has anyone been able to package a dedicated server in UE5 EA, and if so, could I ask some questions of you? I've been having an issue with it. I made the cs file for the target (ProjectServer.Target.cs and changed the info accordingly to set to server, did the same thing for client (ProjectClient.Target.cs). Regenerated project files, then did a build for each (Windows>Development>Server and Windows>Development>Client). Client packaged properly, but server is just giving me the generic project single-player packaging.
Seems to be an issue other people were having. I can't find an up-to-date workaround. Someone had gotten it to work by altering some engine code, but when I looked at that code on my version it was totally different. I'm wary of changing engine code unless I can get a walk-through.
Dedicated Server Builds aren't supported yet. My advice would be to wait until they are. Can you do that, or is htat not an option?
Hey guys . ASAP !!! my project manager will beat my ass!!
When player presses T button . i want to widget popup and depending on which button player pressed , charcater needs to play animation and every other client must see it
Even if i am changing animation variables on Server side . animation gets played only on client side and not replicated to another clients . Why?
here is my stupid code
Hey guys, I am fairly new to UE4. I was working on a small multiplayer game when I faced this issue where I am able to press movement controls from client, nothing happens in the client but the client player on the server screen moves. Not sure what's causing this and the error I am getting is "LogPawn: Error: EnableInput can only be specified on a Pawn for its Controller". Didn't find anything on the internet that helps with blueprints.
Show the notify too
Make sure you auto receive input from player 0 in your player controller, and auto posses player 0 in your pawn blueprint
replicated UObject or AInfo?
Don't try to replicate the animation itself, just replicate some data that can help you pick the animation. Typically an enum or int
@oak oracle wait why are you trying to do networking inside a widget. Don't do that
Do the networking inside the character or PlayerController.
ServerPlayAnimationOnce or something like that.
Is there a better way to sync the movement of a moving platform and the client's pawn? I've smoothed it out the best that I can, but still sinks/rises until the destination is reached. Previously they were just jittering everywhere.
That's all dependent on how you're moving the platform and pawn around.
Currently - the elevator itself is using a 'move component to' as it allows me to dynamically set the time based on the distance between floors. It all works, as far as moving and replication, there's just some odd behavior from the clients perspective during the move. I've tried several things to get the pawn to move along with the elevator, to no avail. Oddly, in some of my tests, the pawn ends up on top of the elevator and, during that ride, none of the aforementioned glitches seem to be apparent - just when they are inside. I checked the collision, and all seems good there.
The pawn logic for moving it while inside is what I'm trying to work out now to get rid of the sink/rising behavior while the elevator is in motion.
I have 2 players , 1 host 1 client, I want my client to join with its preselected stuff, Weapon , color .. etc , How is this made ?
@pastel escarp that is a very broad question, and there are 100's of ways to do it.
Is there an example I can look into ?
hi the default player limit for multiplayer is 16. I read in forums to add in game under the script tag maxPlayers = required value, but it didn't help.
I restarted the editor but didn't compiled it. Do I have to rebuild from solution after changing config file? Or simply is adding that line to defaultgame.ini enough to increase the default max 16 player for dedicated server?
no
but it could be overriden
in your gamesession
or via a CVar
static TAutoConsoleVariable<int32> CVarMaxPlayersOverride( TEXT( "net.MaxPlayersOverride" ), 0, TEXT( "If greater than 0, will override the standard max players count. Useful for testing full servers." ) );
Someone here who is working on a multiplayer game in unreal c++?
I have some trouble with the pitch replication from my fps player.
If I look down and then up again it will turn around to the other side, but not locally only in other player sessions
I use the decompress formula
If I use instead
RemoteViewPitch × 360.0f / 254.5f
It works...
And if I use the decompress function from FRotator... It is going crazy if I look down.
(The decompress function use / 256.0f ..... Why?)
I also tried with clamp... I took a look into the unreal tournament source code. They also used clamp (-89, 89)
I was using 0,360
So I will try this later, but can anyone explain me what is going on?
Would anybody be willing to hop in a VC to help me with my problem?
I need help transferring arrays from player character to player state.
Someone can help with one simple question:
According to the guide, I created binds for building cubes relative to the character and because of this, in multiplayer, other players do not see my cubes, and I do not see their cubes. The problem is that the cubes are created relative to the client. I want to ask where I can drag all this to work in multiplayer?
I took ThirdPersonCharacter and in EventGraph I did all this, in a single-player game the cubes appear and I can even touch them, but in online the cubes are phantom and the server does not see them
Show the spawn code
let me try this
Not sure if anyone has seen this before, or if it's too vague. I'm trying out running my game from the editor with 2 players. However the PIE player gets stuck as a spectator.
Digging into why this is happening, I can see that ClientRestart_Implementation gets called for both players but it seems the first time it gets called for each player, NewPawn is null because it hasn't been replicated over yet. This causes it to retry and at this point, it works for the other player but not the PIE player. It seems to call ClientRestart again and the NewPawn is still null, so it fails and doesn't retry.
Sometimes when debugging with breakpoints, it seems to work. Probably because I'm putting the breakpoint in such a way that the replication has time to finish before the retry.
I haven't messed around that much with the beginning-of-game networking stuff, so I'm not sure what I could've done to make this happen. Wondering if it's something that others have run into as well.
Actually, it seems like it keeps retrying again and again and again, even minutes after. I see it calling ClientRetryClientRestart(GetPawn()); on the server, at which point GetPawn() is properly defined. But when it hits ClientRetryClientRestart_Implementation(), the pawn parameter is null. I'm guessing that means it's not getting replicated over for some reason? Not sure why the pawn would successfully replicate for one client but not the other?
thats server corrections
meaning the server and client are fighting for position
client is not where server thinks it should be
There's a cvar that you can change to have it draw debug capsules so you can see when corrections happen
p.netshowcorrections 1
Take a look here, there's more info: https://ikrima.dev/ue4guide/networking/debugging-tips-tricks/
Gamedev Guide: Programming with Unreal Engine, Houdini, Math, & Graphics
Uhm. I always just use the editor console tbh. But I'm pretty sure can add the cvars as part of program startup arguments ( I also don't have Rider 😄 )
But you can also just use the config files if you need something on more permanently and don't want to fiddle with it too often. It matters which file you put them in, so it's a little more hassle to set up
Hi, in a listen server with only one client (the listen server) the remote path of switch has authority is not called. Is that the correct behavior? My thoughts were that the listen server acted as a server and a client, so that both paths would be called.
My understanding is that a listen server is authoritative, and therefore will go down the authority branch. It would not go through both.
that is indeed what I am seeing.
That's why it's labeled authority/remote rather than server/client.
ok, so I need to test for server or client instead of that node then
When ChangeName is run in the gamemode, on PostLogin for instance, does that update the playerstate in gamestate's playerarray for that player?
I'm having a tough time verifying its actually getting updated because i'm not seeing any printstrings from the server process in my output
and my client's player state doesn't seem to be getting updated
Push xD
I hate discord for this kind of questions... (Support)
Questions get lost after other posts...
My understanding is that GameMode can update GameState, including PlayerState which is in GameState's PlayerArray. GameState is replicated to all clients so they should be able to look at PlayerArray to get current PlayerState of themselves as well for all other players
Yes correct
Correct. Well. Partially. PlayerArray is not actually replicated. It's locally maintained by clients. When a PlayerState arrives on client, it adds itself to the PlayerArray in GameState. But pretty much, yeah.
so if server changes PlayerState of a player I'd need to handle that manually?
Changes in what way?
When I run ChangeName gamemode function during PostLogon event
Oh, that should be automatic. PostLogin is server so it'll replicate to clients through the PlayerState.
ok, ill keep hammering away - something else must be going on
I did this for some AI stuff, one sec.
@soft dawnI call mine in HandleStartingNewPlayer_Implementation Override. I'm also creating the AI there though. Just waited for PlayerState to be created and called SetPlayerName on the playerstate.
ah, maybe I'm trying to update PlayerState before its created.. I don't get any errors but ill try to validate that before changing name.
Thanks for the help
Do you happen to know if its possible to get OptionsString of a connecting client? Client uses Open Level to connect to server and sends some parameters. I don't know how to actually access these on the server though. OptionsString inside GameMode is what the server started with so only helpful when using Open Level on server.
@soft dawn Uh. That's a good question. Trying to track that down. If I'm not mistaken, you might be able to call GetWorld()->URL
Only sort of sure that's set on clients..
Or wait. I'm not sure how I ended up on that.
Ah. URL.Map seems to be the string passed in to the OptionsString.
if the actor has not replicated in time
then it will be nullptr
we used FastArrays to get around this
should be
if the actor is replicated
maybe they are not relevant (too far away from player?)
maybe try setting them always relevant
to see if they show up
who
whoa
why you using NewObject on an actor?
Actors should never be created via NewObject.
That'd certainly explain why it isn't being replicated.
Actors exist in the world, period. Trying to work around that by using NewObject will result in all kinds of issues, including the actor not replicating because the world doesn't know about it.
When using Steam Sessions and Advanced Sessions with a packaged game, its works fine in the editor standalone and when building with the shipping configuration but doesn't work when I select the development configuration. I have no idea what's causing this and have tried a couple fixes online. Any help would be greatly appreciated.
Funny enough I figured out how to make it work! If anyone is curious I can share.
Edit: I had made a reddit post about it and then resolved the issue myself and broke it down here:
https://www.reddit.com/r/unrealengine/comments/rr2hw8/cant_build_dedicated_server_in_ue5_early_access/
I tried your suggestion it didn't work but I was able to fix the issue by setting up RPCs differently. All I had to was call the run on server RPCs from the client which would in turn call them multicast RPCs which would then trigger the movement in all clients. Thanks.
Hi guys! I see that push model requires enabling through setting the CVar. Is there a way to permanently set it to true?
Hi all, I would like to make a online fps game on mobile with Unreal Engine. I have good knowledge about Java and Cpp for game server. But in unreal engine, I saw another dev using Steam. What should I choose for my game to get better performance ?
How is it possible to call an interface function that is running on the server(say a GameInsatnce), called by a client(a Widget). How is it possible without using RPCs?
Yep, I already tested that and it works. Though I'm amazed
GameInstance is on both client and server, so what you saw is the local version ( client or server, whichever you had ) execute it
Yes I think this is working because I'm on a listen-server. Thanks guys!
this is exactly what Run Configurations are for ;) you can clone them and tweak their arguments in Program arguments field. Or, you can use EzArgs plugin for that. it'll add program arguments field to your toolbar
Can someone help me with this? https://forums.unrealengine.com/t/dedicated-server-crashes-when-vr-client-joins-due-to-oculus-handtracking-check/269101?u=rpgamer777
I’m working on a VR multiplayer project that relies on dedicated servers, and whenever I connect to a dedicated server with a VR player, it crashes. I’ve done this test with Desktop clients connecting, and there’s no issue. Also tested this on other projects and even tried using Oculus’ source build of 4.27. The way I found that it was related...
Probably need a callstack.
I set a variable to replicate initial only but it seems to be replicating every frame as if the condition isnt working. am I doing something wrong?
What is the code setting that value on server?
🤦 forgot to show it
just interps from 1 point to another and sets location
That's odd. There may be BP fuckery involved. It's weird with OnRep stuff. Lemme test.
i remember asking a question about initial only and you answered it as well. it worked as you explained but its not working now. . . . using the same UE version and what seems to be the same debug method.
When you use repnotify, compile the server files again as soon as it crashes.
Still testing. But random fun fact I just noted. BP OnRep doesn't actually fire on Server when variable is changed in an increment node. Only calls on Server when you use the Set /w Notify node. 😄
oh yhea. I just avoid using macros to set variables all together now. it doesnt play nice with replication
What do you mean by compiling as soon as it crashes? Do you mean a debugger build?
you must re-export the server files every time you make changes in the project
@heady python Your client is not ticking right? The Tick is set off by default? That's what I'm assuming from your beginplay.
When the server doesn't see your changes, it crashes and crashes.
I always rebuild both the server and client at the same time.
yes. tick is off and in the video its only being turned on for the server
server is sufficient for updates
What you mean by that?
@heady python Odd. I don't know. I made a pretty simple test of an integer incrementing on tick on server. Client only prints once and never again in the OnRep.
hmm. guess its a weird bug in the engine? ill just restart and tamper with it until it works
I do not speak English, I am confused by the translation, I am probably typing it wrong.
it doesn't work by itself like that
Not following?
Auhority -> multicast remove -> Run on server Run on Server -> multicast multicast-> Now Yes 0
sadly. I recreated your exact example and it still replicates every frame.
i guess ill manually RPC the values to any clients that join the game
I have no idea what that means. We were testing Replication conditions. Initial Only. It was working fine.
sorry i might have misunderstood then :)
Any tips on how I can replicate VR pickups on multiplayer? The positions have to be the same for all players (approx 4). I have tried sending location every 0.01 seconds but I see a lot of stutter on clients
have you enabled replicate movement on the actor?
You guys know any popular databases for storing information like players champions owned, skins, etc? I'm assuming mySQL is used a lot?
Don't know where to ask this question tbh
If you have no experience with databases then you need to start learning one of them. SQL databases are probably easiest to get into for a beginner, rather than NoSQL databases
And if you're going down that route I would advise to look into MariaDB, it's basically the open source fork from MySQL, which happened due to corporate shenanigans
@short arrow , forgot to hit reply, so here's your ping :p
i am using mysql
I can also recommend XAMPP, if you're playing around with this at home. Download here: https://www.apachefriends.org/download.html
Download XAMPP for Windows, Linux, and OS X. Older versions of Solaris are also available.
I'm like 99% sure XAMPP comes with phpmyadmin for you to easily look at your database and manage it, play around with it. It's been many years since I last ran it
Yes 😁
%100 😁
Though I do not know how you're going to go about hooking this up with a UE game, I have never used the two in combination
Socket.io nodejs varest plugin vs :)
You're going to have to investigate a little or get advice from someone who knows 🙂
I added some information to your training, I hope you weren't taken, everyone will benefit :)
awesome thank you
🙏 of course. My database days feel like a lifetime away. I did all of that stuff for a decade, but also haven't used it in day-to-day for half that time since 😁
yeah I'm pretty sure there's nodes for connecting databses with ue right?
and some plugins
but thanks for the guidance guys!
Plugins
But also if you're new to UE and new to databases, take things slowly, one step at a time. Don't try to do everything at once
It's easy enough to play around with PHP and learn SQL while doing this
So I'd advise playing around with PHP+MySQL and UE+BP/C++ separately
and then once you master both over time, and you learn where to combine them then start on that
To use mysql in ue, you must either work with c++ or use varest, mysql plugins. I am currently using a plug-in that I wrote with socket io and node js support.
Yeah I've got some solid years with UE. It's my full time job :) just trying to learn everything I can
Awesome! 🙌 If you haven't done databases before there's a number of things to learn
For the basics when you create a table you always want one auto_increment primary key, int of some sort. The "ID" basically
you gotta read about keys, indexes, how you gotta index tables once you need to cross reference data, like if you have an items table where you have an ItemID but also you need it indexed because you're looking up items for players by player_id that is a column in your table
Youre scaring me 😨
non applicable as I use photon. It's a fundamental level issue here
Interesting. Do you know if my bug above is fixed with photon?
Sorry! I'll stop! I just sprinkled some stuff in there, I'll leave you to it! 🙏
sorry my bad I thought you were replying to me 😅. Got a huge yelling at work on the current bug dont mind me.
at first I was replying to you. I was just thinking that maybe you'd know if photon would fix my issue
I don't know much about photon
oh what is your issue? Oh just read it. In photon it removes the need for building a dedicated server. Your device which hosts the game becomes master client. You have much more control over connection which is also a pro and con (easier connnect to servers but have to manage all errors)
Hi. Spawning Actor on Server does not spawn Actor in Client. Bug I get following in the logs. What could this mean.
LogNet: Warning: UActorChannel::ProcessBunch: SerializeNewActor failed to find/spawn actor. Actor: None, Channel: 2
I am running PIE.
What is the actors lifetime?
Actor is spawned for some time and then destroyed. Both in cpp. If I understood your question correctly.
I mean how big is the some time?
An AbilityTask Spawns the actor on server and then destroys the actor on server when it ends. The task may run upto 20s.
https://pastebin.com/se6jt6hT https://pastebin.com/5AnnNEPL
Above are the links. Actor and AsyncTask are both declared in the same file. On client side task calls Actor function to send the rpc to the server. Where the actor on server then calls the task function. Because async tasks do not support replication, I choose this way. Because I needed to provide some functionality to blueprints. Though other methods may work too. But I am facing this error. And I am thinking this is happening just because I am running it in editor. It will not happen in packaged build. Any help will be appreciated.
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.
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.
@kindred widget i got the InitialOnly working. Turns out if your actors NetDormancy is Dormant to that client, the RepCondition doesnt work properly. After switching it from DormantAll to Awake, the RepCondition works fine. Im assuming this is a bug but maybe theres a network concept thats going over my head?
That's.. Odd Sounds like it was just continually registering as the actor becoming relevent on client.
Is there a way to create a replicated object on both client and server, and then connect them after the fact? I know the usual alternative is to spawn a fake object on client, then replace it once the server equivalent arrives. In my case I have something a bit different where I want to transfer a large-ish amount of data up front, spawn several things from it on the client, and then indicate which objects on the server they correspond to.
@clever plinth I've never personally done it, but there is a way of name stably spawning an actor on both server and client.
Hello sir, is there a way to use the destroy session on the dedicated server, now let me be more descriptive.
If the client gets on an animal and ends his session, that is, if he leaves the game, the character of the client stops, but the character or the animal disappears. I can connect the function I wrote to get off the animal to the destroy session, but first I need to check the session of the session.
Hello, and happy new year to everyone. I have read in the past that listen servers are limited to eight players in UE4, but a few internet searches are giving conflicting information. Is this the absolute limit, or is eight the recommended max for performance reasons?
IIRC there's no hard limit. Just test it out and profile stuff to see where the hard limit is for your game. If it's a shooter game your requirements are different than if it's a turn-based strategy game etc. etc.
There is no hard limit, there is no recommended amount either because it is entirely dependent on your game.
Anyone saying "8 is the max" is either talking about a specific game or just doesn't know what they're talking about.
Quick duckdebugging question:
Linetracing and projectile spawning works fine for my server.
The client's linetrace is being "ignored" and I can't figure out why that is.
The client's control rotation is taken into account but not the look rotation.
Projectile spawning:
What do you mean by "ignored"?
oh let me make a quick gif
thank you all for the information. 👍
Left: client
Right: server
more accurate would be to say: the client's pitch is not taken into account when the projectile is spawned in.
probably because you're not replicating the client's pitch
other than that the projectile replicates just fine
oh
Isn't that part of the control rotation?
I thought that that'd be replicated by default anyway
how would I go about replicating the player's pitch?
seems like this is what I want
ControlRotation is a client local variable. When dealing with it in a multiplayer context you usually want to use GetBaseAimRotation.
it's said to be replicated by default and to be the method used in Unreal's ShooterGame template
I was using the camera's rotation up until now
Pitch is replicated, but yaw is usually not. Yaw is usually guessed from the pawn's current world Yaw value. Roll is pretty much never used by shooters, so Pitch is the only network traffic required instead of the whole rotator.
Rephrasing a question from yesterday: Does anyone have any good ideas on how to debug an actor replication issue with a player's start pawn? I can see it existing on the server side but when the server does a client RPC to ClientRestart_Implementation, the pawn parameter is null.
I'm spawning a bunch of actors in PostLogin on the server and it seems like if I don't do that, I don't hit this pawn replication issue.
I'm out of ideas, and I'm open to suggestions even if it's something like: "Try putting a breakpoint in this method in the engine and go from there"
If I'm not misunderstanding your problem scenario, this usually happens if you send an RPC before that particular actor has properly replicated to the receiving client
Yeah that’s my understanding as well. This is all engine code though and I see guards for this in the code. If it’s null on the client side, it retries the RPC again and again. At least yesterday when I was debugging, it seemed like the pawn never replicated to the client and it just retried forever
So the pawn isn't replicating to the client? I guess that's where you can start looking at?
Right. Is there a good place/way to debug that? I was initially digging into ReplicationGraph.cpp, but I realized I'm not using the ReplicationGraph plugin so that's probably unrelated.
The first place would be to look at is where you're spawning the actor. Is it BP or C++? Essentially if you spawn the actor on the server and it is set to replicate, then it should be replicating on the client. There's no need to dig in the engine source code for that if you haven't made any modifications that might interfere
This is the default pawn that gets spawned automatically by the engine based on the DefaultPawnClass in my game mode. So the SpawnActor call is somewhere in the engine code. I'm working in C++.
The first player that joins gets their pawn spawned just fine. The second player's pawn does not replicate over in time.
And it spawns properly on server?
Because sometimes you can run into issues with player spawn due to collision if you're just using the default, if they collide it won't spawn the 2nd player's pawn
Other easy checkmark is to make sure the class you have is set to replicate properly
You could test if there's an issue with your particular class by simply spawning one after the 2nd player joins and see if it's a general issue with that class or something with the player spawning
That'd be my first goto checklist for eliminating potential causes
Yeah it spawns properly on the server. Actually, maybe I'm completely misunderstanding what's happening. Here's kind of the progressive symptoms of what I noticed:
- The camera/control is messed up for the player and is just stuck at (0,0,0)
- That's because the player's controller is set to spectating.
- The player controller is set to spectating (I think) because it never acknowledged the possession of the pawn.
AcknowledgedPawnis null, butPawnin AController is defined.
So the pawn has been replicated since it's in the Pawn property for the controller. But for some reason I'm still seeing it retry forever because the RPC parameter turns into null on the client side.
Is there a good way to "correlate" actors between the server and client? Do they have some net ID or name that I can check to make sure they match?
Are streaming levels involved?
Nope
Alright. If it's nothing on the easy checklist, can you make a reproduction scenario from scratch?
Create an empty/default project, try to reproduce the issue ( I mean obviously time is a factor here, I dont know how complex your setup is )
I'll try
I'm sorry I haven't run across the symptoms before beyond what I've asked clarification on, I wish I could be of more help
When tracking down those issues, it helps to break things into smaller steps. Forget the controller and forget the RPC, those are all for later. Your pawn isn't replicating, that's the base step. Why?
Once you figure that out, after pawn spawning comes controller possession, and after that comes RPC
Just as a concrete example of what I'm seeing: Even minutes after starting my game, I see breakpoints getting hit in both SafeRetryClientRestart in PlayerController.cpp and in ClientRetryClientRestart_Implementation (also in PlayerController.cpp). On the server side, it's passing in GetPawn() which is defined. On the client-side, the input is null. However I can see that the playercontroller on the client side has a pawn of the expected type so I would expect the RPC to properly deserialize the pawn, unless that's a different pawn.
I'll try making a sample project and see where that takes me
hello, when I use delay in the replication process, I can't get positive results. How can I deal with it. The animation works well for me, but it is transmitted late to the client and server or I cannot transmit regularly.
I've got an interesting issue that I am seemingly unable (Or too tired to clearly think) to resolve.
Chaos Vehicle - Multiplayer (Player controls the driver seat, which has access to input that should drive the vehicle)
Problem at hand:
Chaos Vehicle Controller, no longer seems to react to input given to it.
What I have tried thus far;
- Tried reverting to a singleplayer-control scheme of directly passing Forward/Turning axis inputs to the respective Throttle and turning methods of the vehicle controller
- Debugged to ensure values were being returned and that it was passed to something that wasn't Null or 0 (Turning/forward all provide their respective values)
- Checked whether client was triggering anything or not, or something was possibly overriding the values passed to the server (By adding a branch to check if value is not 0, so that I could manually see whether an input was given or not)
- Confirmed that all events are triggered via button presses and nothing isn't reaching its end target.
What it currently is set to within the blueprint and what the expected result currently is:
We grab from the client the WheeledVehicle(Chaos controller) that is the parent of the driver that the client is possessing
We pass that component along with the input axis to the server request to replicate along all other clients
Result should be that the vehicle begins to move forward, however nothing happens at all.
Assumption?
- Possibly the Chaos Controller itself? As everything else so far connects and has a result, but the chaos controller doesn't produce anything.
- Maybe the way the vehicle or passenger/pawns were spawned in? Shrugs
input axis turning -> Switch Has Authority -> Authority multicast -> remove server
Hhm.. I'll give that a shot ^_^
you know i faced the same problem 🙂you know anyway
Still unable to get it to work, though it might be me not applying what you're saying correctly XD
one minute
As currently my understanding of what I've got is that the client is providing inputs, that get relayed to the server via the "Run on Server" and then "Multicast" in which the multicast gets the input from the client kinda thing
What makes matters even more funny is that an older version of the vehicle I've got does work, as that directly feeds the input to the controller (Which makes me possibly think that it's acquiring the wrong controller? idk)
If you do not notify the server, it will not work, you must first forward it to the server and then to everyone.
That's what I thought I was doing, with the custom event call replicating on "Run On Server"
As the command to turn the engine on does work correctly
yes Server Run On Server Multicast Multicas
or
replicates multicas
That's what I have currently;
Client Input (float) -> Run On Server (command) with float from Client -> Multicast (Command) with float from client -> Input to Chaos Vehicle Method
Isn't it working like this?
Nope
Which is what's confusing me
Hence I thought it'll possibly be to do with the ChaosVehicle component, or how I am acquiring it kinda thing
well, did you check the values with print, does it return float?
Yup
I've done all that, I checked to see if it returns the value I want (a.k.a a 1 or -1)
I've checked whether all clients on the network receive the command from the server when I press any of the keys and they do
It's just that the value seems to just go into the ChaosController and nothing happens, hence the assumption it might be with that
I don't speak English, I don't understand much, but check in repnotify if it works, float is not replicated
You're all good, at least I know that it's not the inputs and how my method is setup that is the issue ^_^
So I'll continue debugging it further and see if I can figure it out xD
sorry i hope you can solve it i wish i could help i am working on vehicle but my project is a bit complicated since it is mobile oriented
I appreciate it, you've helped as much as you could already 😄
And I'm currently just messing around with Unreal, it's my 4th? Day so far now and working on a multi-crew vehicle system and it works so far, but then I had the stupid idea of making it multiplayer XD
multiplayer is simple 🙂 and nice, I'm working on dedicated, no problems so far
I am definitely enjoying how multiplayer works on Unreal compared to Unity so much easier
unity waste of time 😄
Haha, it was alright decent for 2D projects
2 years wasted, thanks to him, it's none of my business, it's not improving
Hmm just remember issue might be with the fact I am spawning the pawns (driver, turret controller) on runtime, which might be an issue as I dunno if I actually do it properly or now so I will try that tomorrow 🤣 (1:27AM here)
Setting GodMode doesn't replicate as I'd expect it to. Only the server is invincible. I have the GodMode bool set to replicate and run an event as Multicast but that's probably not right. Any pointers?
LMAO nevermind! I just have to add a short safety-delay before calling the event since I gotta wait for all players to login
GameMod is something only the server sees
this is weird
this is my quick and dirty (working) fix
and I thought, well I could just do my initializations everytime a new player joins the session like so
but when I remove the Delay the stuff doesn't get applied for some reason. Any logical explanation as to why that is?
Possibly the player array might not be filled yet? I'm not sure so I'm just throwing something
that's very possible!
As you said initially only the server was god mode, but the delay would mean the list has more things
Try see what the player array count is when the delay is there and isn't there
maybe a .2 delay after the array append should fix that
well the player count will be correct at some point because they're being added via onPostLogin. The problem as you indicated could be that it takes more time to fill the array with the new user than to execute the Init... event.
@unkempt walrus you were exactly right! Also, adding a grace period of .5 fixes the problem (hopefully reliably enough)
That "Might" fix it for now, how many clients are you testing that with
the game will only ever be at 2 players max per session
Then that'll do 😂
Was thinking if it was like 64 then it might be more than .5
But hey, if it works it works, optimization and stuff can come later when everything is there 
d love to make the next MMO but ehm... as a solo developer I don't think I hate myself enough to have goals like that lmao
Pfhahah, yeah 🤣
yeah most bugs are features anyway amiright
Exactly xD
But glad that you at least found what the issue was then or supposedly :)
Hello guys I have a basic question about destroying actors in multiplayer.
An actor is calling destroying(self) upon overlap with the player. Why can all clients and server receive this information without telling the server to destroy the actor?
If I call DestroyActor from the Player then I need to call a run on server event to get the same result
Oh nvm I think it's the ActorBeginOverlap event that does some notification job
i don't understand the question myself. thing is going to move, server is going to detect/run beginoverlap, server runs destroyactor, actor goes away. are you seeing something different happen?
(at roughly the same time, maybe sooner, the client is going to detect/run beginoverlap, and run destroyactor, but it's not going to do anything because the client doesn't have authority)
What is the RemoteRole for Authoritative Character on ListenServer
Should be autonomous
You can increase the network priority:
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/Relevancy/
Physics behave different between devices, and usually most code behaves slightly different too because of varying delta times, etc
So generally speaking you need to have independent simulation on each device (prediction) and then when authoritative server data comes back you rollback to that state and then rewind changes
You can also correct smoothly toward the server data
Somewhat painful stuff, but it's unavoidable
I'm wondering, is there any potential issue(s) when it comes to spawning in an actor that's then attatched to a parent actor on runtime within a server?
(Currently, i've got a vehicle that spawns their 'seat actors' once it itself is spawned. However, there might be an issue with how I am grabbing the movement component from a parent object)
Soo.. My current issue:
ChaosVehicleComponent, whenever an input is passed to their respective methods (Throttle/steering/handbreak) none seem to result in anything working.
What's the expected result?
Result should be a server-authorative control
Client Input (InputAxis Turning, provides float value)
-> Sends a request to server to turn the vehicle
-> Server receives the value + reference to controller it should influence
-> Server Multicasts with reference to the controller that it should 'Turn' with value passed from initial client request (The float from InputAxis Turning)
What is wrong?
While the float value does arrive correctly and it all seems to go fine from a networking perspective and giving data
The ChaosVehicleMovementComponent does not do anything with the value given. Is this due to the component not being "Possessed" Directly?
Does the ChaosVehicleMovementComponent have to be possessed for it to work, or can it be done as it is currently set up?
How is it setup currently?
Parent Actor = Vehicle + ChaosVehicleMovementComponent
Child Actor = Driver (Spawned on run time and attached to Parent Actor)
^ Child actor gets reference of their parent's ChaosVehicleMovementComponent to manipulate
Any input would be greatly appreciated, stuck on this and I have no idea whether it's maybe a networking issue, where grabbing a component from a parent that you don't "Possess" is a bad idea or something alike ._.
And apologies for the long post XD
Guys can anyone explain how net cull update frequency work??.I am spawning guns on server.When I am far away they are not getting spawned but when I go near them they are getting spawned which is fine.But if I went far again they are getting disappeared again??.what is this mean??
Pretty sure that's caused by Net Cull Distance
Why it is disappearing??.Once it is spawned what is the need to disappear again??.It does not make any sense??
Cause it culls it?
It's not relevant for you anymore
So but don't you think it should cull only replication instead of visual elements??
Try it out, lower the cull distance and see what happens
Yeah it is working properly with proper net cull.But it is somewhat not relevant.Thanks for response
from my lobby widget i call this when the user changes some settings
in the game state, this is my server-side "gameDetails" updating logic
the first print "setting game details" is called both from the client and server instance
BUT the second print, "setting game details on server" is only called if the host/server of the game clicked on the button.
can anyone tell me why my lobby widget cant trigger a BPI->custom event that runs on server?
First, you should really use base classes instead of an interface in this manner. It's much cleaner. But that's irrelevant. Actual reason is GameState is a server owned actor. Client can only RPC through ClientOwned Actors.
please could you provide me with an example?
eg. click button -> getPlayerController-> custom event on server -> updates uhhh..?
By default only three actors are Client Owned. That's PlayerState, PlayerPawn, and their Owner which is PlayerController. To set an object's Ownership to a client, you have to have a reference to a ClientOwned actor on the server, and call SetOwner on the actor that you want the client to have ownership of. You shouldn't do this with GameState though, since it's the Game's State and should only be a Server Owned Actor. To Allow a client to interact with Server Owned Actors authoritively, you need to let them RPC through an Owned Actor. PlayerController for instance. Then on the server's version of that player's PlayerController you would GetGameState->SetGameDetails.
On the same machine, yes. This doesn't have anything to do with interfaces.
Interfaces are just another method of member access of an instance on the same machine.
alright - generally i thought that if i can reference something i can call it
They're a lot less useful than most BP tutorials will lead you to believe.
i guess not
ok
so any UI user input needs to ( if relevant for replication ) needs to go through a PlayerState, PlayerPawn or PlayerController. is that correct?
(for an RPC to a server owned actor to have an effect)
Correct.
thanks a lot! i thought for some reason gamestate was fair game for anything
so im calling this in my widget instead now
which calls this which calls a server-side controller method, which then finally updates a gameState variable
it works!
😄
if this doesn't sound correct please let me know
my game is relatively flexible - players can choose keyboard caps, layouts, gamestyles(eg.basketball), elevations(changes to keyboard elevation), modifiers (loads of random unique changes to match logic) and probably more things in future. To "simplify things" i created an AllGameDetails struct which stores all of these different parameters in one place instead of having scattered and randomly named variables everywhere
my question now is what would you recommend in terms of code design
I'm thinking for example, one option is on my "SetGameDetails" node i can pass in which field(s) changed, so that the game state can handle changing the world accordingly after updating the state - so as well as having a centralised state object, i could also centralised my logic which responds to state changes.
The alternative to this i guess is"before/after every time i call setGameDetails, ill also write the logic to change the game according to the new state, wherever im calling setGameDetails from in my code" (eg. actively changing/spawing/destroying something)
for some things i will "read directly from getGameDetails for more passive things that are checking things in a tick" for example (eg. constantly lerping in tick to offset determined by a value in the gameDetails)
so question boils down to, should i centralise all my logic that deals with "active changes" (spawn, destroy) in the same gamestate method that updates the state object itself? This is how we'd do things in the web generally, a centralised store that all your stuff can read from, and when it is updated optionally suscribed things can get triggered to change/create/delete/whatever
im realising what i said about the web wasn't totally true 😄 we do respond locally to state changes locally in whichever component is interested in the change
i guess i'm looking for general advice on centralised/decentralised state management in ue
Fixed it, in case anyone ever wonders about why a multi-crew vehicle where the driver is a separate pawn that controls the main hull(which has the vehicle component on it)
Make sure to fucking untick the Requires Controller Input XD
On death I call UnPossess() and so on, start timer and which function I should call to restart player when timer is finished ?
@twilit flint Usually ServerRestartPlayer in Player Controller I believe.
thx
I'm working with the Character class.
I do not call Destroy Actor when a player dies. I simply deactivate input.
My game is round-based and I want to reset all player's location and rotation to match the corresponding Player Starts.
I've got everything figured out except actually setting the location and rotation.
Currently I try to do this via the SetActorLocationAndRotation node but nothing happens. Not on the server and not on the client. Yes I verified that the event is called.
The default nodes are not useful for my case because they all require the player to have been despawned
Restart Player should not require the character to be null?
Oh, wait, no it does. My bad.
Er. Well, it'll leave it.
uhm, apart from that. Why is the SetActorRotationAndLocation node not working as expected?
Where is this being called from?
Hmm. Odd amount of rerouting here. Client definitely shouldn't try to tell the server to call that again. Should just run on server explicitly. Thought that is a minor issue. Only reason I could see this not working is if your array of pawns is invalid.
Are you testing with a Listenserver by chance?
Or Dedicated?
I could see an issue with this in Dedicated, there's a CMC issue. Listenserver, the host player should see the location update immediately.
The game won't support dedicated servers
In Dedicated the client would need to move the character first or server would have to call a force update to the position. Setting location on server won't immediately replicate to a non moving client until client tries to move.
so I just figured out how exactly I want to rotate and translate the players
would this just be called as a regular function from within the gamemode?
*for the players
Control Rotation is local. To affect that correctly, you need to do a ClientRPC
I'm actually just really dumb. All this time I thought I was setting the rotation etc. on the Pawn but instead I was doing that on the Player Controller .........
Haha. Yeah that'll get you.
changes var name from Players to PlayerControllers
On a side note, saving references like that is okay, but somewhat unnecessary. It's very easy to create functions that parse the GameState's PlayerArray for PlayerStates of valid players. PlayerState can always access that player's Controller from GetOwner->CastToPlayerController, and access their pawn from the PawnPrivate variable.
yeah I haven't worked with PlayerStates at all up until now and the players are added to the GameMode and not even the GameState so I'm really not doing things the idiomatic way haha
Does the GameState class have native nodes/functions to get all currently connected players etc.?
this would mean that I don't have to do stuff like this anymore:
I have a vague memory that non connected players are removed from the PlayerArray. But yeah, you can avoid that. You can get the same thing with this... And to be fair this looks much nicer in C++. 😄
with ClientRPC do you mean this:
have an event Reset Player inside my player blueprint
GameMode calls the Reset Player event for every player via an event Server Reset Players which is replicated as Runs on server
?
or this approach that I used to handle player death:
honestly my understanding of Replication with when and how to combine Multicast and Run on Server etc. is shaky at best.
It's rather simple. If you're calling something from client ( e.g. Widget UI click ), Run On Server called from client, is sent to the server to execute there from client
if you're running the logic on the server that you want everyone to get you do a Multicast
The way to think about it with a bridge is simple: If you are on Server, do Multicast if you are on client do Run On Server followed by Multicast
if you have something that needs to get to all clients
So you're -always- doing a Multicast and when your logic originates on Client you're prefacing it with a Run On Server
Thanks! I'll make that a poster and hang it on my wall LMAO
Once you have those basics in the head. You'll have scenarios where you dnot want a multicast, but you'll have RunOnServer which sets some replicated variable, the engine's replication of that variable to all clients replaces your otherwise Multicast RPC
it's all about knowing the building blocks and how to put them together! 🙂
Can i call myself UE Replication Expert? lmao feels like all the questions I have and others do could be answered by the notes you just provided.
No there's more to learn but this is the basics 😛
I'm sure you'll get there some day! 🙌
@verbal tendon just to make sure I got it right by following an example:
I've got a Reset Player event that replicates on Server and is part of my player Blueprint.
My GameMode does some checks and passes in the relevant info
You don't want to be setting control rotation
ControlRotation isn't replicated. The two things you want to change for the player is their pawn's location & rotation, not the controller's control rotation
The node you already have in that screenshot has a rotation input
This logic is inside a regular event inside the GameMode. The event Reset Players
Reset Players is called as part of an event inside GameMode called InitPreroundPhase which is a Multicast event.
would this be the idiomatic solution?
( GameMode is only on server, so a RunToServer RPC is kind of pointless, regardless of that yes it'll run on server, if you ever need to use it to send from client, so that's technically fine )
There's no screenshot for what ResetPlayers does
yeah I do that because the game's host will be able to initiate phase switches.
But I dont like the sound of it 😄
Not the same thing, your arrow is pointing to a ResetPlayers node
oh well all it'll do is reset the player's health and position etc.
I'm replicated the way VALORANT handles it (not technically but the idea of it).
So players play in rounds against each other and once the winning condition has been met they're reset to the inital starting points, a timer starts etc...
The snippet you posted earlier that has Players[1]->ResetPlayer also looks questionable, since it's cut off there isnt more info to go on, but I'd wonder why you're doing that
Oh boy 😄
There's a lot to mention here, I'm gonna miss stuff
First of all high level. You have a server that's resetting players
generally speaking theres no need for client RPCs in this scenario
The server evaluate when to reset players ( game mode - server logic )
it may involve multicasts for sending things to the clients but that's about it. I'll get into details from things I noticed on screenshots
if you'd like to I could summarize the current flow more succintly so you don't have to look at the screens as much @verbal tendon
In regards to this one, instead of using a string on the PlayerStart actor. You put an integer there ( 0 or 1 ) for the playerindex
And then all your branches go away, all the code duplication goes away and you're left with a loop that does Players[ Spawn->PlayerIndex ]->ResetPlayer
single logic flow
And yeah I noticed the update screenshot on the rotation, looks good
You always want to duplicate as little logic as possible ( none is ideal ) if you find yourself duplicating things like there you can probably do it an easier way
that makes your logic easier to overview: less bugs, easier to maintain
An actual integer instead of the start tag is next, not a string 😛 then you're there
as the variable type
well I mean the default PlayerStart comes with it as a string so idk
so you don't need to do have the conversions 😉
It doenst matter you just add your own integer and use that
@tacit bough Not sure what all I missed, but in general Server can tell a ClientOwned actor to ClientRPC, sends the event only to that client if the client owns it. Server can Multicast from any actor regardless of ownership, this sends the event to that instance of the actor on all machines.
Replication deserves it's own mention since it's very different than RPC usage, Replicated values set on a replicated actor on server will replicate. Setting those on client only changes it locally.
As for clients, a client can only ever ServerRPC, they have zero other networking capabilities.
Thanks! That does make a whole lot of sense.
There is a chart halfway down this that will help with that a little.
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Charts where each RPC invoked from an actor with each ownership, from which machine type will end up.
uhm
I'm trying to apply all this info to my current situation.
Right now Reset Players doesn't do anything.
To test it I've got a keyboard button set to call Reset Players from the GameMode inside my PlayerBP
Reset Players is a function inside my GameMode
all that Reset Players does is call Reset Player on every currently connected PlayerBP
@verbal tendon Would I have to set any RPC etc. stuff with this set up? I mean since the GameMode lives on the server I don't really need it, right? Or do I O.O
Input events are on the client. So where you have an input event like that, you want to do a RunOnServer
but is the Reset Player event then RunOnServer or should the event that sits on the GameMode be RunOnServer?
e.g. in GameMode:
you're mixing things
yes call ServerResetPlayers from your 'R' input
and that shouldnt be on gamemode because gamemode doenst exist on client
so that RPC needs to be where your owning actor is. in the Character class or the controller class
in this case it really is just for testing purposes. Does it still hold true?
I'd only press R while on the host while testing for example.
in the end only the GameMode itself would call Reset Players
if you're developing a multiplayer game you'll be testing from both server and client
its good to have one way of doing things and keep in that structure
but not if it's just a function that'll later run on the server only right?
Correct, so your "ServerREsetPlayers" in this case is the "testing function"
and whatever logic calls it
"Reset Players" is what's more integrated into your core logic and not part of the testing
ServerResetPlayers needs to be in character or controller, and that's what should be called from Input
oh right
ServerReset players needs to be on character or controller, that exists on client
Yup
so here's the really confusing part for me. What kind of RPC setting do I set in the Server Reset Players event on the Player?
The GameMode executes Reset Players which executes Reset Player on every Player anyway.
Do I have to have any RPC setting for Server Reset Players with this in mind?
E.g. RunOnServer because only the server has the GameMode actually running on it.
because whatever I do inside GameMode is automatically a Multicast if I manually do stuff on all players, right?
also, does ResetPlayer have to be replicated in some way or again not because we call it from the GameMode?
ngl I'm super lost again now. More than before maybe. Since what I had before didn't do anything at all anymore,
I've done this inside my playerBP:
And Reset Players inside GameMode now does this:
but still I can't get the server to reset all players.
Individually players can reset themselves but that's not the goal.
@verbal tendon I do appreciate all the tips and tricks you've shared with me already but tbh I still do not know exactly as to how to apply that knowledge to my specific situation.
to summarize what I want to do (removing the debugging help stuff)
I want the **server **to **change **an attribute on every player
That's it. Nothing else. No events that are invokable from any client (or player for that matter). The GameMode is the only executing entity for this.
so my idea is to create an Event in GameMode that performs the action on all players without using anything like Mutlicast, RunOnServer etc.
in my mind the players shouldn't have any implementation details in them as far as the reset logic is concerned.
welp. figured it out. I can literally do everything of this inside the GameMode. No need for any replicated events at all.
the player got on the wolf in the game successfully...
player left the game or lost connection or lower f4 pulled closed server is not separating the two I need a solution to make this separation process
@woeful schooner Try overriding APlayerController::PawnLeavingGame()
By default it calls GetPawn()->Destroy();
I can't control when I disable pawn
Is this a BP only project?
The project is c++ but I'm coding bp because I don't understand c++
Not sure. The events for that are likely all in C++. I don't think you'll have much luck with that without overriding some virtual C++ functions.
bp is possible because I've seen it in games made with bleprint before but I don't know how to do it
the whole problem is here i delete here problem is solved but wolf is gone i can't control
Way to go 🙂
hello, can you give detailed information about how to do it in c++?
You need a C++ PlayerController class that your project is using. Just implement the function in it.
.h
virtual void PawnLeavingGame() override;
.cpp
void AMyPlayerControllerClass::PawnLeavingGame()
{
Super::PawnLeavingGame();
}
Calling Super destroys the current pawn. So more or less just remove the Super call and only destroy the player's actual pawn instead of the currently possessed one.
i don't understand but i'll give it a try as far as i understand
?
cpp
@woeful schooner They virtual override needs to go inside of the Class's brackets. Put // in front of the Super:: call.
Try those changes, and if the wolf stops despawning, you can finish the function to despawn the player's actual pawn.
Fill out your copyright notice in the Description page of Project Settings.
#include "MyPlayerController.h"
void AMyPlayerControllerClass::PawnLeavingGame()
{
Super::PawnLeavingGame();
}
cpp
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"
/**
*
*/
UCLASS()
class JURASURVIVALMOBIL_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()
virtual void K2_DestroyActor() override;
};
h.
sorry 😦
I could not do it 😦
Forgive me if this is the wrong channel for this but is there any folks here knowledgeable in AWS? Im using gamelift for my game but would like to have cognito authenticated with steam instead of forcing users to make their own account. I couldn't find much on google so Im asking here, thanks in advance.
Lookup Flopperman, he has a big tutorial series on AWS. https://www.youtube.com/watch?v=tOy0xYaP3wA
Also in the sticky
he also has a discord that you can join where he answers q's
perfect thank you so much
Does anyone know how to appropriately replicate an HMDs rotation when locking the camera to it?
From the player's blueprint, I tried to set the value of a repNotify variable in PlayerState from server, then do a multicast to print the changed variable on each client. Why is the result in multicast always seem to desynchronize with the copy on the server?
If I don't use PlayerState and just put the repNotify variable for example in player's blueprint and do the same thing, all clients synchronized perfectly.
When doing client authoritative movement, would there be any reason that calling GetCharacterMovement()->Velocity = SomeVector; always calls correctly on the client but only applies the new velocity about 80% of the time, the other 20% carrying over the velocity from before? Seems like some replication race condition but I'm not sure what since I've all the CMC clientside settings set up
I of course have GetCharacterMovement()->bIgnoreClientMovementErrorChecksAndCorrection = true; and any movement where I'm not directly setting the Velocity property works fine
@plush otter Don't multicast. RPC will reach the client before a replication in a lot of cases. When you set replicated variables, use the OnRep function to check them.
Ah I tried to show the result with OnRep, there's obviously a little delay before each client prints it.
So if I want to use the new value after the update, OnRep function should be the right place to go.
Thanks!
Dirty solution that works: Rather than directly setting velocity to SomeVector instead call LaunchCharacter with SomeVelocity passed in, and the OverrideXY and OverrideZ bools set to true
It's the only way I could get it to work correctly on the client, strange!
@kindred widgetJust want to verify my understanding. Say there's a Health variable in the player and a little hp bar above its head. After altering the value of Health from a server only action (take some damage), I should call update UI with repNotify instead of multicast?
Correct. Usually you do this by calling a delegate in the OnRep function. bind the delegate in the UI.
OK cool
Just started learning these concepts and many online tutorial videos start doing things like this with multicast. I guess it's just easier to start with but definitely gets me into trouble with visual desync.
Hi, possessing a vehicle as a client is detaching the pawn i've attached to it, any ideas?
Hello.I set net dormancy of an actor to dormant all.But when i am spawning the actor on server i can see it spawning on other clients as well.WHat is the problem??.I am using blueprints for this..
Please help
Context here: #blueprint message
what do you want to acheive??.You want to play sound on other player??
What's the best way to replicate physics smoothly so it looks smooth for all clients?
When I try to add a new element to a Replicated TArray, I get error. The call only runs on server. It works if I play on standalone, but not when there's also a client.
Does anyone know how to Add to a Replicated Array?
I have another quesiton.
When I use AddDynamic to bind a Button to a method, is there a way I can have that always called on Server? It doesn't work on client.
I already tried to make the method itself call on Server, but I think because it's accessed through a Button by a Client, it wont run on Server.
any idea why my spawned actor does not replicate
Make sure it's set to replicate and ensure the server is the one spawning the actor.
for local mp, both using either same keyboard (for test), or any combo of keyboard/gamepad, do you need to make separate playercontroller bps? i already have my primary char setup, and by default the game isuign my player controller, but now trying to set up p2, unsure if i need a second player controller, and if so, how to assign it to p2
im wondering if it would be smarter to put all my controls in the actual char blueprint instead of the playercontroller bp
No, the engine handles that for you.
The server has to spawn it?
But how can the server spawn it. For example, I have a client that wants to spawn a bomb
You run a server RPC and have the server spawn it.
after a bit of research, seems like the best solution is to use the smooth sync plugin incase anyone had the same question (No clue if this is the best solution so feel free to chime in and suggest something else)
Has anyone experienced a weird bug where when using the Asset Manager in a multiplayer environment one of the players doesn't load the assets? I've tested this only on one PC but both with "Run Under One Process" toggled on and off. With it toggled off one player loads all the assets and the other only loads one. Is this something thats happening because I'm using the same PC to test multiplayer?
for some reason it is spawning two on the client and one on the server
oh I guess switch has authority helped
If I have to run my server build on digital ocean and want to connect clients to it how can I do that.?
One more question what are the other option then AWS to run my dedicated server on cloud.?
ok, so i have a problem, im making a split screen game, how can i detect what kind of "controller" (gamepad or keyboard and mouse) is "player controller" using? i want to show key tips based on what kind of controller player uses, im using build in split screen system, im not doing anything more than "Create Player"
Please help
Context here: #blueprint message
What I am trying to achieve is in that chat too, but people in that chat told me to come into this one as someone here might be able to help with my issue.
Hello guys!
Im looking for methods to multiplayer phone game, where one of the players can host the game.
Is there any method to create a game like described below, without buying or hosting on my computer any server? As i read using the same Wi-Fi can help this, my another question is, that is there a way to play this from different network connection (but the people still stay next to each other, just everyone using his own mobile network or something like that.
I want to make a little party game with 5-10 players on mobile. It would be a social role-playing, card based game, without any very complicated functions, just start the game on the phone, everyone gets the roles, some counter works rounds, until the gang finish the game and close the app, no need to save anything.
Thanks for the answers and Happy New Year!
what is analogous to APlayerController that is replicated?