#multiplayer
1 messages ¡ Page 695 of 1
you probably want to work through some of the sample projects, because you're kind of making this more difficult for yourself
yeah, if it was, then you could just get self
like if you do the key press handling in the character, you don't have to find the character, if that makes sense?
well, i'm using a template called horror engine which is a class inherited into the character blueprint
okay, so when it inherits the character BP, it is the character BP basically, with extra info
oh okay my bad
so it should work?
then why it doesn't?
both of them jump instead of only the one i'm making jumping
it happens for every input action
it's because you're trying to grab the character index, i believe.. the target for jump is probably supposed to be 'self'
:\
it says that 'Target' must have a connection
you can maybe do a 'self' pin and 'cast to character', but it's pretty sloppy
in general, you probably want your jump code in the character class, sorry to dodge your specific question a little
yeah i know but this template is build like this
i feel ya.. it's hard to answer because it depends on what all is going on with that template
this was a tutorial that seemed really good to me: https://www.youtube.com/watch?v=RtQRMcupJs0
i know it doesn't apply to your particular template, but sometimes it can be helpful to work through it to know where to look in your own project
i think i found a way to make it works
thank you so much, i'll give a look
glhf
Was wondering if anyone could spot an error that I have no idea why im getting, since I've done this before and didnt have any issues. I have a multicast RPC in a parent class and my child class is trying to override the _Implementation of that RPC. Though I keep getting some unresolved externals from it for some reason...
Decleration in the parent header
Override in the childs header
how do you find that in Rider?
Not related to the issue, but I would suggest making this kind of RPCs as UnReliable. It's a cosmetic rpc and doesn't affect gameplay that much
Other question (more relevant to here) about general code logic to spawn projectiles on the server and client as well as a vfx on client and server. This is the logic:
(The following is within a UComponent for the players inventory)
- Input received to trigger "StartModFire()"
- Continues on "FireActiveMod()" which determins what mod is active and calls its "FireMod()"
(The logic jumps over to the Mod Actor, of which does have a reference back to the owning player if needed) - Within the Mod Actor's "FireMod()" a "ServerFireProjectile()" is called to spawn the projectile on the server (from what I know this spawns a projectile actor on both the client and server)
- Finally within the "ServerFireProjectile()" a NetMulicast "MultiSpawnVfx()" method is ran to try and spawn a vfx that both players are able to see.
The result of this logic looks like this:
-when the server fires a projectile is put on client and server and the vfx is only visible from the servers point of view
-when the client fires a projectile is only put on the server and teh vfx is only visible from the clients point of view.
Both client and server follow the same logic path in code and call the same RPC functions in reguard to the server one and multicast one. I'm not sure what causes the server RPC being called by the client to only spawn the projectile on the server and im unsure why the multicast doesnt actualy multicast at all but rather only runs on the local machine...
Thanks for the tip!
The ufunction needs BlueprintNativeEvent, doesn't it.
Otherwise it won't generate the _Implementation versions
It doesn't need to be a BlueprintNativeEvent. Though it would be wise to put the implementation under where you declared the multicast function.
The "start match" and "End match" functions what do they do exactly? i am doing all logic myself and i was wondering if it would be better to use unreal stuff
I have that issue resolved now, now im just trying to resolved the issue in the other message
đ , what variable should I get in C++?
When I send an actor reference through a RPC, what makes it recongnize the actor on servers/clients?
Does anybody have experience with replication of widget and widget interaction ?
I have a very simple widget, which is just a button (see screen below).
I want the states of this button to be replicated (hovered, pressed).
My FirstPersonCharacter has a WidgetInteraction.
But for some very weird reason, the hovered state is never seen.
It works if there is only one player but not when the others players spawn.
Any idea why ? I'm losing my mind
Thanks
There is a NetGUID is that is associated with replicated actors that is passed through RPC calls. That NetGUID then resolves on the client/server to the appropriate referenced object in memory.
Thank you!
So then whats the proper one, I am assuming its in C++?
Nope none. I only use a source build for delicate servers
Hey a few weeks ago you suggested manually ticking an actor to move it forward in time for prediction, but I can't figure out how to get that to work. I'm creating an actor that has a Projectille Movement Component and callling Projectile->Tick(DeltaTime), and drawing a debug sphere before and after the call, but the projectile doesn't move at all, and lags behind the client version of the projectile. Is there some other way to call Tick manually that will actually move the actor forward?
So im trying to call a server RPC if the client is being ran on and the gen.cpp for the file is erroring when it calls the server RPC from the client. It says it errors on the last line here c++ static FName NAME_AModParent_ServerFireProjectile = FName(TEXT("ServerFireProjectile")); void AModParent::ServerFireProjectile(FVector Location, FTransform CollisionTransform, FVector Direction) { ModParent_eventServerFireProjectile_Parms Parms; Parms.Location=Location; Parms.CollisionTransform=CollisionTransform; Parms.Direction=Direction; ProcessEvent(FindFunctionChecked(NAME_AModParent_ServerFireProjectile),&Parms); }
is anyone familiar with this situation?
Maybe try ticking the movement component
yeah i tried that too and it didnt seem to work either. However, I'm not sure I'm calling the right function. I'm calling ReceiveTick, which just takes deltatime, but there's also a TickComponent function that takes a pointer to a function of some kind and an enum for what kind of tick is happening in addition to deltatime. I have no idea what these things are so I haven't called that one.
ummm it appears to be working if i call TickComponent passing in the component's primarycomponenttick struct as an argument. not sure what that actually is but okay
The error it gives me is a stack overflow somehow just in case someone else has seen anything like this?
Any tips on how to improve the attack feeling as playing client ?
Currently when i attack i'll play an animation montage via a Multicast, but with a "normal" ping you'll already get a somewhat clunky feeling.
I've also tried to play the animation montage locally too, it makes it only a tiny bit better tho >_>
The fact that i'm using root motion animations is likely also making it harder rather than easier. Also feel like i should point out that i'm not having problems with root motion jiggering itself
Not sure if i'm thinking weird here, but should i maybe try to play this montage locally based on a timer event ?
I thought about letting this event fire after e.g. X ms where X is the amount of time it will take till the server gets the command to play the montage from this client
i think its missing implementation in parent class
you will most likely predict and execute stuff locally while waiting for the server to confirm or reject the client prediction for a certain action
The parent class has the implementation, it just doesnt create a decleration in the header file
Attempting a Debug Editor build now to see if Rider will show me the call stack
I usually build in Development Editor as that was just the default for me
shouldn't it be declared virtual in header file? in parent class too?
well that is the default for binary build, but DebugGame is a nice compromise since DebugGame still has optimised engine modules
Development Editor would still show you a stack overflow though
how can you debug if you can't compile and run?
It is declared as that, that is in the "fileName.gen.cpp" file that gets generated
ignore generated code
It does compile and run
it'll be in your _Implementation function probably
if your stack looks like
RPCFunc
RPCFunc_Implementation
RPCFunc
RPCFunc_Implemetation
over and over
When i step through the code manually right when i try and step into that server RPC is when it gives me issues, it never actually makes it into my code for that function when i step through manually. That was what happened earlier when I was debugging. I am recompiling for the debug again at the moment
can you show your _Implementation function
I'm currently looking at the header file from APlayerState and i saw this here
/** Exact ping as float (rounded and compressed in replicated Ping) */
float ExactPing;
float ExactPingV2;
Are the any more informations about ExactPingV2 ?
also in addition, if you overrode ServerFireProjectile_Implementation in any child classes, make sure you're calling the right Super
thats all the implementation is
and now show FireProjectile
rpc calls fire projectile and the fire projectile calls the same rpc?
only if not authority
The idea behind is was to ensure a projectile always gets spawned on the server
NOTE: I'm relatively new to networking in c++ like this so things may look weird as I am in the process of reading documentation and whatnot still. Still working in progress
I would follow the UE4 coding style on braces, I tend to just use !HasAuthority() instead
but a callstack will certainly help
since it should fail that condition on the server
we still talking about this right?
This is the call stack after the exception
rider was frozen when i took that first screen snippet, but once it calmed down after the exception it definitely is recurssing somehow
I was able to find the owning player remote role...?
the variable is just called Role
nothing else
also RemoteRole being ROLE_Authority would indicate this is a crashing client rather than server
Is it in the AActor hierarchy?
so the weird virtual stuff I saw from you the other day might be coming into play
yes
private member of AActor
Found it, Rider was hiding it
yes it's crashing as a client
though at this point I would just do a complete audit of everything that declares or implements ServerFireProjectile(_Implementation)
remember: ServerFireProjectile SHOULD NOT BE VIRTUAL, this is a function generated by UHT which does all the networking magic
I usually explicitly declare the _Implementation function too
So you're saying the original decleration of the function should not have vitrual
like in either the parent or child class?
no only the _Implementation function should ever be virtual
Could that cause the issue, because I did have virtual on the front of the ServerFireMod() decleration?
yes
you should instead make the implementation virtual as sswires said
UFUNCTION(Server, Reliable, ...)
void ServerFireMod();
virtual void ServerFireMod_Implementation();
and in child classes, you can override the implementation
Hmmm, the same situation still arose...
So im a bit confused as to how this is able to run recursively. So when the code is switched to server via the RPC that calls the same function. Does the role of OwningPlayer not switch to being the server?
I tried switching it to a simple HasAuthority but it seems as though the role of the Actor containing these RPC functions is always Authority
HasAuthority is return (GetLocalRole() == ROLE_Authority);
I mean switching from checking the Authority of the owning player it check the authority of the actor
Still unsure how the Local Role for the owning player could be the same when running on the client and when switched to running on the server
there's the local role and remote role
the server will always have authority over replicating an actor
Are you running as a single client on a dedicated server? Net mode helps to know
So i've went through the call stack and the issue is definitely that when the server RPC is ran and it calls the Fire Projectile the Role of the Owning player does not switch from autonomous proxy to authority
I am not running as a dedicated server
Under one process is fine and a valid way to sanity check stuff
So what net mode is it?
On a listen server PIE session, the first player will always have ROLE_Authority
it is indeed a listen server
the listen server can also play the game
yes the server and client are both playing the game
First or second viewport?
Or does it happen in both
Forgive me I dont think I understand what your asking. The server pops up in the first viewport and the client joins in when the second viewport pops open
Yes and Iâm asking which situation replicates the crash
Ahh i see, its only on the client which makes sense because the other player's role will never let it run the server fire projectile
I still think something is up with your overrides of that RPC
Thatâs why I was talking about virtual
u implemeneted _validate
WithValidation isnât required anymore btw
So you can get rid of it if itâs just return true
Probably due to old examples and documents I've read
yes
in docs they said: UHT require server RPC's to have _Validate
I really donât know how your client could call the RPC implementation directly without networking
its old docs
Which hasnât been true for ages
Question: Am i naive in expecting the LocalRole for the owning player to switch to authority when running on the server?
I've used logic like this before where I check the Role and based on that will run the same function using a Server RPC and have never experienced anything like this
LocalRole will be Authority ALWAYS on the server
Thats what I thought! So is the Server RPC not working due to some other potential reason maybe?
Well this is why to do an audit and run through your call stack and try and figure out why it keeps calling itself
I donât have access to your code but have run into similar situations with RPC mishaps
I examined the call stack thoroughly and it just called the same two functions over and over. Is there any thing in particular that might stick out or to look at?
That you would recommend when looking at the call stack?
Misuse of UFUNCTION in derived classes, overriding the RPC generated function rather than the Implementation are the usual suspects
But I canât really say for sure unless itâs on my screen and diving into the code
Yeah i totally get that
When you say misuse of UFUNCTION in derived classes do you mean that the override decleration needs the UFUNCTION with it aswell as the parent decleration?
No, it should be avoided in any child classes
okay good just checking, yeah I might just figure some other route to take since there seems to be nothing different than how I've done things in the past and there is just nothing that seems to remotely stand out
Also see if youâre accidentally spawning versions of these actors on the client
Because thatâll cause issues
Im not sure what you mean?
Whatever the hell ADefaultAmmo is, make sure youâre not spawning a redundant client side version of it
The tell tale sign would be the roles being different
Between that and the owning player
Rebuilding to check currently. Question though:
For what I have currently in the group im in we have two players. Both players have a custom UInventoryComponent attached to them. The inventory has reference to mods that the player can use. In this case i've just issolated the situation to using our default mod. So you mean for example that in this case both players inventories mod references should be replicated on the server? Still working through the logic of deciding when something needs to be replicated vs not being so
Replicated actors would need to be spawned by the server and the server only
So i've just check and the Player character (server) has a role of AutonomousProxy, while the ADefaultMod that is in that same players inventory has a role of Authority. So i believe that matches the problematic situation you described
Your team is about to learn a very nasty lesson on whyâSP now, MP laterâ is stupid
Hah.
Yes, never, ever, ever try to convert a SP game to MP.
Always start out thinking about MP.
So what you saying in the case of this Mod Actor is that it shouldnt be spawned as such:
void UInventoryComponent::BeginPlay()
{
Super::BeginPlay();
// must spawn in our default mod so that it becomes usable
FActorSpawnParameters SpawnParams;
SpawnParams.Instigator = GetOwner()->GetInstigator();
AModParent* ModParent = GetWorld()->SpawnActor<AModParent>(DefaultModClass,GetOwner()->GetActorLocation(), FRotator(0,0,0), SpawnParams);
if(ModParent)
{ // we want the default mod to stay forever so set never destroy to true and destroy the mesh component
DefaultMod=ModParent;
DefaultMod->bNeverDestroy = true;
DefaultMod->bIsDefaultMod = true;
DefaultMod->MeshComponent->DestroyComponent();
DefaultMod->OwningPlayer = Cast<ANetworkChar>(GetOwner());
}
}```
But rather having a check before like HasAuthority() to make sure the server spawns is?
And never try to write a mp game before you have a good understanding of network replication, authority and asynchronous programming.
I forget if beginplay runs on server and client (I assume it does) so you should probably add an authority check before spawning anything.
true that will spawn 3 actors 1 on server and 2 on client
2 on the client because the server will send an extra one to the client to "replicate" the one it has created itself.
Assuming it passes the relevancy checks
Believe me I know, the situation is less than ideal. What this project is is our "Senior Project" and our idea was to make a two player fps shooter (which in heindsight was very dumb), but our team was naive to networking in unreal and what it really took. And our leadership through this project which was essentially our professors in charge of overseeing things (who are supposed to know what their doing) never mentioned that its absolutely critical to think about mp from the very start of the systems. Granted it would have been nice if we looked into that but we were naive and didnt know to look and the people overseeing things never said anything about it. So we went about our ways with just one "network programmer" until i realized that when we tried to plug his networking code to spawn two players as a client and server and things broke and I started looking into things that we were so beyond screwed because of layed our own foundation for failure essentially without anyone watching informing us...
If i only spawned if owning player HasAuthority was true then how would the client ever be able to spawn in its default mod?
since wouldnt the client player never have authority and always be the AutonomousProxy?
the server will tell the client to spawn the same actor
BeginPlay runs on clients too
So your client and server are spawning independent copies of the same actor
Okay now i see what your saying
Yeah hopefully this is part of the root of a lot of problems since this seems like it could be quite problematic
Man, I miss gameplay programming.
lets just call it programming lol
I love gameplay programming. I do not love "turn this SP game into MP game programming" đ
I added the check like so c++ if (GetOwner()->GetInstigator()->HasAuthority()) { FActorSpawnParameters SpawnParams; SpawnParams.Instigator = GetOwner()->GetInstigator(); AModParent* ModParent = GetWorld()->SpawnActor<AModParent>(DefaultModClass,GetOwner()->GetActorLocation(), FRotator(0,0,0), SpawnParams); if(ModParent) { // we want the default mod to stay forever so set never destroy to true and destroy the mesh component DefaultMod=ModParent; DefaultMod->bNeverDestroy = true; DefaultMod->bIsDefaultMod = true; DefaultMod->MeshComponent->DestroyComponent(); DefaultMod->OwningPlayer = Cast<ANetworkChar>(GetOwner()); } } and it does what i thought were the client player's inventory has no default mod at all
Hello⌠Iâm curious if shipping and development builds are compatible for multiplayer?
Yes?
Does an actor need an owner to replicate? I'm currently using the default spawn parameters to spawn in my actor on the server but it's not replicating at all
Is your server responsible for spawning this actor?
Only actors spawned by the server will replicate
Ye. I said it's being spawned on the server
oh sorry i missed that
are you positive?
i'm also assuming the actor is set to replicate
Anyone know how I could replicate this? So that the flipbook is set on server so other's can see it
sent a server RPC that has the flip[book asset poitner parameter
It's because that is not supposed to be a thing. You can't just turn an SP game into MP without a lot of pain
Sometimes even "You can't just turn an SP game into MP without a lot of pain" more correct sentence
Imagine making a montage based movement system with IK and physics related gameplay mechanics, and your boss wants you to convert it to MP
Anyway a curiosity question, are OnRep functions binded via dynamic delegates? Why UFUNCTION required for them?
Sorry but no. Regardless of your setup, everything can always be turned into an MP game. Depending on the setup the pain is less or greater, and depending on the project constraints. It's easier the less constrained you are, with full freedom it's not that bad, just depends on how much content and logic needs to be converted
If you are willing to fight with engine's nature, sure everything is possible but with a dedicated engineering support and tons of budget. Or if you are just crazy (and experienced) enough to rewrite the core parts of the engine
Some things can not be replicated directly, or just not sensible to replicate
So, I'm using the FPS Multiplayer Template. And when I play the packaged game and click create game. It's just stuck on the loading screen. Here is are my host game blueprints:
And this is what the publisher said when playing multiplayer
Option 1 Using Steam
-Download the demo from the discord
-Open steam and leave it open
-Make sure that the steam download region is the same for all the players, this can be changed in Steam->Settings->Downloads ->Download Region
-Open the demo
-Create/Join a multiplayer game
That's for the demo which I think also applies to the actually project
Anyone knows if there is a way to make OnRep fire when value is set by server but not changed?
I set a bool to true by local client and send server RPC to set it to true again to fire OnRep, but due to its predicted before server change OnRep is not being called on local controller
That's not really true at all - plenty of thing are inherently impossible in MP
DOREPLIFETIME_CONDITION_NOTIFY
and you have REPNOTIFY_Always/REPNOTIFY_OnChanged
you use it like that, so the repnotify will be called everytime the value is set, even if it's the same than the old one
DOREPLIFETIME_CONDITION_NOTIFY(UZircoHealthSet, CurrentShield, COND_None, REPNOTIFY_Always);
Thanks a lot!
It really depends on the constraints of the project, almost nothing that is realistic is impossible
Don't need determinism or hotjoin? All the doors are open
So we built a space sim with realistic physics projectiles fired at multiple kilometers per seconds
You want to port that to MP?
You work your way from zero constraints to those that are required for the particular project
I'm currently making a space sim with realistic orbital trajectories, hundreds of ships that all always move all the time (since they're in orbit)
You think you could port that from SP to MP after the fact?
By the way kinda offtopic but what was it's name? I'd like to add it to my wishlist (i remember you mentioned about it once at #cpp )
I'm not here to fight you. I mentioned pain based on when this is done, and that anything is possible based on project constraints
Astral Shipwright
I don't see a purpose for the discussion you're trying to lead
You can always completely rewrite an entire game from scratch, sure
You felt the need to write "everything can always be turned into an MP game"
But like, for many many games that would be a completely different game with a full rewrite
"Regardless of your setup, everything can always be turned into an MP game. Depending on the setup the pain is less or greater, and depending on the project constraints. It's easier the less constrained you are"
Atleast take the full quote, not the first half
Whether or not it's reasonable to do for any project is a different story, and the pain&difficulty of doing this will scale exponentially with the lack of experience from the person doing so
I disagree with the full quote - sometimes it's literally impossible
Quite often really
Any large enough amount of gameplay-affecting physics will make your game single-player
Any large enough amount of real-time data changes will make your game single-player
Well I completely disagree with your statements
Let's just agree to disagree and leave it at that
.. I am using a custom c++ character movement component to drive all the movement and rotation replication.
Any tips for solving this problem -> https://forums.unrealengine.com/t/listen-server-sees-client-movement-as-jittery-stuttering/476520
Details:
Hi, after testing my game with the average network emulation profile, I discovered that the actor velocity in a listen server, is not smoothed as in simulated proxies.
I am using the actor velocity to drive walking animations (the distance of each step - stride), in the listen server the walking animations stutter because the velocity has abrupt changes. (This only happens in the listen server)
Hello, Iâve been going crazy trying to resolve this issue. I canât seem to figure out why the listen server sees the clients animations jittering and stuttering while clients can see the server and other clients animations perfectly smooth. [Here is an example of what i mean.][1] Here is also a picture of the StatNet. https://answers.unreale...
If I call a server rpc from the server, does it go through the whole process of rpc'ing or does it just run it like a normal function?
Yep and I'm positive because the subsystem that's spawning it is server only
It acts like normal function
UE says "whatchu doin' bud, you cant send RPC to yourself" internally and ignores it
Perfect. Thanks.
yeah I know it runs on the server but i wasnt sure if it would go through the whole rpc process, i.e. not be called until the next frame
at least thats my understanding of rpc since replication occurs at the end of frame
at least thats my understanding of rpc since replication occurs at the end of frame
Yeah
So I'm trying to understand why my OnRep is not being fired when it's set to false but fired when it is true. Anyone has any idea?
DOREPLIFETIME_CONDITION_NOTIFY(UWeaponModule, bActive, COND_SkipOwner, REPNOTIFY_Always);
bWroteSomething is false but I changed bActive from true to false in server
This is the result when I set it to true
you should call OnRep right after changing bActive on server
also SkipOwner will send changes to everyone but the owner
Owner is server, so it should arrive to clients
Clients dont receive OnRep, also the change of the value
If your original value is false and you will "set" it to false nothing will happen, because the value doesn't actually change
RPC networking doesn't care about value assignment on a variable, it checks for a diff between the actual value
My original value was true and I'm setting it to false
Also when you have REPNOTIFY_Always on DOREPLIFETIME_CONDITION_NOTIFY it will replicate without checking the difference
It'll only ever send a property if it changes, REPNOTIFY_Always doesn't change that
Setting true from false makes it replicate
but setting false from true doesnt trigger replication
đ¤ Hmm.. yeah apologies, you're right
It was for OnRep function triggering condition, not replication
So bActive is false by default on clients, and only being set by server
They dont change it locally
So when server sets it to true, server replicates it and it's true on all clients, but still can't reason why same thing doesnt happen when server sets it to false back
Are you turning off replication when it's false?
No
Through PreReplication or somesuch
its a bool in a uobject i think
Hi. I cannot scroll in Network Profiler GUI.
Yeah good luck with that, the profiler is old and broken AF
Not sure if its identical as features but you can try Insights
Honestly don't think the profiler has had an update in over 10 years
Oh, its from UE3?
Well it was there as early as 4.0 that's for sure đ
Like UnrealFrontend, Lightmass, and Cascade
But while it's useful it's a pretty crusty old app that Epic don't maintain so milage may vary
Literally the UE3 stuff, all of them
Tried this.
https://github.com/ryanjon2040/UnrealNetworkProfiler
In this I can't select a frame. Maybe one of it's forks has a fix for this.
Try Network Insights instead, more fancy
that just a visual update
If it's a third-party app you probably won't get much help here
Probs have to fix it yourself
RyanJon2040 is in this Discord but under a different name it seems
@mighty schooner or there are four of them đ
What's that?
RyanJon is doing good things with UI/slate, I saw some of his works for FlowGraph
Modern profiler
Looking at it's source code size, it does not look that much complex to give an update to the profiler.
Insights is updated profiler
made by Epic
Available for 4.25 and beyond
with fancy widgets
Ok. Thanks. I will look for it.
@chrome bay how much would it cost me if I wanted more help with my replication (or lack thereof) stuff?
I doubt the comment matches the declaration order
Only way to know for sure would be to dig deeper
Also in an ideal world, the In shouldn't be that high - the server isn't constantly sending updates, it's only sending changes.
But what I mean is, you won't be getting any updates unless anything is actually changing
12 idle players will make little if any impact
So uhm, how much would GAS help me when it comes to client side prediction of animation montages ?
You would just call play montage task in an ability and its done
That sounds easy enough.
But would it be fine if i use GAS just for this goal ?
Like i wrote already most of the systems i need, the only real problem for me is the client side predictions for things like attacking with an montage ^^"
Implementing GAS is not 5 minutes work (its 30 minutes of work but a hassle if you are just going to implement for this)
So just for this, eh, no wouldnt be fine
But if you are going to use abilities or effects directly, yeah totally
Alright, so GAS it is not then xD
I've also heard about a plugin epic works on atm. Network Prediction was it i think
Is it still to early to give that a try ?
Why not have a boolean with COND_SkipOwner condition
I think GAS for just predicting anim montages is overkill
And send the server RPC to set it true
Its pretty easy thing to predict
Since CMC also drives the mesh pose
It wouldnât help with that
Will give it a try later, wont lose much if it doesn't work xD
Alrighty, thought it was kinda related to that
Thats how most of the time prediction works when OnRep functions involved
I actually don't use the OnRep method atm, but a Multicast since the attack isn't relevant for players who are very far away
Then just play animation and call server rpc to call multicast, on multicast if player is locally controlled return before playing animation
Gonna try it đ
Btw, feel like it's worth noting that it's working good atm. The problem starts only when i test with an "normal" ping as it feels clunky on the playing client
Oh wow, it really works pretty good now, thanks đ
It's still sometimes clunky, but i guess you can't really avoid such things with a rather high ping xD
It will be trouble if client finishes before simulated proxies finish their anims and send another RPC to play animation
Other type of issues probably caused from CMC
since it drives root motion replication and mesh pose ticking
And its doing its best, so yeah sometimes you cant avoid issues :\
Hi, what could be a reason to have a RemoteRole set to None on my PlayerCameraManager inheriting class in BeginPlay ?
do you think it's easier to implement your own prediction and revert to the previous state if needed?
Probably a simple answer, I want to assign each player character the unique ID UID. I've replicated that variable and now I'm encountering the following issue
Instance 1:
Local character has UID 12345
Remote character has UID 12345
Instance 2:
Local character has UID 6789
Remote character has UID 6789
Ah I think I'm misunderstanding the concept of replicating
Isn't that because you have two different characters? That would make sense, wouldn't it?
So I'm running into an issue where I'm quite certain im doing something a bit wrong when it comes to spawning in actors within client and server. To make things simple lets say I have an Inventory Component attached to a player. This inventory spawns in a weapon within begin play and the player can use that weapon. The issue im running into is when i debug the game and lets say im looking at the client or just player2 lets say. Player 2 will show its Role as Autonomous Proxy while if i look within the inventory at the weapon actor reference its holding the Role for that will show as Authority. What would be the correct way to go about spawning in the weapon actors so that the information matches up as would be needed?
No, what I was aiming for was, with adjusted wording for clarity:
Client 1 session:
Player1 (local) with UID 12345
Player2 (remote) with UID 6789
Client 2 session:
Player1 (remote) with UID 12345
Player2 (local) with UID 6789
But I read up more on replication and I figured it out
(Basically making an RPC to tell the server "Hey I've been assigned this UID! Let the others know about this, thanks!")
If I understood the documentation correctly
That is not something you want to do. Trusting a Client with something like an UID assignment is a bad idea. The server should assign those exclusively otherwise you are just creating a loophole for cheaters and its all around bad practice. But good job at figuring out a solution that works đ Networking and replication can be tough to think about.
It's actually a UID that is assigned by a third party app for teleconferencing integration. This way I can link each Character with its corresponding webcam and audio feed. But that's a good point you make, thanks!
Seems like you got yourself a little login riddle. Make sure that the third party is ok with disclosing the UID to general public. Otherwise it has to stay strictly on the server and you will have to figure out other way to identify the characters. I've got myself once into situation where we got stuck on shipping a product because of legals and its a bitch to rework core system just before shipping.
Thank you very much, I'll double check the licensing and security disclaimers of it. Always nice to get advice from someone who's been around the block
Your weapon actor sounds like it is being spawned on the client rather than server side. The role doesn't directly tell you if the object is from the server or not, it's more that it is telling you its relation to the current instance of the game.
While running code on the client, anything spawned by the client will return its role as Authority, similar to if you were running on the server, anything spawned by the server would have role as Authority.
Anyone know how I could replicate this? So that the flipbook is set on server so other's can see it
I've never implemented my own prediction, but I don't think it gets much easier than using some type of prediction system thats already been battle tested
This might be a long shot, but not sure what's going on. I have a networked game where I right-click somewhere and it sends an RPC to the server and then on both the server and the client it calls UAIBlueprintHelperLibrary::SimpleMoveToLocation(PController, DestLocation);.
Now this has been working great while running in the editor, but I recently went through the process of packaging up my game with a specific server target and everything. Now when I start a dedicated server from an .exe and connect to that server from the editor (locally, on the same machine), I'm getting some insane rubber-banding. Walking a distance that normally takes 2 seconds now takes close to a minute. This is really weird to me for several reasons:
- It's happening locally, so there should be minimal latency
- Even if the client and server were fighting about where to place the actor, I would expect the server to win and for the actor to still move the whole distance within a couple of seconds, instead of moving super slowly.
- If I change windows so I'm not focused on the editor (client) window, I can see the pawn walking normally in the background without the rubber-banding.
Any ideas what might be happening here?
Here's a video of the behavior
- Incorrect, it will continuously miscalculate forever and correct forever, until stopping movement
It looks like he's trying to walk through something that only exists on server but not saying that's the case and wouldn't make sense with #3, but have you used the console command p.netshowcorrections 1 so you can make sure that it is a net correction occurring
Interesting. Assuming this is due to continuous net corrections, how do I solve that? It seems like there's something that is out of sync, but I'm not sure what. The location should be getting replicated from the server. Maybe it's the pathfinding?
You'd need to use client-side prediction, with characters you'd just send the pathfinding results as movement inputs though rather than building it from scratch
Alright, it's definitely net corrections. Getting lots of green/red cylinder around my pawn as it's rubber-banding and I'm seeing a lot of "player movement" errors in the logs. Interestingly it seems like the ServerVelocity is almost always 0, and that's seem to be causing the difference in location:
Tue Feb 22 15:42:10 PST 2022 Warning LogNetPlayerMovement *** Client: Error for TopDownCharacter_C_0 at Time=55.136 is 8.215 LocDiff(X=-4.576 Y=6.822 Z=0.000) ClientLoc(X=-18595.691 Y=-12035.105 Z=145.594) ServerLoc(X=-18591.115 Y=-12041.928 Z=145.594) NewBase: CruiserCommand:PersistentLevel.CCStaticMeshActor_11.StaticMeshComponent NewBone: None ClientVel(X=-105.065 Y=156.662 Z=0.000) ServerVel(X=0.000 Y=0.000 Z=0.000) SavedMoves 0
You should be using AddMovementInput based on client side path following anyway so you get prediction
Got it. So to confirm, you're saying do something like this:
- User right-clicks ground somewhere. Calculate hit.
- Send RPC to server with destination vector
- Server kicks off pathfinding to destination.
- Server (somehow) repeatedly calculates based on the current path, what the movement input should be
- Server replicates this movement input down to the client, which then applies it locally using AddMovementInput.
If I want to add prediction to this, I would need to add a step between (1) and (2) where I also do pathfinding locally (or maybe just naively assume just use the angle from the current location to destination) and use that to calculate an initial movement input that can be used initially until we start getting movement input from the server.
Having a bit of a multiplayer brain fart. I'm using onrep to notify the player states when the server has assigned the team int. Then on rep I execute logic to set the color of the pawns team on pawn's mesh.
But the client doesn't seem to do it for the server, only for itself. What am I missing?
The OnRep will be played locally after the variable was changed by the server
I'm not sure I understand what you mean?
The OnRep fires when the server changed the variable anyhow, right ?
The On rep fires only for both pawns on the server, and only for the clients owning player state but on the client the servers player state doesn't seem to fire it
That is what the output log shows, you should see 4 Team Assigned messages but only see 3
Are you doing it in C++ or blueprints ?
BP
hey guys. i'm thinking to make a web game with multiplayer with ue. is using pixel streaming can allow people to play together
?
of course with a host server with aws
but i don't want people to download the game. so is it good idea pixel streaming or just switch the engine
Seems like my brain is also not it the best spot atm xD
Yeah. part of me is thinking, maybe I'm not supposed to do this in the player state, but like the Team Number should be replicated on the player state for sure?
I have this working for Health on the pawn itself with on Rep, health changes and updates everyone via the pawn. Health should also probably be on player state but if team int is acting this way then I can't move health over till I figure this out
I figured it out!
So my Team Int was default to 0 which represented an actual team. So when I assigned team 0 to the var that is already team 0, the OnRep wasn't fired because the value didn't change.
So I made the int default to -1 so it changes and sends an on rep.... so silly
Yeah, that's actually a thing you can quickly overview đ
Kinda wish this wouldn't be the case tho
Yup, total brain fart...
Pixel streaming for a MP game? Why exactly ?
that would be very easy to access as like html5 games
i'm not sure if pixel streaming can do this. thats why i'm asking it would be great if it is
Ah.. I see. I don't think that is the right solution for the task. I'd use unity and build out to webGL. I think they still support doing that.
it is good but the size is a big problem. the main task here is easy to access not loading 300mb game
Well another thing to consider is that pixel streaming will offload the work onto the amazon web server which will have a GPU cost tied to it. WebGL would just use the clients computer GPU.
So yes pixel streaming would be lightweight to the end user, essentially like cloud computing/gaming
But you'll have to spin up an instance of the game per client that jumps in
Unless you do some sort of local gameplay that runs remotely and have multiple users access the same instance, that might be possible never tried but that is less of a multiplayer question and more of a pixel streaming question
On top of that there are other existing solutions to hosting application online you could look into but again this is less of a multiplayer question and more of a cloud gaming question
So what you're saying is that when we come through on the client we need to spawn the actor on the server and with a server RPC and set that created actor as the clients weapon?
If it's a replicated actor, it should only ever be spawned on the server if you're expecting the server to have authority of it. Not sure why you would need an RPC. It likely should be handled VIA the actor's reference VIA a replicated variable and if you need something to happen after the variable is replicated, then it should be an OnRep.
Okay so make sure the actor is replicated as well as the variable reference. And in the begin play with the client it will spawn it on the server and set the reference and since its a replicated variable the client will get that updated reference? Just wanting to make sure I understand the whole flow so I can actually learn and not just try and mindlessly program what your saying, sorry if the repetitive questions are super annoying
Why would your client make the server spawn the sword?
If the sword is supposed to be getting spawned along with the client's character, then you can do it on Begin Play, but it should be on the authority/server side only.
So, I'm using the FPS Multiplayer Template. And when I play the packaged game and click create game. It's just stuck on the loading screen. Here is are my host game blueprints:
And this is what the publisher said when playing multiplayer
Option 1 Using Steam
-Download the demo from the discord
-Open steam and leave it open
-Make sure that the steam download region is the same for all the players, this can be changed in Steam->Settings->Downloads ->Download Region
-Open the demo
-Create/Join a multiplayer game
That's for the demo which I think also applies to the actually project
I must have misunderstood the "it should only ever be spawned on the server". The problem im trying to solve is that the Role for the weapon actor reference in the players inventory does not match the owning players Role. I was told this was an issue yesterday and have been trying to track down the correct way
So your saying something like this? c++ void UInventoryComponent::BeginPlay() { Super::BeginPlay(); // must spawn in our default mod so that it becomes usable if (GetOwner()->GetInstigator()->HasAuthority()) { FActorSpawnParameters SpawnParams; SpawnParams.Instigator = GetOwner()->GetInstigator(); AModParent* ModParent = GetWorld()->SpawnActor<AModParent>(DefaultModClass,GetOwner()->GetActorLocation(), FRotator(0,0,0), SpawnParams); if(ModParent) { // we want the default mod to stay forever so set never destroy to true and destroy the mesh component DefaultMod=ModParent; DefaultMod->bNeverDestroy = true; DefaultMod->bIsDefaultMod = true; DefaultMod->MeshComponent->DestroyComponent(); DefaultMod->OwningPlayer = Cast<ANetworkChar>(GetOwner()); } } }
the GetOwner()->GetInstigator() is just the owning player of the inventory
That looks ok to me. Yeah, when I said "should only ever be spawned on the server" I was meaning that however you do do it, it should be on the server, but I questioned why you were trying to have the client ask the server to spawn it as it is on Begin Play anyway and since Begin Play already fires on the server as well, you may as well let the server handle what it needs to handle.
Sounds good, yeah it already works on the server side and once I have that "DefaultMod" replicated it should work for the client side as well
I've set the "DefaultMod" to replicates and have setup an OnRep function as well to tell me that it has been replicated. However, when the client runs its begin play and makes it into that if check telling me its running on the server and the default mod is changed its never replicated down to the client?
Am I mistaken in thinking that is how it should work?
Is the inventory component also replicated?
Does anyone have a good tutorial or something for multiplayer elevators? I have m-player elevators working in general, but I have an issue where clients see the host jittering. The host sees all clients move smoothly, all the clients see other clients move smoothly, but all clients see the host jittering. Is there some magic settings I should be checking to fix this?
It is set to in the editor
I know its getting into that if check for Authority when the client spawns in but it just doesnt replicate the mod down to the client
So I'm trying to set replicate a variable that im setting on the server in a begin play function. Im doing it as shown in the images below. For some reason though when the server sets the variable in begin play it doesnt replicate down to the client and call the "OnRep_DefaultModUpdate". I'm not sure if there is anything im missing, any suggestions would be much appreciated:
(bump)
I'm starting to think this is some kind of an engine bug. Anyone knows how can I debug this issue further in the engine code?
It turns out in the AModParent class I needed a "bAlwaysRelevant = true" in the constructor...
that's not usually a great way to solve a replication problem
network can handle only so many relevant actors at any given time
some need to be always relevant, but that comes to about 10% of use cases
No. Player right clicks, uses client side pathfinding to get array of waypoints and then provides direction to first and input of 1 to add movement input node until reached then onto next waypoint.
Guys i have a public IP installed, i have added port 7777 TCP/UDP on my routers port forwarding. added port 7777 on my firewalls inbound and outbound rules with edge traversal enabled. but yet when i launch a dedicated server exe on my PC and make a person from a different connection / IP join my PC, it says connection timed out
btw my IP gives ping response to other networks so theres nothing wrong with it
ive enabled and disabled the firewall on my router as well and then made clients join the game, yet they get timed out
I'm trying to get sprinting to work in multiplayer but it just feels really laggy and doesn't sprint
You'd also need to run the server function code on your client
But very big note. It's kinda just not possible to make a proper sprint system in Blueprints only. You actually need C++ for it
You'll notice the "not working properly part" once you play with some lag
Also, you should set the Sprinting variable on the server rather than only on the client
does anyone know how do i fix this i need this connected
On CreateSaveGameObject, do you have to option to select PlayerSaveObject as class ?
does anyone have good steam multiplayer course? (tried watching DevAddict/Jeff course already)
If I have a NetLoaded Actor with a small NetCullDistance and my Client Spawns outside of it.
And the Server then changes something on that Actor, which results in an OnRep Variable being changed. Shouldn't that variable replicate and trigger the OnRep when I enter the CullDistance as a client? o.o
yeah it should
Hmpf, it doesn't
I'm drawing the CullDistances (the sqrt of it) with a sphere collision, so it should be accurate
Walking into it as one of the clients just doesn't update the OnRep var
It starts on Empty. It gets set to Loading -> Loaded on Overlap, which calls on everyone even without being in range of course. Then the Server does something that sets it back to Empty, which is not replicated to out of relevancy range player. But walking back into the sphere doesn't cause it to update ;_;
Hmm yeah it should do, unless it's the same as the default value of that class for some reason
Hm no, it just tried something else
I left 1 client outside of the range
And cause the loading and the firing with another client
means Loading -> Loaded happens again on everyone cause of overlap
And Loaded -> Empty happens on Client 1 and Server
When i walk into it with client 2 after that it works
If I do it with the Server and both clients are out of range, it breaks or so idk
but the values are replicated properly?
I mean, I guess? It's an OnRep enum that the Server sets
I mean, do you check if the value on client is the value on the server if you enter your sphere of interest e.g. does the value replicated properly at all
The Value properly replicates if everyone starts in the sphere
Does it replicate in the cases where you don't receive the OnRep ^^
No, the variable simply doesn't replicate for Players that walk back into relevancy range
Ok. you don't have any fancy rules added to the replication of the properties?
Hm?
define the property and the on rep stuff in code instead of data (as rep notify is handled different for code and data IIRC)
You mean C++ vs BP?
yep
so did you test it to reduce the unknowns
No, that's also not a relevant test. The Project also doesn't have enough C++ to quickly do that
The variable OnReps just fine if I stand in the sphere when it happens
The value isn't even updated on the client
I can make it Replicated instead of OnRep
And we would have the same issue
The Client that walks into the relevancy range doesn't seem to get an update
even though it should
That's the whole idea of it
Got that. I just mean, to identify the bug, it could be worth to test if the same happens if you try the same in c++, so if it's a BP specific issue or a general replication issue đ
Yeah I get you
It weirdly enough works fine if one of the clients issues the change
If the other one walks into the range it updates their variable
Well "issues"
It's a Server RPC then of course
But shouldn't matter. Server Clearly set the varaible to "Empty" and the Clients have it set to "Loaded"
Even if I change it to Rep instead of OnRep, it should at least update to "Empty" for a client that walks into range
Gnaaah ue4 why are you like this
Wait if it's outside of relevancy range, the client shouldn't have the actor at all
NetLoadedOnClient actors don't despawn
Ah kk so it's placed in map
Yeah
It's a Cannon to be precise
Walking into an Overlap loads the cannon. Walking over another one waits for input to fire it
That all works fine if everyone is in range
what engine ver btw?
4.26
Hmm
Out of interest, what happens if you uncheck NetLoadClient?
So it spawns an actor on startup
Question on that.
If you have an actor that is net loaded, how does it get linked to the server? Is OnActorChannel open (was that the client side of things) called for it and then closed again and reopned?
They're linked by FName
Since if they're in the map then they're stably named
And net addressable
But yeah it should be opening/closing channels IIRC
then I'd set a breakpoint there and see what happens^^
I can't realyl compare it to NOT NetLoadOnClient
Cause then they spawn without the Actor to begin with
What I did try was not setting the load state on the Client on overlap (so no prediction) and that seems to help? Idk why it would though.
Oh no
Oh
Is it that fucking bug
well yeah that's probably the issue then
I didn't realise you were changing it on client
No it's probably this annoying bug
That it compares the State with the Archtype
Instead of the instance
asdjklgfasjklfgaj
onrep is only called if the value is different
The value is different
but if you predict its not, right?
But it might be comparing to the archtype
If I predict then the value is 100% different
All have it on Loaded
yeah but server doesn't know that
Server sets it back to Empty
So it won't send back "empty"
Eh
If it never acked "loaded" for that client, it'll never send "empty"
And since channels are opening/closing, it won't send anything initially because it thinks the actor is in "empty" state
So if the client predicts something when the actor is not net-relevant, then it'll be permanently out of sync
Don't đ
Am I supposed to not NetLoadOnClient
Even Epic say they predict as little as possible
Hm
Okay, guess I do it server only then
That said, there is also this nasty archtype bug
That would be my guess as to what's happening anyway
but I think that had to do with Instanced changed variables
E.g. Blueprint has it set to Empty.
Instance in the Level has it set to Loaded.
Server sets it back to Empty when the Game Starts (everyone is relevant).
Breaks
Wonder if that's fixed in UE5
usually surfaces if you have an actor with a boolean state
IIRC we made "spawners" for some of our permanent actors in HLL to skirt around issues with startup actors
Though it was so long ago I can't remember what they were
Yeah we had Actors in The Ascent that had boolean states, which were e.g. false by default.
Like "Is this Terminal active?"
Some instances in the level were set to true, and later deactivated runtime again.
Client never got that update.
That does present an interesting edge-case though, if you predict something client-side and never ack it with the server because of relevancy, it could go permanently out of sync
Turned out that deep down in the code, for whatever reason, they compared the value with the BP Class value, but only in specific scenarios. Never got around fixing that. Not even UDN was able to help
Wonder if it's linked to that age-old issue where in-map actors would occasionally drop their saved properties
BP Class is the Archtype or so in their code
You can find that issue on Google quickly. Someone fought that a while ago with a simple pole actor that was in the floor by default
And outside the floor if hte boolean was flipped
Should 100% exist in 4.26
But I think, iirc, it had to do with flipping the value on BeginPlay back
So:
BP Class: False
Instance in Level: True
OnBeginPlay (Server): Set to False
Something like that
Maybe, but I haven't encountered that in ages
I made a multiplayer lobby using advanced steam session but when i load a new level using open level it just restart the current level. How can i fix?
What's the bug that happens in this scenario on the client?
It never updates to False and Client has the value set to True?
you need to travel, not open level
how can i do that?
Yeah iirc
Basically you would expect it to update back to false, case the server sets it.
But somewhere it compares to the BP Class value, so Server thinks it's not dirty.
A random ass delay fixes it. Not even frame based.
Even though it can't have anything todo with latency
bump đĽ
should i use it as a console command, right?
think so, not sure if blueprint has a specific node for it
When are you changing that value?
okay ty
take a look at seamless travelling
If that's the callstack that should be easy enough to fix. Also I've never run into this in the wild, because I've never had a property that's meant for instanced BPs to modify but hard set in BeginPlay đ
I'm changing that value after an input release (its weapon system, player (listen-server host/authority) releases the input and sets the value to false)
They had a Component on the actor that initialized it. So the BP Class was False, the Instance was True and the Component initialized it back to false on BeginPlay iirc.
Not sure why that was a setup anymore. Might be savegame related or so, not sure
If the client didn't ack the "true" value, it won't send the "false" value
Possibly changing between true/false too quickly?
Bools are useless for fast network changes
I'd say sure if there's an engine bug that's a bummer, but I'd also say that setup is tragically flawed đ
No, I wait 3 secs at least
Yeah, maybe, but it should still not happen. It was not even fixable by some delay.
The only way we got to fix this was by turning the Bool into an enum and setting the BP Class to some invalid entry
E.g. Invalid, True, False
lel đ
:D You lel, it had to figure out why that happened in the first place
I feel your pain
And it was not at all clear why it randomly worked when adding a 2.34524523 second delay
On the Server, that has no "ping"
As if the Engine takes a random amount of time to say "hey, you need to use the default value of the instance, not the BP Class!"
Uff, anyway, I will change this code to run on the server only. But first, walking the doggo.
would've been great if you still had the context on this
to go fishing in the UE5 codebase and make a PR if it wasn#t fix
Ya, been too long, but you can try to repro it :P
It's not a big setup
takes maybe 10min
or 5
Make an Actor with a StaticMesh. Add an OnRep Boolean.
In the OnRep, move the StaticMesh upwards by some units on True, and back to the default value on False (some relative z location for example).
Set the value to false on the BP. Place an instance into your level and set it to true there.
On BeginPlay set it back to false on the Server.
Result: Server sees it correctly on the start z value. Client remains seeing it on the higher up value.
Expected Result: Both have it on the start z value.
I'll make notes and take a look sometime
Ah it actually only breaks on the Server
Does not provide anything at all but if it's going to help I'll show my code: https://pastebin.com/WAH5T4fb
Rep condition:
FDoRepLifetimeParams Parms;
Parms.Condition = COND_SkipOwner;
Parms.bIsPushBased = true;
Parms.RepNotifyCondition = REPNOTIFY_OnChanged;
DOREPLIFETIME_WITH_PARAMS_FAST(UWeaponModule, bActive, Parms);
That's even weirder
Left: False (Extended), Right: True (Retracted)
BP Class: False
Ah no, I confused my self, it breaks on clients
Server:
Client
That is the only logical way for it to break :p
Yeah, haha nvm
But yes, 4.26 relatively easy to reproduce. Additional step to see it properly in the Editor is to also run the code in the COnstructionScript
So you see the update when flipping the bool in the level
That is if none of your programmers put a special subsystem in place that crashes the editor when someone adds something to construction script. Just to fuck with the designers on the team
đź
Why
Evil, but why
Anyway, not looking for offtopic. Multiplayer Bug. Feel free to check UE5EA :D
Going to walk doggo now, cheers and thanks for the help everyone
đ
Turns out there are some other people having similar issues, but not sure if theirs are exactly same with mine https://forums.unrealengine.com/t/instance-editable-overrides-repnotify-variable-on-network-client-join-only-when/451555/9
Isn't that basically what I described above?
Okay so shocker I have another question: I'm trying to run a server RPC from an actor with a Role of SimulatedProxy and it just doesnt actually run the RPC it just skips over it more or less. Are you able to call Server RPC's from a SimulatedProxy? The actor is being spawned in on the server in the clients BeginPlay and replicated down to the client, does anyone have any insight in this situation?
No you are not allowed to call ServerRPCs on simulated proxies
Server and ClientRPCs only work if the Actor is owned by a Client
And ServerRPC specifically only if the owning Client calls it
So should I be spawning in the actor differently to be able to allow it to call those RPCs or should I be following a different kind of work flow where I dont try and run RPCs within repliciated actors like I am trying to do?
Depends
If the Actor belongs to a Player, the nspawning it on the Server with the specific Player(Controller) as the Owner would allow you to call ServerRPCs on it
Think a Weapon that the Player carries
If the Actor belongs to anyone, then you should perform the RPC elsewhere, somewhere where the Client has ownership
Think a Door in the Scene
This problem often comes up when peeps try to make an Interaction System and trace something in the Scene and call the RPC on it then
Thats the exact situation that im in, im trying to call these RPCs from a weapon that the player holds
Then you should be fine passing in the Controller of that Player
You usually spawn Weapons after the Character is possessed
So not on BeginPlay
Character has an OnPossessed event
Or PossessedBy or whatever it is called
Only runs on the Server
spawn it there and use GetController for the Owner
Or fwiw the Character itself
Since ownership is basically recursive
So I need to be able to give the spawned actor's owner a reference back to the owning players player controller some way of which your saying is best to do form within the characteres OnPossess?
In the very specific case of spawning a weapon for the Character, yes
There may be situations where you do it elsewhere, as long as you pass in an Owner to the SpawnActor node that is either PC or owned by the PC
Read the ownership part in the Network Compendium
It should help clear things up
It is worth noting that im doing all this in c++
Doesn't matter, the SpawnActorParams have an Owner property
If im spawning in the actor within an actor component attached to the player does that change anything? Would i just be able to get the player controller by getting the component owner and calling GetInstigatorController()?
Yeah, whatever way you cna get it
GetOwner on the Component is the Character
Get the owner of that
And you already have the PC
Aha. In hindsight, that makes a lot more sense đ So just do pathfinding on the client side and feed that into AddMovementInput, which will automatically make prediction and networked movement work as expected.
I usually have a CharacterPointer in my Components that I init from Owner on BeginPlay or so. Then doing GetController() is straight forward1
That makes sense! Ill give that a shot and see if it fixes the situation!
Hey so it really seems like my event tick never runs through the client version of my update slide function, despite the client being able to slide exactly like how the server does. This is a problem because the client never gets to the F0V control macro which adjusts the FOV of the camera based on the speed of your slide. Anybody have any ideas why? (This is in event tick)
:<
So many RPCs on Tick
You theoretically only need one
The one that tells the Server that you want to slide
And to be rreeeeaaally picky
You can't do movement properly in BPs anyway, as the only way to not get corrections at start and end of your actions is to use the CMC and send your input info along the ServerRPC that the CMC uses for Jumping, Crouching and general movement.
Also ClientCheckGround being a Multicast makes no sense
You aren't executing it on the Server
This setup looks generally like a clusterf'ck that will be hard to ever get done properly
If you need complex networked movement, you should learn C++ and the CMC, it's sadly just that
Is there an easy way when debugging (like actually stepping through the code and inspecting the variables and whatnot) to check to make sure the actor has its ownership set correctly? I think i fixed it but its not working and wanted to make sure the information is correct
To answer the question itself:
Hey so it really seems like my event tick never runs through the client version of my update slide function
Probably cause it's a not a normal event but a Multicast, which Clients can't execute
And the ServerRPC would only run on via the OwningClient, not the simulated ones
Check the Owner on the Actor maybe?
So your saying this Owner ref in the AActor shouldnt be NULL or am I looking for a different specific Owner variable?
Yeah
Saying "Sorry" at the start doesn't make this any better.
It's not allowed. Use the Job Board
Yeah, so is everybody else. Rules are rules though (: If you don't want to catch strikes you should make sure to read them. Otherwise your reach turns very small.
Check #instructions For the job board
We have 11 rules. Rule 8 is literally about this :D You aren't scoring points
Cheers
hi, i'm using advanced steam session but when i use servertravel nothing happen. How is it possible?
i mean, it works only when i play as Listen Server
Can you try to rephrase that and give more information?
Because Sessions and ServerTravel aren't directly related
nvm i fixed
What is the crash error?
@dreamy oracle https://youtu.be/RtQRMcupJs0
This could help with learning how to do networked movement in the CMC
If u needed resources
Thanks for the vid!
Currently building a different way than Debug so that it will give me some kind of statement
Someone told me you shouldn't let clients connect to databases, is this true? Shouldn't it be fine for clients to read from a database, just not write to it?
So then how do games give players their level when they aren't in a game?
You contact a public-facing API that does the query against the database for you.
Ah damn
More complicated things to learn. Thanks for the info
I think team tree house has a course in making APIs lol
When i actually build in a development build to let it crash and tell me the error it doesnt crash at all...it doenst work and call the server RPC still but no crash
Does the controller itself also have to be set to replicates?
The Controller is by default replicated
It should give you an error in the log anyway
AWS API Gateways are a pretty good way to expose that. You just hook it to a Lambda function which fetches the data for you.
that does cost $$$ eventually
Is there a specific way I should be calling the server RPC from within my simulated actor?
When using that player controller?
Because Im storing the player controller in the Actors Owner member as such:
Simulated can't call RPC and don't have a playercontroller
Yeah I mean I already said that
Only the owner of that character will be able to do so
Controllers only exist on the owning client and the server
It should be fine to just pass the owner via the spawnactor params
And that's it
There are no other special requirements
If only someone would write a compendium on this stuff
So here's a question. Standard character in UE4.26, nothing really added other than printing velocity if simulated proxy and velocity isn't 0. FPS capped at 30fps to reduce log spam otherwise this looks worse.
LogTemp: vel 106.301460
LogTemp: vel 159.662140
LogTemp: vel 159.662140
LogTemp: vel 213.789612
LogTemp: vel 240.260269
LogTemp: vel 266.940063
LogTemp: vel 266.940063
LogTemp: vel 320.090607
LogTemp: vel 320.090607
Notice the repeated values? It's both updating velocity too infrequently and too incorrectly. Question is... how do I get correct velocity value on simulated proxy đ
Thanks for providing me a starting point, I'm not worried about any money issues or anything like that. It's just another thing under my belt to add :) really appreciate it
This is the comment i was going off of for the logic i was applying with thinking I would be able to call RPCs on my simulated actor
Is that logic not correct?
It is. Again there is no magic behind this
Spawn replicated actor on the server, pass correct Owner and you can call ServerRPCs from client side on it, but only from the owning client
Any other client can't on that actor
I believe I've check all those boxes. I spawn in on the server and replicate refrence down to the client. Im setting the owner correctly since I can see its owner being the PlayerController with the AutonomousProxy Role
Yeah then it should be fine to call server rpcs
Everything that doesn't work is up to debugging
Why is the CMC such a pain to extend, I'm also just bad at this.. But it's still a pain xD
The docs mention how to at least somewhat extend it but doesn't really go into details too much.
The docs couldn't possibly cover it. You just need to read it. It's huge
It's not really designed well
They wouldn't have to cover it all if you ask me, I understand that's a bit too much. But I would have loved a good example of extending something with custom data đ
It's been out there for many years in various forms, community wise
Is there a smarter way to get Add Impulse to replicate nicely to Autonomous proxies than to do an RPC? It works by default for simulated proxies due to their simulated tick interpolation etc which updates the velocity, but that's not the case for Autonomous proxies.
I mean, is there sth in the CMC that I could configure to get this done or maybe something better than Add Impulse?
CMC should be using LaunchCharacter, not AddImpulse.
i need to have a replicated struct, however each value in the struct is dependant on another due to an initialization sequence - is there a way i can check that the entire struct has been replicated successfully (cleanly) before performing clientside logic to work with the values ?
is NetSerialize what i need to be looking at ?
you can use PostRepNotifies, it will get called after all OnReps are done
something similar to what USceneComponent does here:
void USceneComponent::OnRep_Transform()
{
bNetUpdateTransform = true;
}
void USceneComponent::OnRep_AttachParent()
{
bNetUpdateAttachment = true;
}
void USceneComponent::OnRep_AttachSocketName()
{
bNetUpdateAttachment = true;
}
void USceneComponent::PostRepNotifies()
{
if (bNetUpdateAttachment)
{...
how does PostRepNotifies work with replicated structs, is it going to wait until each property inside the struct finished replicating and its happy ? also what happens in the case of one of these values is changed during play
does PostRepNotifies know to fire again or is that just an initial one time thing
it will get caled after actor has finished calling all its repnotifies
mostly, yes
I tried it with launch character and it didn't seem to replicate the new velocity to the autonomous proxy either.
FHitResult has an excellent example of that, its quite self explanatory
thanks, will take a look now
also, docs for NetSerialization are in NetSerialization.h header in few pages worth of comments
I use PostNetReceive for that stuff, hows it differ
i do too, but felt silly to post an engine example and tell him to use a different function đ
Just bumping this. Simulated proxy characters not getting sane/usable velocities
The red/orange locator in this video is determined based on velocity and it jitters like crazy on the larger window (simulated proxy)
Can't do distance matching without getting proper values
that kinda looks like one of your scene components is replicating, probably the skeletal mesh
I just made a new c++ character, added the logging, made a blueprint, chucked mannequin on with a new animation blueprint
Didn't change anythin like that
But nah the character jittering is from distance matching and the fact the velocity isn't updating properly creating fluctuating predicted locations
If I remove the mesh entirely I'll still get abnormal values when debugging velocity
One moment, I'll figure out some better debugging setup
Seems stable at max speed I guess but that's the one time I don't care about it đ
Blank character with this now
The jitter is a lot more noticable when not recorded in low fps video too
Wonder what Epic did in Paragon to get usable values
- Sane (auto/auth)
- Not sane (sim)
Is it possible paragon had to have simulated proxy actually compute velocity at least to some degree
I found a good enough solution by making simulated proxies compute velocity between replications (and replicating input to use with acceleration) on tick (not physics loops)
I am trying to make a multiplayer game, and am having trouble. How do i connect to a server that is not on my local machine? I am using AWS computer to host my server files, but when i type in hte IP adress of the the ASW computer, i cant connect. How do i fix that?
any youtube videos you know about? i tried searching and cant find one
hey, so quick question. Can I take the default shooter game in unreal and make it multiplayer?
if yes, then how?
Yes. By adding in replication events and using replicated variables where necessary. Check the pins in this channel for more information on how to make something multiplayer - the top 2 should give you a good start on how multiplayer works.
Thanks
Uh, I am pretty sure that the multiplayer was already set up.
but how can I give the exe or linux build to other people and ask them to join?
@sinful tree
you can setup a listen server with port forwarding or using hamachi i think
I have no idea what you are talking about. Could you give me a tutorial on how to do port forwarding?
Is there a way to replicate ai on the client side because character movement only works on the listen server đŚ
In multiplayer, the AIControllers are usually only present on the server and are not really meant to be replicated as it's technically not necessary. You're saying your AI appears to move on the server but not on the client? Is the pawn that the AI is possessing replicated?
Anyone know how I could replicate this? So that the flipbook is set on server so other's can see it
@sinful tree ?
Datura I tried looking into it more on like server changing all clients to a new level with the combo box but nothing
yes the ai moves on the server
but not on the client
and yes I believe the pawn is replicated
this is the pawn Im using
This video will show you how to create a multiplayer game using Unreal Engine.
- Links -
Website: https://elias-wick.com
Patreon: https://www.patreon.com/EliasWick
Twitter: https://twitter.com/EliasWick
Instagram: https://www.instagram.com/EliasWick
I followed this tut
uh, how do I ask others to join the server?
Hmmm.. I'd try disabling the replication on the AIController as by default it's not needed. Below are the replication settings I have on an AI controller that is operating no problem on my end and moving using a behavior tree.
There's not much else to go on with what you've provided so far as everything else looks like it should be ok in terms of replicating movement.
You could try even a more basic AI - just a series of "AI Move To" nodes on begin play of the AI Controller, just to see what happens. If it's still not moving around then maybe it's getting stuck somehow?
Hi, being in a setup : Run a dedicated server, run in one process disable and playing as a standalone client, I would like to work on the connection system, so without being auto connect to the server unreal starts when clicking on play.
I can't find a way to connect to this local server, trying to scan for session, even with open 127.0.0.1, I'm missing someone ? Thanks
So I'm not sure who has been following my journey of the non replicating actor and I'm sort of hoping I don't have to retell it, but I managed to get PIE to start and not crash with "Play as Client" and it's still not replicating. Not sure if the server and client share the output log window in the editor but I was getting gamemode logs in it đ¤ˇââď¸
Is it possible to use a PI 4 (8GB) to Run a dedicated server?
My proxy also existed in the outliner thing but I got no messages of the "on rep" function being called
wait so why is multiplayer sprinting impossible without c++ ?
Hi, I think I'm missunderstanding something about PlayerState... every PlayerController contains a PlayerState which is use to replicate to all clients information about a particular player in the game right ? But only owning client & server has PlayerController which seems totally right, but how does the replication of PlayerState works then ? If client doesn't have PlayerController of other client, how does the PlayerState replicate and can be use by all client to get informations about other players ?
@vital bramble what you are going to do? lets talk about that first
Nothing particular atm, I'm quite new to UE, and I'm trying to understand the lifecycle of network I would say, understanding how everything is linked together
Gotcha. Think about 'world' for a while. When you are connecting a server, you are connecting it's world. And anything happens in that world triggered by server will also happen on other clients. When server spawns an object/actor, if it's set to bReplicates = true the instance of that object will be created in every connection. That's the 'object replication' itself.
There is also property replication, when you create that object, if you want your clients to access it from other classes you want to mark it as Replicated on UPROPERTY
And UE will use NetGuids behind the scene to replicate that object's reference/pointer
PlayerState is declared in APawn class
Which exists on every client if you spawn it from server
PlayerController accesses the Pawn and gets the reference
So if you need to access PlayerState from all clients you can just call GetPlayerState from Pawn class
Ok get it for the moment so basically, the world replicate himself on all client's world to make it simple. Actor are replicated (and only the actor, without his component), and then if you want some properties in component to be replicated, you mark them as Replicated
When you say PlayerState is declared in APawn class, I don't understand because I can see in engine source code, that AController has the PlayerState variable
I might be wrong at this part, I used my weak memory to say that đ
OK, it might be possible that the PlayerController on the server replicate any change made to PlayerState from either the server or owning client on the pawn, and that Pawn is replicating to all client, which in itself, it will propagate to all clients right ?
Yeah but even if APawn hadn't a reference to PlayerState it would still replicate to other clients when you make a change from PlayerController by accessing that PlayerState reference
Because property replication is just 'property' replication, when you replicate a pointer to object it will just become accessible from everyone. Object can still exist on everyone's world even if they dont have a reference in anywhere
Just to not confuse you more, short answer is yes
But of course if you are making a change from client you need to send a Server RPC to make it possible
Ok, so replication works "automatically" from server to clients, but not from client to server ? I need to make an RPC on this case ? Can't simply modify my variable right ?
so replication works "automatically" from server to clients
Yeah, properties marked asReplicatedwill be updated automatically behind the scenes in the engine. Also setting transform and spawning things will work automatically too because actor transform is replicated viaFRepMovementstruct in AActor and has an OnRep function. Spawning is a special case that engine handles for you. Rest is as I said, just property replication
but not from client to server ? I need to make an RPC on this case ? Can't simply modify my variable right ?
yep
but not from client to server ? I need to make an RPC on this case ? Can't simply modify my variable right ?
If you have aint32 X;marked as replicated, and want to change it by client, you send a server rpcServer_SetX(yourvalue);and server sets it
Then it replicated to everyone
Further and advanced topics covers prediction, lag compensation etc.
Even worse (most thing I hate to implement) reconciliation
Ok, and in the case I want prediction and set X in client before sending to server, I'll need to handle it right ? And when server replicate X to client, it also replicate from the sending client right ?
Yeah, you might want to have Cond_SkipOwner on that properties replication condition though, depending on the case
If its a movement component that frequently updates that variable you dont want server to teleport you back to your previous sent location
But if its just an integer that only updates a few times in the game just setting it locally and sending to server is fine
Though be careful OnRep func wont fire in that case
Because OnRep is fired if current value and updated value is different
To workaround this you can do this:
DOREPLIFETIME_CONDITION_NOTIFY(AYourActor, Property, COND_None, REPNOTIFY_Always);
Oh ok! Right thanks a lot for all the explanation đ I'll keep diving into the lifecycle (got to see Session, game mode, game state, etc haha) might need some help again in the day! Thanks anyway have a good day!
after joining a steam session i'm still alone in my level but log says that i've successfully joined my second pc's session. Maybe i need to travel or something?
yo i made a multiplayer sprint system in bp
Now have fun to try the system with lags :D
The world would be perfect with no lags, but that's sadly not the case đĽ˛
With lag i mean ping btw
I really don't wanna bring bad news, but from all i know now it's impossible to make a proper sprint system in BP only as you need C++ with its client prediction.
Once you play with ping (which isn't the case when you play via the editor by default) it will quickly break. At least for playing clients. Playing server will work
BP + Custom CMC features for Multiplayer = Nope
It wont work, you gotta suffer implementing bitflags, custom movement states and derived classes that holds movement info
That's what gods of UE decided
Hey again! Got a question which is bit more concrete this time, I have coded a camera system which works quite fine in singleplay, but seems to broke totally in multiplayer, long story short, because I needs the player character in the initialization state, but I think that it is not already spawn on the server, so it broke it up.
Anyway, I just thought "anyway, camera on my case has nothing to do with server, it is an actor which is not replicated and it is not directly attached to the player position"
The problem is that it is my PlayerCameraManager which handle the SetViewTarget with my camera actor, and it is a call I only do on client side, and it seems like server doesn't really like this fact, and will fallback to default camera, does server also need to be authoritative on camera ? Dunno if that's really clear
ok idk if this is a bug but if you try and join a session then try and host a session it crashes the engine
Anyone have this error with the advanced steam overlay? LogPluginManager: Error: Unable to load plugin 'OnlineSubsystemSteam'. Aborting.
i get this when i try to open the game after packaging
Hrlp! đ¤Śđťââď¸ i spawn from the level bp replicated AIs⌠works great on server and client. BUTTđ if one spawns, on client spawns also a lifeless version which has no collision or movement
How can i travel all clients to another map and be executed to server pls need help on this
By performing a ServerTravel on the Server Side.
Preferably Seamless
Show the full spawn code
You are probably runing it on both while replicated actors should only be spawned on server
Maybe try #online-subsystems
I tried executing the server command, but it doesnt change anybody elses level
ooh i didnt see that, thank you!
well on the change level command on my controller
Why are you calling Open Level?
If you call that on the Client they will disconnect
Doesn't matter, you only need to call ServerTravel
OpenLevel are hardtravels, they will disconnect the player
E.g. moving back to MainMenu
ahhh ok
i wish i had my updated code
but it would look something like this to execute server command with an append
this is what i am doing:
if i run only on server still the same
Where is the spawning
That's not spawning
in targetpoints
Yeah then you need to make sure it's already ont he Server before calling it
Too much stuff I don't know about to really help, make sure the SpawnActor is called Server Only
danke, wieder was gelernt
You are aware that not everyone understands german here, right ? xD
I do, but @rocky night please stick to english.
Just started to use a PlayerCameraManager. It spawns on the server and the client, but isnt replicated. Whats the point to this? I'd understand if it was replicated because the server can verify data but its not so why is it even spawned on the server? Hasnt had an effect on me yet but i want to make sure that this wont cause issues later on.
Probably so the server can work out where the player camera is meant to be?
Aright
Sorry đ
Is it possible using the null/no networking sub system to have a user connect to a listen server over the internet?
Is it possible to allow player's to join other's server's without having to use port-forwarding as the host
depends if they are on the same network
if not, then not really without setting up a VPN
if yes, then yes
is there any caveats to spawning an actor from a UWorldSubsystem? im trying to figure out why its not replicating to clients and honestly im out of ideas
Do you know what world is your UWorldSubsystem is in?
Needs to be in game world
eh what?
the subsystem does not contain any replicated properties
im using SpawnActor from a function inside of my subsystem but its not replicating to clients
like.. it doesnt exist at all
Do you have virtual ShouldCreateWorld() on your UWorldSubsystem?
i have it in my class yes
Then the world subsystem should be created for game world,
Weird,
But the spawn actor replicates normally if spawn not via WorldSubsystem?
this should work as we also do it
the subsystem maybe initing too early in the UWorld initialisation so you might need to use one of the world delegates to wait until the world is ready
oh interesting i wasnt aware there was delegates for UWorld. i think ive figured out whats happening but i dont really know why its happening. i was spawning my proxy in UWorldSubsystem::Initialize which ... was being weird. spawning the actor in AGameModeBase::BeginPlay works fine
im doing some more testing right now to confirm this
try using the FWorldDelegates::OnPostWorldInitialization delegate to spawn it
(also checking GetWorld() == World)
ah thanks. ive moved my code around so that GameMode::BeginPlay calls a function in my subsystem which spawns it. delegate might work better though. i have confirmed its all working though which is great :D [2022.02.24-23.26.41:769][193]LogTemp: Warning: AJobProxy.GetLifetimeReplicatedProps [2022.02.24-23.26.41:769][193]LogTemp: Warning: AJobProxy.GetLifetimeReplicatedProps [2022.02.24-23.26.41:769][193]LogTemp: Warning: AJobProxy.OnRep_Jobs: Jobs Replicated [2022.02.24-23.26.41:769][193]LogTemp: Warning: AJobProxy.OnRep_Jobs: Adding jobs to subsystem except that its crashing now which i think i know why
yeah but I think it's a bit more elegant if the subsystem is able to self-manage it somewhat
even though the proxy actor will need some clientside code to register itself with the subsystem
or do they have to be public
yes
@peak sentinel didnt you say you were having the same/similar issue to me?
Is 100tb Bandwidth a month good enough for a server?
just to make sure thats not a typo, is it actually 100 terabytes?
That's what the hoster says
what type of traffic are you expecting? that is a ton of bandwidth
Just like multiple 50 Player Servers
It's a light game nothing too heavy
should be way more than you need.. like way more.
Imagine... 10KB/s per player (probably overestimated)
Estimated average concurrent players 100
= 86.4GB per day.
per month = 2.5TB
you could probably host like.. 10k servers on that
So yes.
yes
depending on the price though i would recommend seeking a lower bandwidth if its cheaper
What hosting platform is this?
It's called NameCheap
Where I'm getting it from.
It's like around 108 USD every month. 6 Core's, 960GB SSD x 2, 100tb Bandwidth, And 64gb RAM.
Idk, first time hearing about it,
I use AWS GameLift,
How you are going to handle scaling with that?
One more question. I'm pretty sure but I want to double-check. Is it possible to host dedicated servers on Linux like Ubuntu?
so im using the delegate and my proxy actor is spawning on the client but its not replicating any properties. im using FWorldDelegates::OnPostWorldInitialization.AddUObject(this, &UJobSubsystem::OnPostWorldInit); and spawning the actor inside OnPostWorldInit
yes you just need to build for it afaik
Maybe thereâs one a bit later then?
OnWorldInitializedActors worked :D
is there a way to set the editor to play a client without starting a server?
If you do not connect to a server, then you are playing standalone, which means the instance you would be playing in is effectively the server.
thats not at all what i asked
But it is effectively the answer to your question. You cannot have a client without a server.
The editor itself cannot act as a client unless it is connected to a server.
sorry i didnt realise that was a thing. i assumed you could have a client without a server and that a client just had no "server" functionality/authority. this might explain why GetWorld()->GetNetMode always returns standalone even when im connected to a server? idk
GetNetMode() will only return NM_Standalone in single player
so I'm not sure where you're getting that from unless you roll your own networking
im not rolling my own, but GetWorld()->GetNetMode is NM_Standalone on my connecting client :(
where are you calling this
are you sure it's not on an actor instance in the editor world?
in my OnWorldInitializedActors delegate
yep because its packaged
your world subsystem will initialize for your entry map too
are you also sure it's not there you're seeing NM_Standalone?
... imagine if i actually read in the logs literally the line above that says its for the mainmenu
is the ReplicatedUsing function called before or after the property is replicated?
Is PossessedBy() supposed to run on the server twice when possessing a client?
Mine is and I believe it should only be running it once on the server
after, it would be pretty useless otherwise
you can add a parameter to the function if you need the old value
does anyone know what would cause a TArray<AInfo*> to replicate all null values?
Is your AInfo* replicated?
sure is. its just a single property though but i have GetLifetimeReplicatedProps overridden
Does the instance exist on client?
yep sure does. the picture i posted is the OnRep function being called on the client with the entire array being nullptr
Server could be sending null values, or client does not have AInfo* instance
Btw what is your job system?
what do you mean?