#multiplayer
1 messages Β· Page 725 of 1
@dark edge I wanted to revisit the gun component idea (I was too busy earlier to ask about it). More of an overall design question. Does it not get annoying setting up new actors to bind to any gun comp functionality? Such as firing or reloading, etc.
We have items with Activate/Deactiveate Primary/Secondary, and the item decides what that means.
So a shotgun fires on activate primary
a machine gun starts auto firing on activate primary and stops auto firing on deactivate primary, etc.
We use projectiles in our case so no GunComponent but the idea still holds.
Gotcha. So a base item class and you just subclass that when you want a new one?
yup
i am BACK
ok so
void AMyCharacterBase::SERVER_start_firing_Implementation()
{
IsFiring = true;
const FRotator SpawnRotation = GetControlRotation();
const FVector SpawnLocation = ((FPMuzzleLocation != nullptr) ? FPMuzzleLocation->GetComponentLocation() : GetActorLocation()) + SpawnRotation.RotateVector(GunOffset);
SelfWeapon->primary_fire(SpawnRotation, FPMuzzleLocation->GetComponentLocation(), SpawnLocation, this, Mesh1P, FirstPersonCameraComponent, GetCapsuleComponent(), true);
CLIENT_start_firing();
}
this is what executes first when the lmb is pressed
UFUNCTION(Server, Reliable, WithValidation)
void SERVER_start_firing();
this is the declaration
actually have both:
UFUNCTION(Client, Reliable)
void CLIENT_start_firing();
Yeah - seems quite similar to the actor approach, just slightly less inheritance.
whats best way of getting the network id of a player from a client instance? do ppl use
GetWorld()->GetFirstPlayerController()->GetLocalPlayer()->GetCachedUniqueNetId()
i read them from PlayerStates
How to join or find session by ip?
im not sure whether to put this in #multiplayer or #cpp but im trying to make an fps multiplayer (new to multiplayer) and for equipping the weapon actor i was wondering what the easiest/most efficient way for me to make it so the owner sees it attached to the firstpersonsocket and everyone else sees it attached to the thirdpersonsocket would be, this is what I have right now and it only attaches to the firstperson so everyone sees it attached to the firstperson, thank you (:
Well you commented out the third person part.
How are you choosing which mesh to attach to? Does the 3rd person mesh not exist on the owning client?
thats what idk how to do, both meshes are on the owning client but i dont have the third person one rendering on the owner client
if i uncomment that then it shows on the third person socket only for everyone, not both of them or something like that
Did you write that code or copy it?
Read it line by line
It is working exactly how you told it to
both sockets begin RIghtHandSocket is not a problem?
OK so how are you detecting the owning client in the first place?
do that same thing here
OR
its on different meshes so i didnt think itd be a problem but idk
It's not a problem, you just have nowhere that this code will behave differently on an owning client vs anywhere else.
yeah ik idk how to make it so it does tho
this is my first time doing multiplayer stuff before
How are you handling the meshes?
You're presumably already hiding/showing based on net mode or whatever
do the same thing
Or better yet, make some function that does that and returns the mesh to use
in blueprints i just ticked the thing render if owner
and use that function here
so it renders if your the owner and if not you dont see it
well, fun thing about replicated actors, they tend to replicate the Parent they are attached to
setownervisibilty
and then attach to it OnRep
Is that a part of Replicate Movement?
no
I mean that attach parent should be a movement-related property, but my project does nothing of this sort so I've never encountered it
also im not sure if this matters but the two meshes use the same skeleton, the skeletal meshes are different but the skeletons are the same so it actually does use the same socket
Hello all.
I have a respawn method in my gamemode, but when I try to call an RPC from the player controller to get the gamemode, the cast to my gamemode class fails on the client.
How exactly can I request a method on the gamemode from within a client player controller?
You sure you're doing it on the server?
when you attach something on server, you generally don't need to do it on client
/** Handles attachment replication to clients. */
USTRUCT()
struct FRepAttachment
{
GENERATED_BODY()
/** Actor we are attached to, movement replication will not happen while AttachParent is non-nullptr */
UPROPERTY()
class AActor* AttachParent;
/** Location offset from attach parent */
UPROPERTY()
FVector_NetQuantize100 LocationOffset;
/** Scale relative to attach parent */
UPROPERTY()
FVector_NetQuantize100 RelativeScale3D;
/** Rotation offset from attach parent */
UPROPERTY()
FRotator RotationOffset;
/** Specific socket we are attached to */
UPROPERTY()
FName AttachSocket;
/** Specific component we are attached to */
UPROPERTY()
class USceneComponent* AttachComponent;
FRepAttachment()
: AttachParent(nullptr)
, LocationOffset(ForceInit)
, RelativeScale3D(ForceInit)
, RotationOffset(ForceInit)
, AttachSocket(NAME_None)
, AttachComponent(nullptr)
{ }
};```
Then how do you even know it's not working? It should look the same no matter what, just the meshes are swapped out, right?
its in USceneComponent, so this would require Root component to be replicated for it to break
NVM, they share a skeleton asset, but you're not doing master pose or any of that stuff.
So how DOES one attach an actor to different things on different machines?
good point ill try changing the skeleton aswell
@dark edge I donβt follow your question. I wrote I am trying to call a rpc from the client Pc to a game mode
Show your code
Do a server call to the server PC then in the server function call the method on the game mode.
the cast to my gamemode class fails on the client.
This makes sense - gamemode doesn't exist on the client.
im desperate :(
this is really weird
can you atleast give me some debugging tips
do you need more code? i can give more code
You aren't showing the business end of the firing logic
gimme a mo
void UMyRevolver::primary_fire(FRotator rRot, FVector vMuzzleLocation, FVector vLoc, UObject* context, USkeletalMeshComponent* Mesh1P, UCameraComponent* FPCC, UCapsuleComponent* capsuleself, bool SERVER) {
const FRotator SpawnRotation = cRot;
const FVector SpawnLocation = cLoc;
if (GetWorld() != nullptr && SERVER)
{
FActorSpawnParameters ActorSpawnParams;
ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
// spawn the projectile at the muzzle
AgfProjectileHitscanB* prjHitscan = GetWorld()->SpawnActor<AgfProjectileHitscanB>(SpawnLocation, SpawnRotation, ActorSpawnParams);
prjHitscan->spawn(FPCC, MuzzleLocation, capsuleself, [=](FHitResult fhrResults, UWorld* world) {
if (fhrResults.Actor->IsA<AMyCharacterBase>())
{
AMyCharacterBase* Casted = Cast<AMyCharacterBase>(fhrResults.Actor);
Casted->set_health(Casted->get_health() - 65);
client_notify(Casted->get_health());
}
});
}
if (!SERVER) {
// All of that animation and sounds and other client side stuff
}
}
the way i do this is i use the same primary fire function for both the client and server side stuff because its just less code
this is really weird
so i have another weapon that spawns actual projectiles
if i try using it in this arrangement the actors spawn... but they seem to use some sort of weird logic
blueprints tell me that they have a 999 lifetime (which is what i set for debugging) but they despawn within 15 seconds
or that their spawn speed is 1000 units but they are going at some 10000
It should be working fine. You don't have to call an RPC. OnUnPossess is called only on server on PC
And if it does get called on client, ask yourself how you destroy a replicated actor on client beforehand?(but quite sure it's not)
I usually get weird behaviour when I destory a pawn directly after unpossess. For some reason I still need a delay.
(Unrelated to what you said. Did not know that event is allegedly only on the server)
@fallow shadowIs the weapon owned by the client?
Wait wtf your weapon is a component but you spawn an actor to shoot
this is all sorts of fucky lol
Ok i could change but i dont think that would fix the issue
.
@fallow shadowSo if you do a print string, does the run on server event fire as expected? Are you sure the problem is the actor being spawned, not the RPC to begin with?
im not too sure but im pretty sure the RPC itself works as intended
i put a dummy variable in the RPC and every function it invokes to check if it has authority (its the server) and it always was
is there any way to make my replicated variable update instantly? a run on server event from the client doesnt update the replicated variable for almost 5 seconds
There's a force replication function somewhere.
It's updating slow because your net update rate on that actor is low
ForceNetUpdate
im on a blueprint project, is it still accessible?
It is
ah where would this be?
On any actor really
This is a function
You call it after you change your replicated property/variable
hmm im running this after a cast
is this alright to run outside of the place im updating the variable? appreciate all the help
Yes. Also make sure you are doing all this stuff on the server
yep its on a run on server event
u dont need an rpc
Hello guys,
I am learning the multiplayer on Unreal and I was wondering if the server-side of a game was only the gamemode? I mean, I'm trying to make a little game with a dedicated server but I'm not sure where to put my server logic, even if the gamemode sounds logic to me. Will clients be able to access to gamemode too or it is only for the server?
Check pinned messages on this channel, find Cedric's network compendium and read it
there are just too many questions to ask them here one by one @proven grove
π I'll look for it, thanks
so i have a actor in the world which i want to display a clientside widget but the actor seems to be running on the server even though replicates is set to off
would anyone have any idea how i would make the client control the actor without replication?
With a dedicated server, even though there isn't a local player like with a listen server, is there still an instance of ULocalPlayer on there for each player actually connected to it, or does it only exist client side?
I'm guessing the latter, but was looking for confirmation
The dedicated server instance is no player. Not like the listen server. ULocalPlayer exists only client side, for each client, and server-side for the listen-server player
Replication set to off means your actor won't be replicated to clients if spawned on server. If it's spawned on client, then it's on client, you don't need to replicate it, though the server has no clue it exists, and it won't be synced using the replication system(if you want that). So replication set to off doesn't say anything about where an actor exists, so you need to know where it was spawned.
its preplaced in the world
You don't create widgets for such actors
It just doesn't make sense
You create widgets for players so they are added on screen
Players through PlayerStates/PlayerControllers/Character have a client-side and so widgets can be created there and added to screen accordingly
its a vending machine which displays the players items and money clientside in the world
do you have another method in mind?
its umg
Ok then create for the player
i create the widget on the player and pass it in to the actor in the world
A vending machine can't interact with widgets
oh i have all the stuff set up and working but its the multiplayer replication thats weird
@fathom aspenI knew the dedicated server didn't have a player by default, but as players connect to it, I wasn't 100% sure (until now) whether or not a ULocalPlayer was created on the server side (and not replicated)
thanks for the reply
until now means you still not sure? π
@fathom aspen i call this from the client
but it seems like these variables are serverside saved in the actor even though theyre just called from the client on remote
This doesn't say much to me. And yes you are using widget components which can exist on both server and client. Take the time and read that compendium I pointed out, as you seem to lack basic networking knowledge
If he is using a dedicated server he might have to check that checkbox that loads umg on the server side. I think it's unchecked by default
I haven't read the conversation chain, so sorry if what i said was way off point with where you are at with things
Any help is appreciated!
I'm of the opinion that the Simulated Proxies don't need to use physics at all, and the movement must be taken solely from the authority
can someone tell me how to figure out what functions should be server sided and client sided
Right but there is an experimental option to load it on dedicated servers
I'm pretty sure there is at least. I've never used it though
- Practice makes perfect. The more you dive through the source code, the more such stuff become so easy to remember.
- Use your ration. If the function is doing some authoritative stuff then it's prolly server only.
- Ask in this channel
mhm okay thank you
I don't know about it, and it's 100% not what he wants
Ufunction(blueprintauthorityonly) functions are only meant to be run on the server. Also yes, as wizard said, if the methods implementation is wrapped in a check for "Is authority" then it is meant for the server. If it checks if it's not server then it's meant to be run on the client
@fathom aspen ok, fair enough
Is it okay to use client shipping build to connect to dedicated server development build?
How do we replicate the actors we created from the GameMode to the clients? We're using a node in the GameMode to create actors, but those actors are not replicated. We also replicate an array of actors, the array is replicated with 2 entries, but the references to the actors are gone.
Nothing really special here. Like you would replicate any other actor out there. Make sure the actor bReplicates and that you spawn it on server. GameMode is server only, so you're safe
You can't have a replicated array/property in the GameMode as you can't access the GameMode from clients. It doesn't make sense to have replicated properties in the GameMode
anyone?
Intax made this a while back I guess https://github.com/intaxwashere/basictransformreplicator
unsure if it's a big help
checking out right now
Oh shoot I was right
I have to simulate movement manually on the simproxies
What's Vector Interp, or FMath::VInterp?
yep, there are two of them though
one is linear
i think that one is smoothed a bit
iirc...
Yes, Cubic Interp basically helps for when the ping is bad by making educated guesses about position and velocity
lerp/vinterp should in principle be accurate for extremely short client sim deltatime
my internet could help demonstrate the magic of long distance movement corrections
trust me, I'm Indian, I know
the switch between Slerp and RInterp is also illuminating
Hey Guys, I'm implementing an assymetrical jump in multiplayer and what I basically do is use the jump system already in the character and change the gravity scale and velocity mid-air to my needs. However, even with a reliable RPC sometimes there's some correction between the client (the autonomous proxy) who is jumping and the server, causing jittering. But looks completely normal for the other clients.
Is there anything wrong in using the gravity scale for this? Any insights on how to make it work?
Jump Started on the left. Server locations are displayed in red and client in green. They differ after the apex and then the server corrects it.
Unfortunately there's no easy fix for that - you likely need to implement a custom FSavedMove to handle prediction and rollbacks.
There's a bit of general info on how CharacterMovementComponent handles replication and prediction here - https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/CharacterMovementComponent/
Fair warning, this is fairly complex stuff and it's incredibly underdocumented. Also not something you can do with pure BP.
Other workarounds may include custom movement modes or root motion, but those have their own complexities.
thanks for the valuable resource! I already have some bits of my mov comp in CPP, I'll check the page to improve my knowledge and start getting my hands dirty on this. Thanks a lot!
fyi the important bit is the last section at the bottom - "Customizing networked character movement". The rest of the page is definitely useful as it goes into detail about how prediction works, but the actual things you have to do are just in that bottom section.
Also take a look at root motion sources (mentioned on that page) which may provide a simpler way to do things depending on how your jump works.
Awesome, I think there's some of this implemented in GASDocumentation
Root motion would be way simpler, but I need air control
it technically doesn't need to be from an animation if that's what you're thinking it is - a root motion source could be completely programmatic
I haven't worked with root motion sources much myself but you might be able to get one to just control vertical velocity while still allowing for normal air control.
this sounds like a really good idea
I'll explore this first before trying the custom movement
If it works (and I don't know if it will) it'll probably be much simpler. Good luck!
thanks!
Hello everyone, I have a switch weapon system that Iβm trying to replicate. The player holds a child actor component, and when they switch weapons, itβll set the child actor class to a different one. However, when I attempt to set the child actor class to a new one, all players are affected.
couple of things.. a system like this is better handled using repbotifies
and child actor component is trash, ill never trust it
It made my life so much easier, rather than destroying actor and spawning a new one
I'll try repnotifies, but why do u think it would solve the issue? Do you know why it's happening?
im not sure
with CAC, you never know, might be modifying the CDO
actually you can reuse the same actor and change properties accordingly to a data asset for example, thats how ive done it in the past
breakpoint in the c++ with debugger required
I read that if I spawn the child actor on runtime instead, then the server will modify the instances instead
So instead of having multiple classes for each weapon, one class will contain all the weapon data (bullet, mesh, animations, etc.) and I switch it there?
yes you can have a single class with a data asset that has the different stuff such as meshes etc. when you switch weapon you only change the data asset and update the data accordingly
you need to store stuff like bullet counts outside tho, i had a struct for each weapon and a struct that rappresent the currently equipped one
I'll keep this idea as a backup plan, because doing such a method would change nearly all of the mechanics I already added
But as I said I read that if I spawn the child actor on runtime instead, then the server will modify the instances instead
Do u know how I could spawn the child actor component on runtime?
I tried it, but it wasn't spawning anything
just like any other component, you create it and register it to the world
This does not work
Guys do j need to maintain seperate codebase for character that replicates and character that work in standalone game??
Can you tell me how to do it.Do I have to use of statements to achieve that
*if statement
Let's say my stand alone character can shoot directly while my multiplayer character needs to send an RPC to server and from that server need to get a multi cast function then he can show the visual effects.
I am talking about dedicated server
Then I think it won't work..
I wrote my character code assuming I am connecting to dedicated server
Thanks for advice.
Can somebody help me with a link to a documentation/ tutorial about steam to ue4 security info, like how to make a proper moderation system or how to not leak IP addresses of players?
OK-AY I am back
dont use P2P. make all your clients go through the server for everything. if player A wants to send a chat message to player B, make player A RPC to the server with the target player (player B) and a string field or something. then the server would RPC to player B that they received a message from player A
so i still have the issue where the code executes but nothing happens
i even stopped using the actor for hitscan bullets and now i directly do the line trace from the weapon actor component
I pretty much already have that, I am worried that my systems for server moderation and IP leaking are gonna have some big problems. I am looking for some documentation on how to make a good server moderation system and how to hide player IPs better.
How can I get my IP adress and port when running a dedicated server?
By asking an external service to tell it to you
by exteranal service you mean?
A server on the Internet
Still not sure how to do that, could you elaborate or provide some code example?
Write yourself a server in PHP or something that simply prints the client IP
Send HTTP request to said server
Read response
Alternatively since it's 2022, use sessions
There is seriously no other way the IP and port where I'm setting up a server than making another server and checking where the response comes from?
Does UE5 replicate physics?
I saw in the handful of cases I have been diving into, that it usually isn't possible. I must use custom cubic interpolation logic for the simproxy.
Then there are things such as prediction for autonomous proxies that I don't know about. Any idea where to look?
Correct
Your machine fundamentally does not has access to this information
You'd need to find the network access point and ask it (how?) its public IP
In practice both parts of this sentence are very big "how"
Hence the easy answer: go ping a server
Oh does OP trust whatsmyip or similar sites?
what if you ping yourself
also im back uhhhh so
i have confirmed that the code does in fact run on the server
the line trace just
doesnt happen
it doesnt happen
why
idk
it works if im on a listen server and the server tries doing it
but if a client it doesnt
Please help!
Same problem, but use search. Better let client Calc physics and just submit rotation, velocity etc to server π
@chrome bay sorry for the ping but if I want to NetSerialize FInstancedStruct without modifying engine files, can I just inherit the struct and add the function there?
I mean that's the plan but when I try that, chaos ensues (no pun intended). The pawns start vibrating like there's no tomorrow.
I need to figure out how to adapt the sample and the off-the-shelf script
I'm using the simple Transform Replicator plugin from the chat. So far it fits everything I need a simproxy to do
I haven't explored any autoproxy-side logic, and I guess I need to look deeper.
My laziness and inertia are keeping me from it but I guess I can do it.
In theory yes, but you of course lose a lot of the editor support for the struct itself.
It wouldn't carry over to the child struct?
Also, what kinds of editor support?
gonna ask one more time because im suffering so much oh my god
i have a character that can fire their gun right
ok so it goes like this
character -> call server rpc -> weapon (actor component) -> do line trace -> respond to line trace results -> call client rpc to do all that client side stuff like sound and animations
The issue is that the line trace doesnt happen
actually nothing that interacts with the world works
spawning actors or line traces etc etc
and before you ask yes the server rpc executes and yes it is actually on the server
i checked with HasAuthority
Did you set the component to replicate?
SetReplicates()?
Component->SetIsReplicated(true);
just as a PSA im inheriting from a base class that inherits from UActorComponent
Oh right. This
nope doesnt work
whats the last point that executes?
if you're asking me, the if statement where i draw a line trace
actually what do you mean "last point"
Ohh yeah then its the if statement where i try to execute the line trace
if the line trace hit anything it would've entered the if statement which doesn't happen
so there you go
this should not be treated as a multiplayer, but a collision problem now
or math
depending which part of the trace is broken
yeah but you see the thing is
if i draw a debug line with the exact start and end point that the line trace uses
it does hit stuff
both stuff i can see and cant see
and if i fire from the server on a listen server it works perfectly
does it hit stuff, or does it go through?
it goes through
by hit i mean i can if anything visualise the line trace and it definitely goes through a wall or character or anything else
you'll need to show code, describin g it is very inefficinet
Aight
if (GetWorld() != nullptr && SERVER && GetOwner()->HasAuthority())
{
FActorSpawnParameters ActorSpawnParams;
ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FHitResult OutHit;
FCollisionQueryParams CollisionParams;
CollisionParams.AddIgnoredComponent(capsuleself);
FVector Start = muzLoc;
FVector ForwardVector = FPCC->GetForwardVector();
FVector End = ((ForwardVector * 4000.f) + Start + FVector(0, 0, -100));
if (GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_WorldDynamic, CollisionParams)) // The last breakpoint hit is here
{
if (OutHit.bBlockingHit)
{
if (OutHit.Actor->IsA<AgfClassBase>())
{
AgfClassBase* achCasted = Cast<AgfClassBase>(OutHit.Actor);
achCasted->set_health(achCasted->get_health() - 65);
client_notify(achCasted->get_health());
}
}
}
}
@fallow shadowIf you show debug on that trace does it look correct?
wait a second debug on trace?
const FName TraceTag("MyTraceTag");
World->DebugDrawTraceTag = TraceTag
FCollisionQueryParams CollisionParams;
CollisionParams.TraceTag = TraceTag;
incorperate that
aye aye
wait what am i supposed to see?
i dont see anything when i fire
Oh ok i fired from server
its a white line and a red marker where it hits
uh
yeah this doesnt happen at all on the client
and how would the client draw a line?
all you send it is the health
it doesn't have any hit information
wait wait wait that's only there to update the hit clients' health
if i remove it everything stays the same except the client doesnt know its hit if it gets hit
the issue is still that the client just cant shoot
it calls a linetrace on the server
it just doesnt happen
Actually no correction
if i remove the client_notify line nothing changes
it just works as intended
Watch on the server when the client fires
wdym by "watch"
literally watch
you're doing listen server right?
Although you really oughta just work your way back from that trace with breakpoints and figure out where it's busted at.
yeah
which is just for testing the game is intended to be played on dedicated
im watching
im looking at the client that's shooting the bullet
no thin white line appears
nothing
well then you're breaking before the trace
put breakpoints everywhere, track down the last on that gets hit
aight
Might be simpler to just print to log at each step calling out what the step is but you do it how you want
might put a few breakpoints in the linetrace itself too
nope
nothing breaks
it follow throughs on the line trace
you're probably not making it to the trace, put breakpoints/debug logs everywhere from the input to the trace
I did that's the thing
on literally every line up to the trace i could
and it followed through
it entered the trace
@chrome bay, sorry for the ping again. I've been able to make a child instanced struct replicate. Works fine.
I'm assuming by editor support, you meant the make/break nodes you created right?
hell i even had a few breakpoints in the trace method and it reached all of them
ok I am trying to set my view pitch on event begin play but when I do its setting the view pitch on all the other players?
its not suppose to do this as its a child class. does anyone know why this is happening?
@dark edge i finally figured it out
So the reason it doesn't work is really stupid
The way i do this is to avoid repetition
the RPC to the server is in the base character class
for some reason calling a function in a base class as an RPC doesn't work
π€
i made a test function that does the same thing except its directly in the character class im playing as and it worked
i should be able to launch two standalone games and connect between the two on the same pc right?
when I start my game as a client, there's a few frames where I can see the map before I actually possess a character ( I start at 000), I want to hide that transition by immediately going to fade to black before I actually get a character assigned, I remember fixing this issue quite a while ago but can't remember how
good luck with that, the only solution i have found so far is the fading thing
which fading thing? I don't get a proper fade until after a few seconds after I'm already in the game π¦
so I still get a few frames of seeing the world before it does the fade
make your own gameviewportclient
nice, will look into that
i need some help :\
im trying to joing a session between two standalone instances
when i join the server get this
[2022.06.21-20.07.07:218][145]LogNet: Verbose: UNetConnection::SetClientLoginState: State changing from LoggingIn to Welcomed
[2022.06.21-20.07.07:258][146]LogNet: Verbose: Level server received: Netspeed
[2022.06.21-20.07.07:258][146]LogNet: Client netspeed is 100000
and the screen go black
the second i alt-f4
i get this
[2022.06.21-20.07.42:744][319]LogNet: Verbose: Level server received: Join
[2022.06.21-20.07.42:744][319]LogNet: Join request: /Game/Maps/MainMenuMap?Name=ZENITH-xxxxxxxxx?SplitscreenCount=1
[2022.06.21-20.07.42:745][319]LogBlueprintUserMessages: [GameplayGameMode_BP_C_0] TempPlayerController_BP_C_1
[2022.06.21-20.07.42:767][319]LogNet: Join succeeded: ZENITH-xxxxxxxx
Ah I meant native editor support but it might be fine actually. Just beware of slicing if you pass an FInstancedStruct around still
is there any way to modify an actor's components and variables from the client completely clientside?
https://blueprintue.com/blueprint/qifwhf8a/
this event is from the player proxy but it seems as if these changes affect other players in game
was something weird in the DefaultEngine ini, now its fine π
Hi everybody! any reason as to why a RPC (on server) called from a UI using a reference to a replicated actor is not working?
If the actor isn't owned by the invoking client, the server RPC will be dropped
You can only use the controlled pawn, player state or player controller. Generally.
what should I do if my multiplayer save game system won't load the save for clients and only loads it for the server player I can't figure it out.
Maybe the loaded stuff isn't set to replicate?
Or something.
Or you're spawning it wrong.
like the variables you mean
what is your setup and what is your desired behavior?
just checked all my loaded stuff is set to replicate I'm new to unreal and followed a youtube tutorial for the multiplayer replication save and load system can I send blueprint screenshots to somebody and maybe they can help me out further if not it's fine I'm sure I'll figure it out eventually
You can post them here, no problem
alright sure
Yeap, it was this. i used the Player state as a proxy for the call and worked.
I tought that when doing rpc from UI it would take it as a the Pc is doing it. Not the case π¬
so this is what I have in my eventgraph and then I also have 2 functions which are savegame and loadgame which is here
and obviously I have a playersDB and a save game and all of that stuff cause the tutorial showed me that but anytime I load in the game it only saves for the server and not the client despite it being set to server and multicasted and originally it wouldn't load at all but I figured out I was missing a connection
sorry for the blurryness
also the stuff offscreen in the load game screenshot is just it connecting to the variables again like in the save game screenshot
Okey i can see a few possible problems.
- Put a few "print" to see if your methods are actually being called, you are making calls right after login and some actors may not be ready at that moment
- Your save/load call, even if doing multicast, should be done on Remote and pass the data to a RPC on server. Or do a RPC "On Client" and from there, pass the data to another RPC "On server".
Remember that your save slots are local
can you elaborate by what you mean by remote and RPCs like I said I'm a beginner so I'm not really 100% certain about all the terminology quite yet might need a more simplistic explanation if possible lol or like an example or something
but atm I'm printing strings to see if the methods are being called
alright I put a few print strings and it seems that it's loading
and prints hello for all the print strings I put all along the blueprint so it must be the 2nd problem
Try to check this first or read the compendium by zedric
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
When you change a event to replicate, that's called a rpc.
What you need to do is make sure you are making your first call from the remote (the client). I assume you have a listen client setup.
So for it to also work on your Server player, you need to make it for all clients and tell them to do it on "Owning client".
From there, grab all the data that you need from the save game slot and do another event set to repliate "On Server" and pass all the data.
First things first. Please don't follow tutorials. Other than this is what you get usually from watching them, they teach you bad habits.
Now to the code. GetPlayerCharacter(0) on server will return the listen server's afaik, so that may be the problem
You shouldn't be using GetPlayerXXX(0) at all. There are always other ways to get what you want
You got a Player param there which you can use
that fixed it
thank you so much
and yeah for now on I won't lol
actually nevermind it didn't fix it so I'll try acrisios suggestion next
and do some more research in relations to network replication
Yes and you should read the compendium which you can find in the pinned messages
The gamedev.tv course and the compendium together made me understand the basics in less than 24 hours
The compendium and youtube made me understand that i don't understand the basic in less than 6 months
Hi, I am facing an issue while updating AI's Widget component image across clients. What I am doing is one player enables the image of the AI's widget component but I am not able to replicate that across second client. I have read on forums that I can use a replicated variable and based on that update UI. I am not sure what a right approach would be to solve this.
Just an image that shows what State AI is in
if you want to change the widget directly, do a multicast.
The best would be to store a variable that determinates the state and do a OnRep.
With the OnRep you can check remote and update all the clients*
I tried that. if the second client tries to update the variable, the listen client (client 1) doesn't receive the OnRep
Also AI cannot send a server RPC as it is not owned by the client and the server RPC will be dropped.
You could have a replicated Actor and send the RPC through them
Like an AI manager
But how would I notify (when I send a Server RPC and then Multicast to all clients) that I need to update widget component' image for that specific AI?
Do the same function in the AI manager
And multicast there
Then it will happen on everyone
Sorry I am not sure if I understood that correctly. I have this marking enemy function that calls Update Marked Icon event for the Current Enemy Character To Mark which further updates the widget component's image.
This marking enemy function is called in the third person character BP
Multicasts are not for stateful events, so don't use them for sure. Use OnReps instead. AI states and data that players need to be aware of should go into AI PlayerStates. There is where you store AI data/states and it gets replicated to all players.
Thanks for the response. How can I give an AI a PlayerState? I thought PlayerState is created for every player on a server!
You do this bWantsPlayerState = true; in your AIController class constructor
Thanks Very Much, I will try using the AI PlayerStates for storing AI data.
Yes please. And just FYI, you can store them somehow in your player character class, but that's not where they are meant to be and it clutters that class for no reason
Thanks Much, I understood
Mark the replicated variable as reliable could do the trick
If Iβm not mistaken, OnRep Notify is only triggered on the clients, thats why the listen client doesn't trigger it.
in BP it fires on server, in C++ you gotta call it manually after setting the variable.
I did that but how can I access/use that AI Player State?
AController::GetPlayerState
Like you would get a player state for a PC
AIController inherits from AController
thanks I got that but I couldn't figure how can I add variables n stuff to AI Player State as for a normal Player State for a PC we just create a BP and use it
It's the same PlayerState class iirc
Yeah look into AController::InitPlayerState
That's the function that spawns the PlayerState
thanks I will look into it
AAIController::PostInitializeComponents what calls it
thanks
What's the best way to tell all players to unprossess their characters (at the end of the game for example I want to freeze all characters?) Should I run a "On Server" event on the gamestate which is turn runs a "Multi Cast" event on the gamestate?
no, gamemode should do that
and multicast is not required
also, default behavior will destroy the pawns on unpossess
I did it like this on the gamemode...this makes sense?
Hi, Is there anyway to check if the session is still exist before join? I have basically list of session from the SearchLobby but the session owner might destroy before the client join.
Ok i finally figured out why my character wont shoot
it cant draw a line trace from an UActorComponent
why????
nothing happens if i try
if i draw the line trace directly from the ACharacter it works flawlessly
How can I block a game that is already started so that no one can join my game, would it be done with update session?
on the client? on the server?
server
reliable or unreliable
reliable
i have no clue then π
reliable should work even if the component is not set to be replicated
show some code^^
this is the actor component declaration
// Class weapon
UPROPERTY(EditAnywhere, Category = Gameplay, Replicated)
UgfWeaponBase* wSelfWeapon;
this is how i add it to the character
wSelfWeapon = CreateDefaultSubobject<UgfWeaponRevolver>(TEXT("WEAPON"));
wSelfWeapon->SetIsReplicated(true);
now on fire it runs a reliable server RPC that calls primary_fire from wSelfWeapon
in primary_fire is just a line trace that doesnt happen
but if i directly put the line trace in the server RPC it works
This is the server rpc
const FRotator SpawnRotation = GetControlRotation();
const FVector SpawnLocation = ((FPMuzzleLocation != nullptr) ? FPMuzzleLocation->GetComponentLocation() : GetActorLocation()) + SpawnRotation.RotateVector(vGunOffset);
// If i just do a line trace here it will work properly
// wSelfWeapon->primary_fire(SpawnRotation, FPMuzzleLocation->GetComponentLocation(), SpawnLocation, this, skmMesh1P, ucFirstPersonCameraComponent, GetCapsuleComponent(), true);
CLIENT_start_firing();
@marble gazelle
So the RPC from the client -> server is received on the server. But the client doesn't receive the client RPC?
no no that's not the issue
the issue is that
in the server RPC i call a function in an actor component
and in the function there is a line trace
the line trace straight up doesnt happen
but if i directly have a line trace in the server rpc it works
works where on the server or on the client
server
is the server a dedicated one or just a master peer
i test on listen servers but it happens on dedicated too
Where should the line trace run, on the server or on the client
ok wait let me do one more tldr; I want to do a line trace on the server:
this does not work:
input -> rpc -> weapon (which is an UActorComponent) -> line trace
but this works:
input -> rpc -> line trace
by works i mean it happens
server
well then set a breakpoint in your weapon code and check what happens^^
it executes
do you use the same coordinates?
well without the actual code I can't tell. if you run the exact same code it should work
i just copy paste it directly into the rpc
maybe if i did input -> weapon -> server rpc -> line trace
i gotta try this first then ill send full code if it doesnt work
that shouldn't matter, the question is, what information is your function taking from the weapon, is it the same info you take within the rpc
yes
did you check the debug draws?
yes
does the ray cast from the weapon create a debug draw?
GameMode is server only. So there's no need to have RPCs at all, as each function/event will run on server
Read the compendium found in this channel pinned messages
I have created an 1d aim offset but I cant put any animations on there
Is there a reason components might refuse to pass the multicast event to the clients, considering it and it's owning actor has replication enabled and no network emulation is done (a.k.a. no fakelag) ?
Hello, does anyone know what is the best practice to replicate an array of objects (e.g. tarray of actors) from server to clients? For example, I'd like to replicate all the actors that are visible to my pawn and my team. If I try replicating an array like I replicate all the other stuff (Replicated annotation in property, entry in doreplifetime) it replicates the array size correctly, but all the pointers seem to be invalid
Is it a good practice to replicate array of objects? should i be replicating just object id's?
Check if those actors have Replicated enabled
That's one reason I could think of replicated arrays are all NULL pointers
Oh, wait, objects
Yeah, those don't replicate on their own, so they can't exist both on server and client unless you manually manage them on both ends with some mutual actor that does replicates
Or you can just attach them to actor's net driver using C++ if you know how to do so
Getting this spammed constantly in my log
LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: PaperSpriteComponent /Game/2DSideScrollerCPP/Maps/UEDPIE_0_2DSideScrollerExampleMap.2DSideScrollerExampleMap:PersistentLevel.worldProceduralGenerator_1.PaperSpriteComponent_75 NOT Supported.
It's being made in the onConstruct script, once made, I have createdSprite->SetIsReplicated(false); But still coming up.
Any suggestions?
Code is
createdSprite->RegisterComponent();
createdSprite->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
createdSprite->SetIsReplicated(false); ```
Well for start I'm trying to replicate an array of actors. They all have replication turned on, and all are present on both client and server.
Then Idk. Replicating actors like that has been working fine for me
when is this?
to replicate an Actor pointer 2 things are required, a pointer to Actor has been replicated and Actor itself has been replicated
Hi, Is there a good way for the server to check if the clients input matches their direction, For example if The player is running forward then it lets you run but if not it stops you?
does the steam subsystem work in PIE?
Is there a replicated Inptut vector variable somewhere?
no to both of you
Zlo is being efficient with their answers. π§
can someone assist me in installing the steam subsystem
and by assist i mean elaborate on what the fuck did the docs mean by "macros" here https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Online/Steam/#serverdetails
how do i use them
where do i put them
Don't cross-post. Ask in #online-subsystems
aye
As it reads. They are not network supported, and they can't be made such with ease afaik.
Pretty much like a decal component doesn't replicate. You shouldn't be replicating them even if they do support networking. You replicate the action you do. So let's say you are changing the SpriteColor. You change it after a player died for example. So you replicate a boolean bDied for example and when the OnRep is called you set SpriteColor
Replicate the action, not the entity itself
That way you save yourself some net bandwith, as you're replicating a simple data type
This is really interesting. It does get called when you don't guard with authority. Wondering if that has to do something with the fact that we check owner's authority
Not sure
That is kinda messing my other function call that is coming externally from my pawn (owner), and it's only serverside
Though, might recheck, maybe there are some switches
I'll delete them and see if it works
Yeah, didn't really change anything
component need to have replication enabled as well for that
It is
Oh right, that was it ^^
If the event begin play fires on the server before the actor (or component) exists on clients, how would they receive the multicast?
You may want to instead use an OnRep variable that you set on the server's begin play that can then trigger the OnRep function on clients as the actor (or component) begins on the clients once they are replicated to the clients.
Except an onrep might not fire if the initial state of the character will probably include that changed variable if set on begin play
Client might not exist yet
Does it work if there's a delay before calling Yeah?
a question how can I use the filters for when I create a room in multiplayer
I want to put that when my room is complete that room does not appear in the find lobby
you update session data
and filter them out client side if they are full
you also have session search filters
that do that for you
Hey guys, not sure where to ask this, but I want to securely send API requests to my web api. I own a certificate on the server, how would I go about using it to secure the data sent by the client?
Do I have to get the cert file and manually add it using the openssl implementation in the engine?
how the heck do I get from a UMG panel to my admin controller on the server to run a kick player from server?
dedicated server?
yeah
so not really possible to do an admin panel that can kick players from in game?
make an admin controller
that gets instantiated with say, a specific login url
engine not happy showing UMG on dedicated servers
every accident i remember when something tried to show it there, crashed
π
Told you it would work lol
Add server calls on player character, call character from UMG, bam server based UMG buttons
bool UVehicleMovementReplicator::ServerSendMove_Validate(const FVehicleMove& Move)
{
return Move.IsValid();
}
void UVehicleMovementReplicator::ServerSendMove_Implementation(const FVehicleMove& Move)
{
if (const float ProposedDuration = ClientState.ClientSimulatedDuration + Move.DeltaTime;
ProposedDuration > GetWorld()->GetGameState()->GetServerWorldTimeSeconds())
return;
OwnerEp->SimulateMove(Move);
ClientState.ClientSimulatedDuration += Move.DeltaTime;
UpdateServerState(Move);
}
@chrome bay just using this instead for now. Overticked moves are ignored so no kicking. Moves need to be valid though: the check simply involves seeing if the thrust and control values are in [-1.0, +1.0].
anyone experienced with beacons able to help me out, I'm still learning them?
I'm saving address to user cloud upon successful connection and then in the event of a crash I'm spawning a beacon and try to connect to said address to see if session still exists.
Now if it does, it connects and everything works, but if it doesn't, calling
InitClient(url);
returns true, but the the beacon will just try over and over without ever failing.
Anyone might know the reason?
Guys, how can I block a game that has already started so that new players cannot join?
is it done with the update session?
Yeah, I fought BeginPlay is called when all clients have initialized it
Now I see this is not true
Well, thanks for that, but now I have another issue: it seems like my map isn't being replicated at all
Or (might have asked that in the first place) there are some way I can make replicated array be in the specific order?
This would rid me of making this workaround
Hi, i used to parse option strings for my custom terrain generator in the gamemode
however so i moved that code to the actual actor, so it works on clients to
Is it only possible for server to parse option string? how would clients be able to use them?
Make into a replicated property in the GameState and your clients would know about it
Maps don't replicate
What do you mean by "specific order"?
So, if I have
0: Object1,
1: Object2
```it stays```
0: Object1,
1: Object2```across every machine it is replicated too
If I remember correctly, order of object doesn't persist with regular arrays
Well there's no such thing to keep replication order. You never know how much time would it take each connection to get that replicated property
You should make it resilient with such cases
So... I'm going to need to make one RPC with one object to be sent and then call it for every object in the array?
Because I need that order
Can't think of other ways to it
Well here you face another problem. If you call the RPC from an actor that isn't relevant to a specific connection you never get that RPC fired in the first place for that connection
Read last pinned message in this channel so you get a better idea of when RPCs vs OnReps are used
I know when those are used
Can I ask what you are trying to do?
This is a player loadout
Upon pressing a button it equips the next item in the array, wraps around to start when reaches end
Selection is determined by an int pointing to offset in the list
And this has to be persistent for every player because duh
Items of loadout are created serverside ('cause it's a set of actors that replicates) and therefore needs to be replicated
Well array order is preserved on server and client if that's what you ask.
What you're looking for is an inventory system and by looking through this channel search you can find a plenty of examples
That's.... not true, to my memory
But alr, I'll recheck
And it would already be working if it wasn't for RPC misuse from my side
It's true. FastArrays don't preserve order for example but that's another topic
I'll check and report later
Has anyone lately dived into making a Leap ability with GAS not end in correction-hell from the CMC?
Lyra uses RootMotionSource, but on Emulated NetSettings even Lyra gets tons of corrections (which is again super sad given this is supposed to be a proper example).
Or generally abilities with movement...
Why is this always such a pain with UE
Everything that doesn't go through ServerMove is just crap. And it seems like corrections hit super hard with RootMotionSource stuff
The only way I get this smoothly working is by ignoring client corrections until before performing the RootMotionSource and reenabling it with a Sync Node so both have perfomed the leap
I may be wrong but didnβt Lyra just massively speed up acceleration as their βdashβ?
Na they have a GA Dash with a RootMotionForce
And an RPC inside that, they just didn't care I guess
Ah alright.
It's confusing though because ALyraCharacter and ULyraCharacterMovementComponent both do stuff with replicating custom acceleration π€
But I guess that's for something else then.
Also, Cedric. Do you know how the CMC prevents speed hacks? I'm trying to better understand how the code in general works every now and then but every time I look at it I keep wondering what prevents people from doing stuff like that π€
All it seems to do to me is that it just limits the max delta time it calculates based off a client time stamp. But what is preventing me from sending a bunch of movement packets to 'simulate' high FPS games and then setting my client time stamp to look as is if it reaches that max every time on thus a high incoming rate?
the corrections should be minimal under no hazardous conditions, could get good results under the 150ms mark
Hmpf...
hahaha xD I know
The wonderful world of MP π
works for dashes, leaps and such, other than that... might revisit the CMC, again, corrections should be almost non existant unless there are discrepancies
I used to make dashes by literally programming them into the CMC
But that was for games where you just had that one dash
Not a bunch of GAs that could all move you in different ways
it just works, but programming a dash onto the cmc is a show
Yeah I flex with that when meeting the ladies
I just know that modifying the CMC state from outside is causing correction.
Changing movement speed via the GA (via some GE in the end that drives a speed attribute) is somewhat okay
The correction is invisible
But everything else feels like the wrong setup
Also different question. Is it possible to link the client time to the server time? So know when at a given point in time on the client what the server time is? The current system from Unreal is rather weird and suffers from latency :p
I asked that before to link up some timer
But I can't recall what the result was
I think I just sent a timestamp or so
Or wait
People said to just end the future timestamp
So if you have a timer of 10 seconds, just talk about it in terms of CurrentTime + 10.
Then Server and Client show it correctly
But what if the client's PC time is out of sync?
If you just use the replicated server time, it will get in sync eventually
You can also do what vori posted
It is enoug hfor most things yeah
this one is more precise except for the first 10 seconds
If you play some random AAA game, you notice that the timers never exactly work
Respawn countdowns for example are always off by some degree
xD
I think that falls under MP is hard
But you might be able to show that code snippet to the ladies
Or boys, fwiw
sigh Can't wait to get the office tomorrow to fix Movement Corrections caused by RootMotionSource in a GA that I didn't code and inherits from 3 freaking parent GAs (chain)
π
you are a beast, you'll get it working
So I checked and it seems like you're right - it does preserve the order
Looks like I've been mislead by some other source about this
Big thanks for opening my eyes
it can happen but its not guaranteed
good choice
in short, yes -- there's a replicator component and the for prototyping purposes the movement is not segregated into its own comp, so it's on the pawn descendent
Are you trying to use physics or are you doing flying on your own?
You said simulating physics on a skeletal mesh so I'm thinking physics but what is actually doing the flying mechanics?
please describe this
void AFlightReplicationEntityPawn_Master::SimulateMove(const FVehicleMove& Move)
{
const auto UpdateLinearVelocity = [this, &Move]()
{
EntityPawn_CurrentThrottle = FMath::Clamp(Move.CurrentThrottle + EntityPawn_ThrustValue,
-MaxThrust, +MaxThrust);
const FVector TargetLinearVelocity =
RootEntityBody->GetForwardVector() * (Move.CurrentThrottle * Acceleration * Move.DeltaTime) + GravityVector;
EntityPawn_CurrentLinearVelocity = FMath::Lerp(
RootEntityBody->GetPhysicsLinearVelocity(), TargetLinearVelocity, InterpolationConstant);
RootEntityBody->SetAllPhysicsLinearVelocity(EntityPawn_CurrentLinearVelocity);
};
const auto UpdateAngularVelocity = [this, &Move]()
{
EntityPawn_CurrentAngularVelocity =
-RootEntityBody->GetPhysicsAngularVelocityInDegrees() / AngularVelocityScalar * Move.DeltaTime
+ Move.ForwardVector + Move.RightVector + Move.UpVector;
RootEntityBody->AddTorqueInDegrees(EntityPawn_CurrentAngularVelocity, NAME_None, true);
};
UpdateLinearVelocity();
UpdateAngularVelocity();
}
that's your answer
So it looks like you're simulating physics but NOT using physics to do the actual forces and torques, it's a weird setup but it can work i guess.
USTRUCT()
struct FVehicleMove
{
GENERATED_BODY()
// Perceived time-slices from every client Tick
UPROPERTY()
float DeltaTime;
// Timestamp from when move began
UPROPERTY()
float StartTimestamp;
// Per tick:
UPROPERTY()
float CurrentThrottle;
UPROPERTY()
FVector_NetQuantize100 ForwardVector;
UPROPERTY()
FVector_NetQuantize100 RightVector;
UPROPERTY()
FVector_NetQuantize100 UpVector;
};
it does work, surprisingly
I did the math too, it makes sense
You're directly setting velocity but using torque for orientation
You should choose one or the other IMO. I'd prefer using forces and torques but it's up to you.
Can't, not in the requirement
Anyway, have you looked into the physics replication stuff? This can just work in multiplayer out of the box, depending on if you need prediction or not. For slow-responding things like airplanes, waiting 30ms for a response from your input is fine.
I have not.
That's a wacky ass requirement if they want to directly override physics velocity but not physics rotation
Well the code looked way worse before what I did
I'd hate to see it lol
the AngularVelocity was not even factoring in DeltaTime earlier
we need smooth movement on clients
that's the only thing I'm being tested for
(it's an unofficial hiring test)
Torque doesn't need DeltaTime brought into it but that logic right there is a clusterfuck
I scoured the source to find where that hidden dt comes in but found none, hence why I replaced a magic number with what's there
so how will we ever get rid of that warning
I'm unable to test it properly because UE5 is set to lag if it's not in focus
fixed that, testing
oh no it's a mess I must sleep over (before midnight here)
That entire architecture seems like a mess but the high level overview of how I'd do physics driven flight is like this
Tick -> Send input to serverside -> Calculate forces -> calculate torques(might not be necessary, depending on flight model) -> Apply them
The physics replication settings can keep the clients smoothly in sync with the server.
this is the movement side, yes?
this is pretty much exactly what happens btw
void AFlightReplicationEntityPawn_Master::BeginPlay()
{
Super::BeginPlay();
GetWorld()->GetPhysicsScene()->OnPhysSceneStep.AddLambda([this](FPhysScene*, const float FixedDeltaTime)
{
if (GetLocalRole() == ROLE_AutonomousProxy || GetRemoteRole() == ROLE_SimulatedProxy)
{
LastMove.DeltaTime = FixedDeltaTime;
LastMove.StartTimestamp = GetWorld()->GetGameState()->GetServerWorldTimeSeconds();
LastMove.CurrentThrottle = EntityPawn_CurrentThrottle;
LastMove.ForwardVector = EntityPawn_RollResultantForwardVector;
LastMove.RightVector = EntityPawn_PitchResultantRightVector;
LastMove.UpVector = EntityPawn_YawResultantUpVector;
SimulateMove(LastMove);
}
});
}
...
void AFlightReplicationEntityPawn_Master::SimulateMove(const FVehicleMove& Move)
{
const auto UpdateLinearVelocity = [this, &Move]()
{
EntityPawn_CurrentThrottle = FMath::Clamp(Move.CurrentThrottle + EntityPawn_ThrustValue,
-MaxThrust, +MaxThrust);
const FVector TargetLinearVelocity =
RootEntityBody->GetForwardVector() * (Move.CurrentThrottle * Acceleration * Move.DeltaTime) + GravityVector;
EntityPawn_CurrentLinearVelocity = FMath::Lerp(
RootEntityBody->GetPhysicsLinearVelocity(), TargetLinearVelocity, InterpolationConstant);
RootEntityBody->SetAllPhysicsLinearVelocity(EntityPawn_CurrentLinearVelocity);
};
const auto UpdateAngularVelocity = [this, &Move]()
{
EntityPawn_CurrentAngularVelocity =
-RootEntityBody->GetPhysicsAngularVelocityInDegrees() / AngularVelocityScalar * Move.DeltaTime
+ Move.ForwardVector + Move.RightVector + Move.UpVector;
RootEntityBody->AddTorqueInDegrees(EntityPawn_CurrentAngularVelocity, NAME_None, true);
};
UpdateLinearVelocity();
UpdateAngularVelocity();
}
That's a bit different, that's sending moves to the server, not controls
Ah, the moves are sent to the server in the replicator
I'm talking about sending controls to the server.
intriguing, directly sending the controls?
Yes or some derived data based on the controls. For my project, that's throttle, brake, steering angle, etc.
Mine's land vehicles though
void AFlightReplicationEntityPawn_Master::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("Entity_Thrust", this, &AFlightReplicationEntityPawn_Master::OnEntityThrust);
PlayerInputComponent->BindAxis("Entity_Yaw", this, &AFlightReplicationEntityPawn_Master::OnEntityYaw);
PlayerInputComponent->BindAxis("Entity_Pitch", this, &AFlightReplicationEntityPawn_Master::OnEntityPitch);
PlayerInputComponent->BindAxis("Entity_Roll", this, &AFlightReplicationEntityPawn_Master::OnEntityRoll);
}
...
void AFlightReplicationEntityPawn_Master::OnEntityThrust(const float ThrustValue)
{
EntityPawn_ThrustValue = ThrustValue;
}
void AFlightReplicationEntityPawn_Master::OnEntityYaw(const float YawValue)
{
EntityPawn_YawValue = YawValue;
const FVector TargetVector = RootEntityBody->GetUpVector() * (EntityPawn_YawValue * YawRate);
EntityPawn_YawResultantUpVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}
void AFlightReplicationEntityPawn_Master::OnEntityPitch(const float PitchValue)
{
EntityPawn_PitchValue = PitchValue;
const FVector TargetVector = RootEntityBody->GetRightVector() * (EntityPawn_PitchValue * PitchRate);
EntityPawn_PitchResultantRightVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}
void AFlightReplicationEntityPawn_Master::OnEntityRoll(const float RollValue)
{
EntityPawn_RollValue = RollValue;
const FVector TargetVector = RootEntityBody->GetForwardVector() * (EntityPawn_RollValue * RollRate);
EntityPawn_RollResultantForwardVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}
here are the controls per se
derived data is precisely what's sent as moves
maybe the nomenclature is whacky because of gamedev.tv influence
The throttle is a control variable, the 3 vectors are the results of some sim unless they're meant to be a control variable.
they look like control variables for "heading"
If it's desiredheading that's fine
if it's simulated heading then that's weird, it's mixing controls and results together
the values called "yaw, pitch, and roll" here are actually just Throws, so they scale a rate and change the direction by influencing each axial component of the heading vector
(afaik)
But anyway, the physics replication system can do the heavy lifting of keeping things smooth for you, assuming the physics movement is what's considered the canonical end result. I'd dig into those settings, there's a ton of tunable parameters.
Please point me to the docs, I'll look into them in the coming week after I fail to make this example work within Saturday
My project has buildable land vehicles and the basic system is exactly what I outlined and it works perfectly. The only downside is there's NO lag compensation, but lag compensation in physics is horrendously complicated.
I believe we are indeed looking for lag compensation when we talk about smooth movement
unless I misunderstood that requirement because of my inexperience
There's a difference
lag compensation is when you press jump in a game and you jump instantly on your screen, with the server still being authoritative
it's HORRIBLY complicated for physics driven movement
it's desired heading, based on my preliminary squint on the code
oh, maybe not that then
Watch the GDC talk on Rocket League networking if you want, but anything with prediction is totally overkill for an airplane game. Airplanes don't respond that quickly anyway.
These are the tuning settings I was talking about
Read the source code on them, it's pretty much the only documentation
The stock settings are pretty strict
Like you don't care if an airplane is within 1cm of where it should be
Yeah I know about these
afaik there was also some random error which crashed the engine when I wasn't looking
I will seriously consider sleep now. There's a whole IRL to deal with outside this multiplayer sample.
What is the smart way of synchronizing all created teams by server (When player connects he is assigned a random team inside GameMode)?
My approach was to change RepNotify variable inside GameState with all created teams, and when new team is added to the array, every client would be notified. The issue is that I need to update HUD of all clients to display all currently created teams. But I'm not sure how I can access local player and his HUD component from inside of a GameState RepNotify event.
Two ways
Either you ensure that your HUD is easily accessible e.g. via the PlayerController
So you can just get the PC and access the HUD in the GameState
Or
You add a delegate/event dispatcher to the GameState
And bind/listen to that in the UI
Which is what I would do
Thank you! Okey I'm going to try the latter but just out of the curiosity, how can I get local PC inside of a GameState?
Tried using get controller and cast it but that failed
GetPlayerController should work fine
With 0 as default index? It says it should be local player but I've read multiple times that this doesn't have to be true sometimes when connecting to server
For a local player it will be correct
They only have their own PC anyway
ListenServer should also get their own with thay
Yes thats what I thought so, okey thanks a lot for help!
If I switch to source engine build on 1 machine to build dedicated servers, do I need to do that on all workstations to maintain multiplayer compatibility?
or you could just distribute the packaged build?
or package the engine itself to save some time
unsure if it will consider it a different version, my assumption is yes
ya, just tested and it considers it a different version. I didn't want to have to have source on all workstations for quick testing, but maybe thats best way.
was saving packaging/distribution for bigger testing runs
distributing your engine build should not be too difficult
as that will change less often than your game project, I assume
What I really want is to connect to the server via PIE. That works with the PIE that is source built. That doesn't currently work with the PIE that is not source engine built.
Please remind me how I must set up my pawn to make use of these settings.
Those settings cover how replicated physics behave
So I can just focus on the movement logic and not worry about the rest at all, right?
Could you provide me a sample under 1-2 KLOC which shows a vehicle being replicated over a network? CMC is way too big and covers a totally different beast in my eyes.
Could you please elaborate? I kinda need this asap!
they base it off of the source engine movement replication
tho smooth sync is also client auth
from what i remember the person plans on making a server auth version
at some point
at the very least one could yoink the interpolation I suppose
I've wrecked the code by trying to gamedev.tv myself into this. I'm not yet fit for a multiplayer based job I guess.
I'll ask for permission from my in-charge to share the code repo.
my would-be employers have that plugin on their systems
well, as mmmm says it's not authorative out of the box
but I suppose it would be a nice thing to study
certainly beats the default interpolation
the problem we're dealing with has a domain far surpassing our needs and understanding of it
...is this even a competitive game?
yes, it's meant to be a 5v5 team deathmatch
obviously it sucks arse rn
I mean I made the gameplay worse than what my in-charge gave me
I guess my point would have been to maybe just half ass it and go client side movement if it was pve
I'll let you read the repo
I don't have time to read it and I'm really not an expert here, I'm just saying what I would try first
here's another massive list of stuff to read lol: https://gafferongames.com/
okay, so TL;DR it's server auth
I removed the replicator
alas
What's a good way to attach an item to my character's hands and have it properly setup for FPS, while having it correctly set for others to see (multiplayer)?
https://github.com/neosphereinteractive-real/FlightReplication/tree/dev-vivraan-fix-rep
This is the code I have atm
Any understanding I can gain on the project wrt this code will be deeply appreciated.
best read CMC for this, although I believe they don't handle guns as attached actors
Do you mean Character Movement Component?
I don't understand how CMC could help me there π€
You attach it to the wanted socket on character and you make sure you're doing that on server and it magically replicates
Alright I think I need to reformulate my question. How can I attach my item to my FPHands (only owner sees), and have it also attached to TPMesh (owner no see)? Said item can be "dynamic", it can be a smartphone with a screen which can been seen by both the player it's attached to, and others players, so its behaviour needs to be replicated
You literally said what you want. You already have FPHands set as OnlyOwnerSee, and I think any attached actors to that mesh will have the same behavior(if not you do it explicitly). Same goes for TPMesh you have it as OwnerNoSee and you attach that item to it and you get same behavior
The functions you need to know are literally SetOwnerNoSee, SetOwnerOnlySee
That's at runtime
Or you do it in details panel
So is it only one item, or do I need to duplicate it?
@ebon cape
Repo is now public
Hello there! π
AController::Pawn is set to REPNOTIFY_Always.
Will this cause Listen Servers to receive an OnRep call when changing the value (on the listen server)?
no, call onrep in mutator explicitly if you want it on server too
Cheers
Iβm having an issue where animations are not played on the other client on the server how would I go about fixing this
REPNOTIFY_Always essentially means "always call the onrep, even if the local value is the same"
It's commonly used when clients are modifying replicated variables (which is usually a big no-no, but sometimes neccesary)
And because the whole controller->pawn replication is a complete mess
But Epic dare not touch it these days
Any help here?
What's the issue with it?
It's become much worse than when I didn't meddle with it. I implemented a Replicator comp which sadly makes things much worse.
But what's the issue in the first place?
We're trying to implement a semblance of smooth replication of simulated proxies.
My code is quite amateur and doesn't exactly do the job right.
It kind of depends on what you want to achieve I suppose but from what I see a lot of games just take the approach of having a small buffer of locations and then working their way through that with a lerp for example or some different smoothing algorithm. There are definitely other techniques like extrapolating which you can do if you want but just using a lerp with a buffer does the job most of the time good enough.
It's a bit difficult to know for us how to exactly apply that to your code though. Which is also mostly up to you I would say π
Valve has a small page about it you could also look at: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
Not sure how up to date it is though. There's a section called "Entity Interpolation".
I figured that part, however that made me question that maybe the fact listen servers don't receive an onrep is because they've already changed the local value, so it's (technically) "the same" as the server value
Ah no, in C++ world RepNotifies are only called client-side, since they are "receiving" the value. Blueprint rep notifies are a giga-hack
hi, I have my server actor controlled by a behavior tree. Using my playercontroller I send a move command to that actor.
But when that actor turns, it's very choppy, because only the data that come from the server update the actor's location/rotation. I would like to run a local instance of behavior tree on client actor so it updates client actor accordingly and sever eventually just corrects the actor's location/rotation.
How to do it since there is no controller associated with the client actor therefore client actor's behavior tree doesn't even start?
Curious - what makes it a complete mess?
xD
i have this respawn code witch works fine in singleplayer but in multiplayer it dosnt and i have tried to get the controller from the player input but it just causes an error
yeah and i dont know how to get the number of the player that died
No need for a number
You can just pass the controller ref of the one who died
It just depends on how you have it all setup
And where
Read this please: #multiplayer message
still new to networking myself, but i believe its because controllers aren't replicated, so everyone's own controller including the server is index 0 as far as they know, it's used for local splitscreen multiplayer, which is why you need the ref
im running it like this would i get the ref with get controller and put it there?
No, on a server Index 0 is the first player
Locally it's always yourself
Where is that
In what class
the player class
You are calling an RPC in the GameMode while it exists only on the server
Read the compendium
but maybe that explains what i'm missing about how controllers work here - this spawn stuff in the game mode works for everyone except the server. if i run a server and 3 clients and i put a print string here, i get four hellos, but the server never gets a pawn or a UI, and the first client (the second one to join, so should be index 1 in that array) spawns at spawn tag 0.
what's in the screenshot is almost exactly the same as a video tutorial i followed and it works there
If needed, GetPlayerController is good to get all players in the GameState
GameState has an array of PlayerStates that you can iterate and use the index of that in GetPlayerController to iterate all controllers
Alternative that storing everyone in the GameMode OnPostLogin
I'm not sure why you're using a SwitchHasAuthority. You're in the GameMode i.e, server only
ok what im not understanding is how to request the server to do anything if gamemode is only on the server and i dont know how it would even be posible foe be to do this
We talking Listen sever or Dedi here?
Run it on the server?
You route RPCs only through PlayerController/PlayerState/Pawn
appreciate pointing that out, just copied from the tutorial and while troubleshooting if something doesn't fix it i change it back to keep track of things :D but that shouldn't ever return remote anyway, right
You got reference to some of those thorough the GameState for example
but how would the server know how the player died im sorry im being stupid
RPC
listen
what is RPC
But I mean, the player shouldn't tell the server how it dies anyways
Server gotta know
Yes that's wouldn't change anything. And I'm not even sure how you add widgets and stuff
But the tl;dr for you should be don't follow tutorials
They are your worst enemy
Read the compendium if you haven't got to do so
Always understand what you're doing if you plan to follow a tutorial so you know when they do something wrong
Blindly following will only cause problems
Remote Procedure Call
coming to realise this :D and I just add widgets by casting to the player controller and calling an event. but it never gets to that point because the server never gets added to that array
ok so i shouldnt trust the client telling the server hey respawn me right
Well you shouldn't be making an array anyways
Never trust the client
Read this
You got PlayerArray in GameState
right so i need an event to know when somthing gets destroyed
It's already handled for you client and server side
i'll certainly swap it over to that logic, i guess i just wanted to know for future reference what the problem here was if possible. thanks a bunch all for the help
No worries. PlayerArray is an array of PlayerStates. To get the PlayerControllers, you do GetOwner on each PlayerState element
what do you mean its already handled like in what way
It's synced
Though it's not replicated
ok so the server has all player states correct
Correct
so i can loop through all players checking for it being destroted corredt
Well that's obviously not the way you would do it
Wha
How do you know if a player died?
Think about it?
He gets damaged for example and then you check health on server and if health is below or equal zero then he's dead
so i check for death conditions instead of just death
Correct. You make your functions fire on events
Player died -> do this
Not: check on tick if player died then do this
That's what is called event driven code
Since it's always ran on server, everytime you take damage check if health below equal 0 aka you died, if true you can run a HandleDeath event, even on the GameMode if you have a common death function handle
the thign is the only death condition is falling off the world what event would i use for that
So you don't have health and such? The only thing that can happen is getting destroyed?
There's an event for that by they way
FallenFromWorld?
FellOutOfWorld iirc
Called when the actor falls out of the world 'safely' (below KillZ and such)
is there a version for blueprint or would i have to make a c++ accsessor
Nope
But you don't need it to be exposed
You can have a some volume under your level
That does that collision handling for you and acts accordingly
and have a BP on the volume that when its touched it runs an event on the gamemode
Well you already have an event called HandleDeath or OnDeath, so you access the GameMode from that actor and call it
Or call the interface function that does the death, and then OnDeath is called automatically
Plenty of ways really
You make it π
It's game specific
But it should have a point where you call Destroy for some stuff
ok so i would make the volume make the gamemmoe run that function right?
Yes
Volume overlaps player, you get mister player from the overlap, you run the death function through the GM
Box volume
i dont see a box volume
You have to make a BP
ahh
Then add it
box collision right
Yea
so i just make a cube and scale it right
Yeah
How UE handles it is that it checks if you are under a certain Z but you don't have to do that
should i make it thick so it things dont phase though it
I mean sure
in case it helps anyone else, got the logic switched over to using the game state's array, but the issue was the timing; i was collecting the Player Starts on BeginPlay and the server was logging in too quickly before it was done π made sure that step was done before trying to spawn anyone
I have already done that. You may examine my Replicator code.
Also please ping me as I'm not frequenting the channel.
This is not a good way to do it. What you've done is open a means for players to teleport around the map whenever and wherever they want to as you're allowing the client to tell the server that they want to teleport and the destination.
The "BeginOverlap" event that triggers your code should be already running on the server - all you should need to do is use a "Has Authority" switch and use the "Authority" path to connect with your existing code, and you can then remove the "Run on Server" part from your "Respawn Player" event.
Correcting as I've suggested will mean that only the server will ever check what is happening on the overlap and determine what to do next instead of relying on the client to tell the server to respawn the player and where to move that player to.
the overlap is on an object that is not the player ansd i should add an authority to the teleport right
The idea of the authority switch is you're checking if the current instance of the game has a certain level of permission over the object. The "Has Authority" should be placed immediately after your "OnBeginOverlap" event.
done! so that should fix it right
Yes, but also make sure to change the "Respawn Player" event. It shouldn't use the "Run On Server" option.
what should it use?
Whatever the "None" option is. The event should just run, doesn't need to be an RPC.
π
Hello, I have an object in the game that rotates. this is a simple square 50 by 50 by 1 meter, and when I'm on it, the stob pulls me from the old side to the side ...
The closer I am to the pivot of the component, the less jerks how to fix it?
"the stob pulls me from the old side to the side"
what
when I stand on this actor it twitches me
understand ?
I really need to know why this is happening.
You are getting movement corrections because the client and server don't agree on the movement. Welcome to multiplayer.
no, I have 2 objects server and client move the same way
i use the simplest sync code
Show your code. Are you using the CMC or no?
It might make more sense to AddWorldRotation instead of setting it and it utilize DeltaSeconds instead of WorldTimeSeconds
Has anyone checked the progress on the NetworkPredictionPlugin lately?