#multiplayer
1 messages · Page 84 of 1
game mode default
As Datura said, you probably need to make the framework for network spawning or get a sample
make sense
Have you tried restarting the editor? The only case I can think of now with your set up is if you happen to be calling into a different character that isn't owned to try and perform the move which I don't think you'd be doing.
Like, the input should be on the character, that same character sends server RPC.
i have the input in the bp for the character
and the function it calls in the c++ for the character
ya thats what im doing
i guess ill try and make the network spawning tomorrow and see if it works out
igtg now thanks for your guys's help i really appreciate it
have a good rest of your night/day
I'm in morning time since I'm in Japan
Have a good night
If the client has logic that sets a replicated variable and the server has logic that sets a replicated variable to something else, ultimately whoever goes last wins?
Interesting question but I guess server wins.
Because server replicated to client with network transmission means will be a bit late.
If it's outside a server-only RPC then I guess it's running on both so the value should be identical, barring other logic that feeds into it that may be server or client side specifically.
And outside a client only RPC
What is that called? When an execution path is running on both the server and the client at the same time and setting a replicated variable in that path? Just...normal?
That's true
Hm
I'm gonna rebuild my player state character and animation replication and was thinking about the best way to handle this stuff heh
So, if you are going to use RPC, don't use replicated value involved in.
My personal suggestion is replicated version for cosmetics like avatar attachment visual
I don't want to use RPCs if I can avoid them
But RPC for core logics you want really be synced.
Like spawning, match state changes and etc.
Maybe spawn is a bad example that usually on server, lol.
Yeah some will be unavoidable
Welcome to the battle of latency
In my experience, I made a tetris online battle game and erasing the lines are RPCs.
You will always have latency, so you just need to work around it 😛
Aye. Generally only send what you must. Compute everything you can.
Is that accurate ?
RPCs are for things that need to happen quickly, Replicated props are for things that can take a while, RepNotify props are for state things
And rep is not reliable so it could be lost
The event you don't wanna be lost needs RPC
rep props are reliable
Are they? Sorry If I'm wrong.
they will eventually be sent
Even you have really bad connections for a little while?
yes
but rpc's take priority
which is why if you abuse RPC's, ie sending tons of reliable rpc's
your game == broken
Found that out the hard way
i mean you need to be sending enough not to flood the reliable buffer
but be just below the buffer
i use quite a lot of rpc's
Yeah, like don't do every tick RPCs
every bullet from a gun is an rpc
That's a bad habit...
yeah but the movement component does that
but its on the unreliable side
who cares if we miss a few updates
If a client is aiming just so I want the other clients auto proxies to match that blend space
oh we don't use rpc's for that stuff
You can definitely using OnRep
well we do for when they start aiming
and stop aiming, ofc
but that is it
as server needs to know when they started and stopped aiming
Otherwise they just use a replicated property or two (axis?) To feed the blendspace
but we give them a gameplay tag, which updates the animation
we use BaseAimRotation from the pawn
for the blend space
Gotcha
Man my player state character... it's a miracle it even works right now. It was the first thing I ever tried making with multiplayer. It's a hot mess.
So, so much on tick.
so take stuff off tick 😅
our player character has 0 tick logic
Looking forward to cleaning it up
it even has tick disabled
0?!
I run a sphere trace on tick from my interaction component from the character
we do it on the controller
Ah
True
we do our traces in PlayerTick as this is local only
and not on the server
(PlayerTick is a function in the PLayerController)
And the server just has to accept your traces? Or you validate another way
I guess all the server needs to agree with is you're in the right vicinty of the interact target eh
And the server should already be doing that
we validate it on the server side
Ya
but server does no traces for the actual interacted item
but it does some checks (is interactable in sane range, angle to interactable, etc)
There is so much I need to do better. Thankfully not a lot of rework.
and a trace to check for anything blocking
same as our weapons
we only trace for the hit on the client
server does some validation but doesn't do a trace to determine what was hit, but does a trace to make sure nothing blocked the hit (like a wall), angle from player to hit actor, distance, fire rate, etc
It's always a balance between player experience and anti-cheating. More strict means worse performance.
more strict can also be bad experience
sure you can use rewind systems (but this is a performance and memory penalty)
but player will be pissed if he said "i hit that player" but server says "no you didn't cause i missed"
all because of latency
I honestly don't care about cheating that much. Couch co-op with casual pvp action RPG.
That said, if people are messing up the experience for others by speed hacking or something... yeah. No bueno.
good ole' cs go hit reg? lol
There will always be cheaters, you really only need to ensure that you do enough to stop the vast majority of them.
cs go was terrible for it
I remember Battlefield being super bad as well
small player competive games, using a rewind system does work well
Those dudes just make it mainly for consoles.
but tbh, it can be a bit overkill
It is fair to be enough on consoles.
Prediction is another one of those things lol
We dont predict grenades
Players can barely tell
Unless their ping is 300+
nowadays, with the way internet is, its not as bad as it was
300+ is just HPBs anyway
i mean most people are <80 ping
Wonder if you guys were around for the LPB/HPB days lol
Early days of e.g. quake 1 arena. Low pinged and high pinged bastards.
yeah, i used to play quake 1 arena
Living in AK I was always an HPB haha
players want there input to be responsive, so when we throw a grenade, the animation etc is instant
same as weapon fire, movement, etc.
ugh, I'm getting PTSD flashes from playing R6 against Chinese players with 300 ping that had the upperhand because of lag lol
Thats ours as well.
Anim goes, grenade just pops in when it reps
yeah, same
The anim covers it for the most part
we spawn the grenade quite early in the anim
Yep
That's good to know. I won't predict some of my skills in the rpg then.
idk that ping plays that much of a factor in an RPG
In fast paced action, Players arent watching their grenades come and go, they care more about not dying
Rule of prediction: Predict as little as possible to make the game feel responsive, people think they have to predict everything, i see it all the time in #gameplay-ability-system 😦
Well it's fast like Elden Ring
Thats our rule as well.
swinging a sword is never as fast as a bullet needs to be, I mean 😄
True
But GAS is supposed for most of genre of the games I guess?
GAS isnt genre specific no
It is easier to make network based games but I still don't like it from beginning.
It is so shitty for debugging.
Its a complex system.
My delve into GAS is going well so far
Hardest part has been designing the proper attributes and MMC/DEC setup
The worst experience I had is just wanna figure out where game designers setting the tag to make the character broken...
You can't search blueprint default properties
complex, over engineered, powerful, but when it works, it works well
there is some big changes coming to GAS in the future though
I'll bite. Like what?
The input chain is also not straight forward enough now. You are so painful to find out the combos graph, there's no.
So basically everything for debugging is staring at the tags changing during runtime which is not my favorite...
need help
You have the client character rep the event to the server? If that way, it not gonna work. Only possesed character (because of player controller) can rep the event to server.
Yo!
Server-side, how can I know the last world-space movement direction of a Character?
Get the Velocity from the CMC for example
I tried that- the problem with that is that for example, if a Character is running straight against a wall, using their velocity for this calculation will result in a wrong direction.
The player is running against the wall but the resultant direction will be the character walking slightly alongside the wall. Does that make sense?
There are scenarios in which obtaining a character's direction from their velocity will result in a different direction than the character's desired direction from their movement input vector
I thought ACharacter->GetLastMovementInputVector() would do the trick (and it does, clientside) but that method is not replicated.
There should just be a getter
It's the movement direction times the acceleration value. So if you normalize it you get the input direction in WorldSpace again
Hmm, auto-complete isn't giving me anything from ACharacter (tried "Accel" and "GetAccel")
I'll google around for that getter though! Is that value replicated?
Found it, thanks! "GetCurrentAcceleration" from CMC
I'll just normalize it and use that as a direction then. Thank you very much!
No biggie. (:
it is npc that isnt replicating properly
client character works fine with replicating its own fx, its just the npc having problems
Client character means the player character on client side? If so, they still has the player controller. NPC has no player controller so it would not be able to rep the event from client to server.
it doesnt
NPC is on the server
Are they replicated?
their movements and stuff, yea
animations too
its only the niagara spawning that isnt working
Did you spawn it from server?
i did it in multicast
Would you like to show the code if you don't mind.
sure but its messy looking
\
maybe i shouldve said before but this is specifically the npc controller
Is it AIController?
AIController doesn't exist on client side.
yea
whys that matter
So it won't spawn because client doesn't have the controller to receive RPCs...
doesnt client take any RPCs from server
It does, but the condition is the client needs to have the replicated actor from server.
AIController never exists on client so it is not able to receive the RPCs
You may change the code to NPC character class and give a try.
why
ill try it
Just imagine that like your server send the event to null instance.
If you are asking why AIController is not existing on client, because it is supposed to control only on server.
wym the server already knows the player character instances and the aicontroller instances
what would be null
Sorry, I cant find the doc I read. But just be good to remember that AIController is not replicated and it is only on server just like gamemode
works!!
was it from the wiki or official docs?
It is not. Unfortunately, official doc is not such detailed.
yea unfortunately
is there anything else i should know net related
https://wizardcell.com/unreal/multiplayer-tips-and-tricks/
I didn't read it thoroughly but it looks good to check.
trying to set up multiplayer spawn system and everything is going good but the server player cannot control the pawn, any ideas?
ok thanks
How did you possess?
the actual posses part of the blueprint is in a custom function on the game mode
To add to what Joseph.S was saying, it's not about clients "taking any RPCs". Actors or components that are not replicated do not have a connection to clients, thus, there is no network communication happening that would allow an RPC to fire.
AIControllers are one such actor that doesn't get replicated to clients as there's no need for them to be as they are handled exclusively by the server, so you can't reference any AIController on a client. The server can still reference any.
Player Controllers are replicated to the owning client only, so when executing something on the client, you won't be able to reference any other player controller other than the one that belongs to the client. The server can still reference any.
When dealing with Server->Client RPCs, they can only be executed on Actors that are owned by a client, then that particular client will execute it. So if you tried running one on an NPC, I believe you'll get a message about there being no owning connection and it being rejected.
Similarly Server RPCs (Client->Server) can only occur on client owned actors that were spawned and replicated by the server (though there is a way to spawn on both server and client separately and make them net addressable). Any other actor will result in the RPC not going through with a similar error message.
Multicasts can occur on any replicated actor even if it is not client owned, so long as it is executed by the server, though the actor may not necessarily be considered "Relevant" for all connections (there's ways you have to control this, based on distance etc.) and then it won't execute on any non-relevant clients.
there's a part in my blueprint code stating that if the target is controlling a pawn destroy that actor and I bound a key to trigger that event and it is destroying the actor on the server side which I cant move in. So i guess I am technically possessing it but for some reason I cant move
Can you just try a simple test that spawning and possession?
not sure I know how to make it simple while keeping the same base function, heres the part of the blueprint i think is messed up some how
When dealing with Server->Client RPCs, they can only be executed on Actors that are owned by a client can only be executed to an actor owned by a client? or from?
thats in my game mode blueprint
Where is your player controller from?
thats from my player controller BP, heres the code
You execute RPCs on actors. The direction is either to or from a client and the server and I indicated in that quote it was going Server to Client.
Essentially, you can have a replicated actor that exists on the server and client at the same time, but in the concept of the engine, you have a single reference between both.
not sure if this helps but even when I run it in standalone I cant move
AIControllers are one such actor that doesn't get replicated to clients as there's no need for them to be as they are handled exclusively by the server, so you can't reference any AIController on a client. im confused on this
do RPCs automatically send the actor it came from and so if the receiving client doesnt have that reference it doesnt work? or is it hard-coded for clients to not take RPCs from server-only instances
The RPCs would have a reference to the actor they are using, and yes, if the client doesn't have that particular actor, it can't work.
Before the RPC is actually sent, the server already knows if an actor is replicated and if it is relevant to any particular client, and would only send the RPC if it knows the client would be able to receive it.
so would it be possible to send "anonymous" RPCs?
What is an anonymous RPC?
doesnt send extra data with the reference to the actor it came from
Unreal Engine's replication system in blueprint RPCs requires you to send an RPC through an actor.
No actor, no send.
ok but what about cpp RPCs?
Same. You could probably code your own replication system if you wanted in C++.
Actor RPCs will be sent on that actor. Period. It needs an actor to do it.
Did you put a breakpoint on the possess to make sure it fires? Also , get in the habit of using redirect nodes, having wires cross each other and go behind nodes makes it harder for yourself and others to read and debug your code
sorry not too comfortable with replication, i have a server and client players and i run this on bp_Thirdpersoncharacter but this does not replicate to my new level it opens (neither sees eachother). Any hints or help? Thanks in advance!
https://www.youtube.com/watch?v=ad5MZLSDAZk
I have been following this tutorial I have made Dedicated server and client builds but the issue is when I copy my client to different pc which is connected to different internet it is not connecting to Server.
what can be the problem ? I am using open comand whit IP
if any one have any other good tutorial plese mention
I want to make simple DS in which client can conect from any where
Patreon: https://www.patreon.com/SneakyKittyGaming
Discord: https://discord.gg/W5g6pZXfjh
Ultimate FPS Template Plugin: https://www.unrealengine.com/marketplace/en-US/product/ultimate-multiplayer-first-person-shooter-template
In this video we setup our project so make it easy for us to package both client and server builds!
ExecuteConsoleCommand instead, with servertravel YourMapName, and make sure you press that input on the server player
The persistent data compendium from pins should get you covered on travelling as well
oh damn thanks alot! Didnt know these even existed, alot of new stuff to look into!
can we keep an ui when opening a level from a server to load from behind ? like to have a smooth transition between the lobby and the game ?
Yeah a loading screen you mean
This engineer-oriented talk about assets loading management for good performance and smooth transitions by Epic Games' Support Engineer Axel Riffard goes over different methods to craft beautiful and highly optimized loading pipelines for your game, be it single or multi player.
Learn more about Unreal Engine at http://www.unrealengine.com
i'm not sure but with that we can;t keep the current widget no ?
What current widget?
All widgets are destroyed upon a hard travel
A loading screen works because it's handled a bit different than regular widgets
Well it's a self contained module just to begin with
and also, can we asyncly load the online level before open it ?
like to avoid long loading and load ressources when user is on lobby
i was made multiplayer game
with steam online advanced subsytem
advanced session
now cannot opne project
beacuse i just switched project with 5.1
and now i back to 5.0
but cannot open project still
Loading the level is usually done while the loading screen is on. So the loading screen listens for a delegate to when the level has "fully loaded" and then it's removed
but can't i load it behind an other level then just open it to have the server replication and avoid loading time ?
Well, you could probably do that via online beacons?
Start loading the map you're going to travel to, and then it's just a matter of travelling to it?
Not something I did before, or that it was proven to work
And I don't see what you're solving here
You're going to wait for that one way or another
Waiting for that while the loading screen is on makes it much more natural
Hello, I get this error when I try to build a project from visual studio. Note: I have built the engine from source and the version I am using is 5.2. Build started... 1>------ Build started: Project: Trail2, Configuration: Development_Editor x64 ------ 1>Using bundled DotNet SDK version: 6.0.302 1>Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -Target="Trail2Editor Win64 Development -Project=\"E:\UEProjects\Trail2\Trail2.uproject\"" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild 1>Log file: E:\UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt 1>Using 'git status' to determine working set for adaptive non-unity build (E:\UnrealEngine). 1>Waiting for 'git status' command to complete 1>Building Trail2Editor and ShaderCompileWorker... 1>Using Visual Studio 2022 14.34.31944 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10). 1>Determining max actions to execute in parallel (14 physical cores, 20 logical cores) 1> Executing up to 14 processes, one per physical core 1> Requested 1.5 GB free memory per action, 7.89 GB available: limiting max parallel actions to 5 1>Building 6 actions with 5 processes... 1>[1/6] WriteMetadata UnrealEditor.version (Trail2Editor) cancelled
1>[3/6] Touch dte80a.tlh
1> Touch dte80a.tlh: Exited with error code 1
1> Touch dte80a.tlh: WorkingDirectory E:\UnrealEngine\Engine\Source
1> Touch dte80a.tlh: C:\Windows\system32\cmd.exe /C "copy /b "E:\UnrealEngine\Engine\Intermediate\Build\Win64\x64\UnrealEditor\Development\VisualStudioDTE\dte80a.tlh"+,, "E:\UnrealEngine\Engine\Intermediate\Build\Win64\x64\UnrealEditor\Development\VisualStudioDTE\dte80a.tlh" 1>nul:"
1>[4/6] Link [x64] UnrealEditor-VisualStudioSourceCodeAccess.dll cancelled
1>[5/6] Link [x64] UnrealEditor-VisualStudioSourceCodeAccess.lib cancelled
1>[6/6] Compile [x64] Module.VSSCA.cpp cancelled
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "E:\UnrealEngine\Engine\Build\BatchFiles\Build.bat -Target="Trail2Editor Win64 Development -Project=\"E:\UEProjects\Trail2\Trail2.uproject\"" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "Trail2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 9:05 PM and took 01.981 seconds ==========
Thanks man will try it
I'm in the process of modding Lyra's cosmetic system. I have a Lyra Tagged Actor that gets added as a character part like normal. In standalone I can use
TArray<AActor*> CharacterParts = CharacterPartsComponent->GetCharacterPartActors();```
To get the skeletal mesh of the tagged actor and then create a SkeletalMeshComponent as child of it to add another skeletal mesh, like a clothing item, and then have all the animation work properly setting the LeaderPoseComponent.
My problem is this doesn't work for muliplayer. On the client even though the character is displayed correctly the `TArray<AActor*> CharacterParts` comes up empty. Anyone have any ideas how to solve this or implement it in a different way?
Im trying to replicate control rotation, but im having trouble. The arrow on top of each player represents their control rotation in world space, and the text on the front of each character also prints the current control rotation.
However, these values only ever change on the client (the arrow momentarily points to the correct direction, but then immediately gets reset to a default direction)
here's my node set-up
I'd imagine it would work? but idk maybe not
I have the Arrow Component set to replicate
Try to read the rotation from the owner and request it to the servers as a property an let the Server Multicast it to all his Clients . The Server has to update his copy as well
Is that not what's happening in mine?
(also correction, clients on the server show up properly, but not on other clients)
(you can see here, the server on the right)
I thought maybe the second Client not having the right rotation replicated to him
oh
GetBaseAimRotation will return a replicated pitch if that's all you need
Or you can just set a replicated rotation variable on tick ON SERVER
or rather, do something like this
Tick -> Run on Server Event (passing over control rotation)
Run on Server Event -> Set MyReplicatedRotationVariable (using passed in rotation)
how would everything else know about it changing?
dont you need a multicast to do that?
and are you saying the server event needs an input to replicate everywhere?
like this?
or is that just for convience?
the arrow rotation works, but now the text doesnt
(it just says "Text" on the clients)
can you try to call the Multicast function from the Server with the Rotation value?
i am going to send you an example
maybe something like that
the fact that it's replicated
If you're new, just forget that multicast exists
rly?
yes, it's a trap
use run on server event to send stuff to server
have server set a replicated variable to get it everywhere else
use repnotify if you want to update something when that variable changes
btw you can use GetBaseAimRotation to get the control rotation pitch on clients
what if you want a function that changes a lot of variables to run on the server and all clients?
also, Isnt the way your saying make it so every action is serverside? I basically want most functionality to be client-side (as I dont want server lag to affect input actions), and have that get relayed to the server and get shot out to everyone else
buut idk
btw, how do you know when functions like these are replicated or not?
Any idea why spectating a bot in multiplayer using setviewtarget would be stuttery?
Feels like replication for the bot's position is being throttled
is there only supposed to be one player controller when using multiplayer?
Does the Open Level Node work in a listen server to move all players to a new level?
Or is it only meant to work in a singleplayer setting?
Does anyone know a fix to host seeing client animation jittering? client to client is fine.
I tried setting bOnlyAllowAutonomousTickPose = true; but this time the client play the animation twice as fast
is there a setting where I can set the tickrate?
There’s a post from Datura higher up in this channel from a few days back where he addressed that I think
I will look through history msg, thanks
just thought it should be pinned, isn't it like a very common problem for Multiplayer. Can't find solution either, there is the bOnlyAllowAutonomousTickPose but it made the animation running 2 - 3 times as fast
Try here #multiplayer message
Not sure if it’s your issue exactly but maybe it’ll help
I read it, not the issue unfortunately
Host of Listen Server sees low fps clients’ animations incredibly laggy/jittery. I’m using default UE’s Character with Character Movement Component. Clients see everything just fine. I’ve seen a lot of post about this issue but little to none solutions, atleast none that would work. Does anybody have solution for this?
Would love if someone can address this, I mean it literary happened right off the bat with every fresh multiplayer project.
kinda suck if some people are forced to host dedicated server just to get rid of the problem
https://www.reddit.com/r/unrealengine/comments/a0n455/listen_server_host_sees_clients_jittering_fix/
14 votes and 9 comments so far on Reddit
I made a door, and it works
except for
when someone open/closes it, then the other player interacts with it, it tps back to the opposite position and does the animation
even thought they door is in the same state on both perspectives
it only happens when i wait a while
Hello, sadly i have another question regarding loading screens for my listen server multiplayer game. I've created a custom GameInstance class to create LoadingScreens with the movieplayer. Then I realized this does not work with the console command "servertravel" as the events PreLoadMap and PostLoadMapWithWorld dont trigger. I would like to avoid using seamless travel as my game is already built around having different GameModes and PlayerControllers. I know I could just use a PlayerCameraManager to avoid having the player see 0,0,0 for some time but I still want to have an actual loading screen regardless. Are there any good options I could take a look at? After this approach not working I'm kinda lost again
If other people need to see it, it has to happen serverside
you can predict locally
@sinful tree well, yeah you already posted this when I first asked about it and thats why I tried the custom GameInstance class but I cant use the delegates with the execute console command. And I would still love to use an actual loading screen and not just rely on the PlayerCameraManager like I already said. Thats why I was asking if there might be a workaround with using console command servertravel or something else
Oh did i imagine the response just now?
hey guys is there only supposed to be one player controller when testing multiplayer?
can someone tell me why only one player controller is being created for me when im playtesting with 2 people
each client only gets it's own player controller replicated, not the others
well yea but shouldnt both player controllers show in the outliner?
No idea about the outliner, are you playing as server or client?
im playing as listen server
If it's the server outliner then sure. If it's the client's then no
i keep getting this error
ya its not showing on the server side either
but if i print it out from the game mode it prints that it is there
Its meaning and how to fix it can be found in the tips and tricks article found in pins
Then the server outliner should have it
You are simply not looking at it
well why doesnt it then
There is a cog
what is cog
is it called cog?
Are you trolling?
It's short for cogwheel
If you're in PIE, there should be an option to pick a world
also it may be worth noting that the player state and the player character are showing for both, its just not the player controller that is not showing for one of them
oh i see now
now it shows
but then why am i getting that error?
shouldn't that mean it does have an owner
I already pointed you where to look
Maybe that get you covered or you better understand what's going on and get back to us with a better question
aight thanks for your help man much appreciated 💟
It's getting depressing, why do Server see client animation differently than client to client
does it have something to do with TickCharacterPose? I tried solution online specifically here
https://www.reddit.com/r/unrealengine/comments/a0n455/listen_server_host_sees_clients_jittering_fix/
but now the animation speed on the server is based on the frame rate
15 votes and 9 comments so far on Reddit
in 144 fps, the run animation play 2 - 3 times faster while in 30 fps she is just moon walking
I can't find the answer for years
Wait, your issue is fps related ?
After i make changes then yes
I mean don't u all have this problem?
we can test with any template
I mean those are usually solved by using delta seconds no?
The jittering?
The issue is only listen server see jittering animation/fast animation depending on the server frame rate
Differences in movement at different fps
client with other client sees everything perfectly normal
This problem can't be seen in PiE
once they are packaged and tested on multiple computer. We can see the very apparent de-sync with listen server on animations
Client to client sees everything normal
That link you posted seemed to give a solution, tho it seems you might need to go at it through cpp
I've been trying to do it in CPP, i see changes
the changes is now that the animation played depending on the server fps
So then do you have a way to fix that now with world delta seconds?
I wouldn't have a clue, and I don't really understand the source of the problem. So everything that server see is "raw" according to the post
trying to translate how that works in the engine
"This is because the server ticks the skeleton's animations only when they receive network updates"
Ok I seem to fix it
disabled TickCharacterPose in MoveAutonomous
I removed this condition tho CharacterMovementCVars::EnableQueuedAnimEventsOnServer
.... hopefully that didn't cuase problem
Why wont my timeline replicate right?
The value changes when I use the server
but when the client does the values dont change
so there is a jump in the timeline if the server uses it again
Sorry, that's why I removed it - realized it was you that I had posted that to originally.
Its prolly not the timeline itself but how you're calling the timeline to be played
I know the timer does not change if the client opens the door
but you can still see it on both ends
Run that timeline on a multicast event and then add a RepNotify 'IsOpen' bool to handle relevancy
Something similar to this
okay ill try that
And this, but yours would be setting rotations not locations
thank you
what is the w/notify thingie?
This is too complex for me D:
When you mark a variable as replicated, there's a "notify" option. In blueprints, these kinds of variables have "OnRep" functions automatically generated for them that will get called when the new value is received from the network - it can also trigger on the server.
oh okay thank you
Is there any text I could read to help me with making a this?
I dont really understand what im doing
Yeah, mountains of it in the pins
oh okay thank you
hey do characters always have authority?
it never prints the client fireing to server
Generally:
If a client spawns an actor, the client is authority on that actor.
If the server spawns a replicated actor, the server is authority on that actor.
oh i see
so because my gamemode is what spawns it, then it is controlled by the server
is that right?
Server should have authority of the actor if spawned in game mode, yes.
ok but that should still not affect how my code works is that correct?
so that would mean the issue is with the multicast
Well, if you're calling this on an actor that is not owned by the client, then it wouldn't send the RPC to the server.
If you're calling this while already running on the server, then the multicast should go through.
Also should there be multiple characters that are server or should there be only one?
Any character that would need to be replicated should exist on the server.
Otherwise, I'm not sure what you mean by multiple characters that are "server".
trying to call this server spawn player custom event when a character dies in multiplayer of course (this is in my player controller BP). I can get the player to spawn with a simple keyboard input but cant get it to work on character death any ideas?
Are you able to show how your character death works and where it attempts to call this? Nevermind... I see you posted in #blueprint
thats actually just how my enemy dies ill put how my character dies in here 1 sec
you know what from what the person in #blueprint just told me you cant execute code on a destroyed actor and i had called the server spawn event after destroy actor lol should i make a separate function on my player controller that when called destroys actor and then calls the server spawn?
actually that's not working I cant call an event on my player controller from my character
Why not
i swear any time you say why not it all of a sudden lets me lmao
what would i need to put as the object reference for the call to the event on my PC
hm my project seems abit laggy when im playing it is there a way to se if that is preformance issues or coding issues or something
?
nvm i finally found a solution at long last its been like 3 days 😭
Hello, I have been working with playfab and unreal recently and I faced a problem with the "Create Server Matchmaking Ticket"... It's giving me an error code of 1000 even thought I did everything exactly as said in the documentation.
Get player controller probably
There is no pin for player controller... if someone already worked with playfab and unreal dedicated servers I hope they can help me. Thanks
I was replying to someone else
mb sry
alright new hurdle to pass, this code on an actor that will be an enemy is on launching my server side character but not the client side? ill be doing some digging but if anyone knows a quick solution let me know.
You can't execute Server or Client RPCs on non-owned Actors
If that actor isn't owned by the specific client that calls the RPC it won't work
Also you are using the Input of the Server RPC to calculate a value in the Multicast
That's as wrong as it can get :D
: )
You'll have to send that value with the Multicast if you need it
i see so would a work around be to create this as a function in the game mode and multi cast it and then call this function from the actor? and i need to increase that integer by 1 every time the launch character node triggers i assume ill somehow have to get that to the game mode?
No. GameMode doesn't exist on Clients
If this is an AI then you only need to call this all on the server
If the integer has to exist on everyone then mark it replicated. That's it
This being the incrementing of the int
You can also just send the int along additionally
The server RPC is probably your main issue. You can only call those in client owned actors
If this is confusing then you should read (re-read) the network compendium
ah i see ok ill mess around with that
Hey there!
Sorry for replying to a month old response. I'm working with the gameplay ability system and i've also watched Delgoodie's CMC tutorials. Sprinting and other stuff makes sense, though I was wondering how one would go ahead and implement movement modifier gameplay effects with GAS that play nicely with the CMC's prediction framework. It makes sense to add sprint speed modifiers inside of the CMC and stuff but it surely is not a manageable method for gameplay abilities where you could have hundreds of different abilities/effects that you would want to apply to characters to modify their movement speed. Imagine stuff like equipping items that grant movement speed buffs, or simply being hit by an ability that reduces your movement speed by a percentage. Has anyone tried something like this before?
@grand kestrel Apologies for the tagging. I've found you as the author for this git repo: https://github.com/Vaei/PredictedMovement/
Can I ask for your suggestions/opinions on the matter I've posted? 🙂
Also, if direct tagging is a no-go here, please do let me know so I can avoid it in the future.
Whenever you set a variable to RepNotify it creates a function along with it so any time that variable is set it will also fire off the function, multicasts will fire for both server and clients but they only happen for players who are relevant to the actor at the time the multicast event is fired (https://cedric-neukirchen.net/docs/multiplayer-compendium/actor-relevancy-and-priority), the RepNotify will update those players who aren't relevant to the actor when the multicast is fired, so in my example the multicast event will play the timeline to open the door, a player who is on the other side of the map wont see the animation of the door opening but they do need to know if the door is open or closed when they become relevant to the door actor, so in my OnRep function im checking if IsOpen is true, if so it sets the door's location to its open location, if not it sets it to be closed at its closed location
Using the multicast will achieve the behaviour you're looking for but it wont handle relevancy which can cause issues with clients being 'out of sync' with the server
Hi! Maybe someone knows in what direction I can search. I have a listen server and one client in LAN. I can connect from client to server in the editor. But in built version I cannot connect to the listen server. One more interesting thing is that if client and server are on the same machine, then connecting to server hosted on built version works fine.
How do you connect exactly?
open myip:7777
Strange. Can you find the session via findSessions node?
that doesn`t work too
How you open the session?
open MyMap_P?listen
Not sure if you use c++ but try using the create session node and check lan bool
hey y'all I used to have a button in my editor to add a client once the game was already launched but I can't figure out how to activate it :/ I'm using unreal 4.27 btw anyone have an idea ?
Ofc you need to search in lan on the client too
whats the simplest way to replicate a characters rotation? should this be handled in the movement component like the location is?
The movement rotation is already replicated
does it get it from the controller's desired rotation?
Usually yeah
You need to override virtual void PhysicsRotation(float DeltaTime); in Character Movement Component if you want a rotation that doesn't fit with the existing settings
(which is either follow movement velocity or control rotation)
ah ok, so i guess best practise is to 'set control rotation' in the player controller and let that filter down to the character/pawn?
IMO yeah
cheers
currently getting location under cursor and rotating control rotation to lookat cursor location... kinda dont want to do it on event tick... any better solutions?
maybe a Timer by Event?
tick is fine to me
controller ticks already and before character movement ticks, so there's no benefit to not doing it on tick
Do you only want to get it every X seconds? Or do you want it every frame? Timer by Event is objectively worse than Tick
Don't be scared of Tick
Timer by event makes sense when you are like, "I only want to do something every X seconds".
Timers just tick under the hood anyway.
ahh ok
makes sense
i can use Tick because it's pretty core to the gameplay to have up-to-date player rotations (Y)
hey guys, why when i call get All Actor of Class in game state it return 0 but when i call it on player character it return not 0 (but 10)
i already tried delay but still return 0 in game state
What class? Is it a network game?
Hello, I have been working with playfab and unreal recently and I faced a problem with the "Create Server Matchmaking Ticket"... It's giving me an error code of 1000 even thought I did everything exactly as said in the documentation.
Can any one help me?
my BP class named BP_Card
Are you using the correct game state?
yes
in game mode
i print string it
Usually it is like replication problem.
in begin play
but i try in single player first
it still return 0
i think its a bug
Are you sure they are spawned when you getting them?
Definitely the wrong class then.
yes i already try call Get All Actors of Class in the game state begin play and BP_Character in begin play. but both return different result
the same class
Are you sure they are spawned when game state starts?
guys i figured it out
i call the get All Actors of Class inside function that i made in game state and it return 0
but when i try to call get All Actors of Class directly in Event BeginPlay in game state it is working
strange
You're calling your method before begin play happens.
Do you call it in the constructor or something?
i call the method/function in the begin play game state
You need to show us your code, I think.
what happens if you put a delay of 5seconds straight after the begin play?
already tried that. but still it return 0 inside that function
How do you know the other one is returning zero?
Switch authority? Are you sure it is server?
i print string it
yes. i play 1 player only
in editor
If you play it as client, still could be simulating the network environment
but im sure its called in authority because the print string inside set trigger location function was called
i tried it without switch has authority too
i think it cant call get all actors of class inside a function
How is you instances I mean they are spawned or placed in the level?
Print string what, exactly?
placed in the level
print string the length of the returned actors
So you don’t have network simulating totally, but it doesn’t work?
yes its strange im planing to create a new project
it return 0 on function but return 10 when called directly in event begin play
That sounds bizarre. It should work inside the functions
Have you tried moving the modes directly to the begin play event and not using the custom event?
nope. im planing to recreate simple project and reproduce this scenario and see if it still return a 0 actors inside a function or not
Try just connecting the node up to begin play.
fyi: im on unreal engine 5.0.3
Will take 3s to test reconnecting the nodes.
did u play as listen server?
Hey guys, how would you tackle montage replication with starting position?
mainly for drop in player to stay in sync with everyone's animation
check AbilitySystemComponent.cpp
it has an implementation inside it to sync montages
I think you have to ask yourself, too, if you even need it. Is the montage a few seconds long? Who will care or notice?
Can anyone help with this issue. I have setup a vehicle system that uses a interface to take control of car when interacted with instead of possession. entering and tasking control of vehicle camera works fine I can rotate and see around car but the input for throttle does and steering does not work even tho it's the same interface as to rotate the camera around
Everything works fine single player and I can drive around but multiplayer client can enter car and rotate camera around but can not drive it
Probably the server is not receiving the commands to control the car.
the way we did it was to mark the vehicle as autonomous proxy
and sets its owner to the driver, then do a client rpc to setup the inputs on the client side
we reverse this when driver leaves
ok so I studied the network compendium and I am still pretty confused I think... currently all of this logic is on an actor that nobody owns which I now realize I cannot call RPC's from. I would think that the logic for my enemy should actually be on my enemy but it seems I would actually have to have all of this happen in the game state BP? in that case wouldn't the Gamestate BP be flooded with blueprints once I have much more enemies? (context this code is trying to launch all players in the session once the boss's health falls below a certain point.)
Question: is CMC's velocity replicated over the network to SimulatedProxy?
Basically I just want to know if I can use GetVelocity to determine, in a machine whose role is Simulated Proxy, if a Character is moving or not
i would put the boss logic either in the Behavior's tree, or in the character BP, the AI is always server side anyway, so what you have to do is replicate the necessary parts to the clients
I can't read the screenshot, too low resolution. But it sounds like you're trying to have NPCs make decisions on the client and then tell the server about it? You should be deciding stuff like that on the server.
whats the behavior tree?
to do that on the server i would run that through the game state right?
the BT(Behavior tree) is recommended for complex ai, it is a much more organized and better performant method to controll AI behavior. especially for boss logic BT is the best solution if you ask me 🙂
Gamestate is more for tracking the games progress that needs to be replicated to the clients, Like Kills in a team or captured flags in CTF for example
Thats an example behavior tree, you can set the exact behavior of the ai and its conditions to trigger
ahhhh i see ill have to look into AI then i was avoiding it until i could just make a static enemy do the things a I want but since that seems like the better solution anyways its time to bite the bullet
This is in my player
if I am the host, the Inventory HUD is valid
if I am the client, its always null
Maybe there a flaw in my logic but I was in the thinking that the UI and updating it would be client side, do I need to do RPC for this or my solution is just wrong?
the logic seems fine, it just seems like you just didn't set the game UI on the client
since you're saying it's null
you will need to do an RPC if you are storing your items on the server, but if you're storing them locally and you only want to locally operate on them, then you won't need an RPC
hey why does my tick in c++ for my character print has authority = true but in blueprints it prints false?
If I pass a uobject pointer as a parameter in an rpc, will the engine serialize the replicated uproperties for me, or does it only work for actors?
UObjects don't replicate, so you cannot pass them as a parameter in an RPC. There is a guide in the stickies about replicating UObjects.
Still trying to get my head around client/server multiplayer. I have tried making a event called send vehicle input containing a has authority switch with a server rpc and multicast but still doesn't work
why are you multicasting input 🤔
You can't send server rpcs from an actor you don't own.
thx
Since you aren't using possession, you don't get ownership.
Kaos gave you a solution to that.
I do own thr charactor am sending it to the vehicle
I am using a interface on the vehicle and if invehicle is valid on charactor i send the normal move and mouse input to the vehicle instead of the charactor
hey guys why does my print print playercontroller 0 for both players?
Because player controllers don't replicate - the local controller is always referenced as 0 on a client.
Show your code. Specifically the part where you send it to the server.
oh
They do, but only to the owning client?
so even though its saying 0, it means the pc1 right?
OK give me 2 mins will take a few screenshot
It's a good idea to stay away from trying to reference players by index in online multiplayer.
well i was tryna debug lol
im not actually referencing by index
You can do it for the player array on the game state, though, just don't use it for plaeyr controllers.
Though that array is liable to change, so storing an index to be used later is a bad idea.
why does this never print for the no authority
shouldnt one print on the server
and one for the client?
this is in tick btw
no, because you checked IsLocallyControlled right before that...
That'll only print authority for a listen server?
so the tick doesnt run twice? one for the client and one for the server?
it does, you just checked IsLocallyControlled which isn't going to return true for the server if it's something controlled by a client
never? I have no clue what you're doing
ok, but why do you care about whether it's locally controlled
you're throwing random functions at this without understanding what they do
Just run teh method. If it's a client, it will send it to the server. If it's the server, it will run it locally.
(assuming all other criteria are met)
so like this?
No
1st Image is vehicle Controls 2nd is charactor on enter vehicle and 3rd is redirected controls from charactor
what did i do wrong?
So from what I can see, you don't actually send the input to the server at all?
The only thing you do is attach and detach the player to the car.
(over the network)
but why would the camera rotation work?
- Just call the method, not the _Implementation version. In this case, ServerRPC_Move.
- Don't multicast this information out, just set variables in your player (I assume?) and replicate them normally.
Because the camera is local?
Idk.
no i am using the interface to control the vehicle spring camera
So? It just means that hte server isn't resetting the spring arm component's transform.
You're still doing only on the client.
The server isn't being notified of this at all.
oh i see what you mean
I don't know what "Set Throttle and Break Input" is doing.
But it will also only be executing locally.
Same goes for the steering.
If you have some authority check in the steering and acceleration methods, that's why it does nothing on your client.
that is part of the advanced vehicle system
Well, yeah, you arne't the owning client, so it does nothing.
i thought multicasting was good tho?
Multicast being useful is extremely rare when compared to direct rpcs and regular replication.
i see
i have set the owner to the character that enters on the rep notify
Shrug Idk.
😭 lol i might just have to stick to possess kind of ruins the game but never mind lol
You should stick to having your controls in the PC and forwarding them to the server. You can then forward them to the local versions of the actors for local simulation and let the server do it itsefl as well.
Paint skills++
i just followed a guide on how to integrate vehicles into lyra but it was not replicated so just tried to do it my self lol
Multiplayer changes the entire dynamic of how everything works.
yeah i figured that everything is so much more complicated lol
Tbh, you should even design SP games thinking about MP. It stops you doing sloppy code.
im a bit confused, if i have an input that rotates my character, do i send that as a parameter through a server rpc, or what?
actually i forgot to say if i connect them both the car wheel spins but does not move if that changes anything lol
Probably?
alright thanks
[2023.05.16-15.26.54:726][412]LogNet: UNetConnection::SendCloseReason:
[2023.05.16-15.26.54:726][412]LogNet: - Result=MissingLevelPackage, ErrorContext="/Game/ThirdPerson/Maps/TestMap/Generated/TestMap_MainGrid_L0_X0_Y-1,/Game/ThirdPerson/Maps/TestMap/Generated/TestMap_MainGrid_L0_X0_Y-1"
How to solve this problem? 5.2
This problem occurs when connecting to the server and when a level uses World Partition
question, does setting an actor to dormant all have the same affect as initial so that when the game starts it does not send everything over the network before shutting itself down?
DormantAll will cause the Actor to be removed from the consider list when determining if its variables should be replicated.
Initial Dormancy only affects Actors that were placed in the level.
gotcha, and if an actor thats placed in the level is set to dormant all would that actor have the same effect initially as if i set it to intial?
hey can someone explain to me why when i use the addmovement input it only adds it to the server character but if i use the add velocity one it moves both of them?
how can i fix it?
AddMovementInput should be handled by the Client, not the Server.
gotcha. doing some testing to figure that out, thank you
Generally you want to use InitiallyDormant for an Actor that may need to replicate in the future but could also never need to replicate throughout the course of a match.
So for example.
A Machine Gun Turret thats placed in the Level.
That requires a Player to interact with it to perform actions
but even if i just do it in the tick function normally without calling the rpc it still only works for one
Throughtout any given match, no Players may ever interact with it.
But there is a chance that they could, at which point you would flush its dormancy
thats basically the situation, many interactables that may or may not be touched but when they do we would have them go back to dormant if not interacted with after X time. kind of like fortnite trees
Yep.
An Actor can only be InitiallyDormant once.
You would set it to DormantAll after the fact.
I believe it assumes DormantAll after the fact anyway when its dormancy is checked and its already been Initially Dormant and its set to it again.
I cant remember.
would i have to fire a client rpc to fix this problem?
because my characters are naturally server controlled?
What do you mean they are naturally server controlled?
Unless they are NPCs Pawns are controlled by Players.
Generally speaking.
ok so then why does the add movement input not work in normal tick?
it only works for one person
that seems to be what testing showed, atleast with FlushNetDormancy, starts out as intial, once flushed it goes back to dormant all
Is it FirstPerson?
is it bad to have a net multicast for something relatively simple that may happen every few seconds?
AddMovementInput is not the same as adding an Impulse to velocity.
Impulse is a one time application
AddMovementInput is meant to be applied in small increments over many frames.
well ya i have it in my tick function
Depends, what are you talking about specifically?
so it should work
Is it for an NPC? If its not, you should be handling it with Key Input events.
As the Client should be controlling it through Key Inputs no?
well what i want it to do is continously move in the direction its facing even if im not clicking a button
and i rotate it when i drag my mouse
I'm looking to use a NetMulticast function that starts a timer on each client (up to 4 clients) which is basically a cooldown for an essential Actor in the game
so thats why i have it in tick
but not sure if that would cause lag
How often are you expecting to be calling that?
maybe once every 3-15 seconds
Perhaps you should take a look at how the TopDown example project handles it.
Well if thats what you need then go for it.
A single RPC isnt going to hurt in that period of time.
perfect ty, first multiplayer project 😛
ty! I appreciate the tips
Then worry about perf once you know all the tools available to you
Hello all, I am trying to do something relatively simple. I am trying to replicate the result of a trace made by my camera (so starting from my camera, going forward 1000 units or so - basically just a point in the middle of my screen some ways off in the distance).
The problem is that the character controller is not replicated to other clients, and so the camera isn't replicated to other clients it seems. Would anybody be able to provide insight?
The goal is to have my character's weapon point to the direction of that trace result, which works totally fine in single player with my original implementation. Should I be doing something like adding a variable to the player state/character, and then editing that value, and then having that value be replicated? 🤔
Whats the purpose of this?
Have a Weapon point at the trace end on all Clients?
Is this a First Person game?
The goal is to have my character's weapon point to the direction of that trace result
To expand on this:
I want the tip of my gun to point to the end of this trace. Each client should see where each other client's trace is pointing to
its hybrid
i have figured out the control rig portion successfully, it works great in a non-replicated setting
But when I look at it from a simulated proxy, the guns of all other players don't actually point anywhere
(another step after is adding a delay, so that there is weapon sway - also something I have done, and works fine in the non-replicated setting)
The problem is that I'm using the camera trace, and the other clients dont have access to the controller (or camera). At least I think thats the issue?
Try utilizing APawn::GetBaseAimRotation to start.
So what I'm after is this:
I need a trace result that is stored somewhere in a way that is replicated and that is accessible by my ABP
I have this as a current fix, but its so much more complicated when dealing with the sway/weapon move lag
You dont want that on Simulated Proxies though, its not important to outside observers.
it would be nice to get it from the camera itself too for the purposes of determining where the bullet will end up, so you're always pointing to where you think you are pointing (if that makes sense)
in my case, the bullet leaves the gun in a straight line. So in this case, the sway could be important
if the gun is not pointing at you, the bullet wont hit you
Generally you will handle the Local Client and Server more accurately and have a approximation for Simulated Clients
Yes but you would fake the shot on Simulated Proxies.
Its an efficiency issue yes.
well, I suppose I'd like to try it without doing approximations and then worry about that later
i feel like what I'm asking for should be relatively basic: How can I send the result of a trace to everybody?
Sending anything to anyone is basic sure.
But you are going to run into more than just that as a problem
so in my case I do the trace on the client, then get the location of that trace, then send that data to everyone
and that should be sufficient I think? 🤔
NetMulticast or use a replicated variable
Well you will have to send the Clients version of the result to the Server so the Server can then send it to other Clients.
Which adds latency
Ah, I tried this and it didn't work. I must've done something wrong.
Should I be storing the variable on the character or something, and then selecting that as replicated? 🤔
how would I do this?
Thats the multicast right?
I actually have read that hahaha
Then you shouldnt be asking me that question
I'll go ahead and try asking my question again at a later time then
Sometimes people get really mean here and I'm not really trying to engage with that
From Client to Server
You are asking a super basic question, which is thoroughly explained in the document, however you say you have read it, Im just expressing that if you did read it and understood it, you should be able to manage it.
You would get the Client to do an RPC to the Server
Passing along the Hit Result
You might send this RPC every frame
And make it Unreliable.
So the Server gets as update to date version of it as often as possible
Then the Server would either update a Variable that is replicated
Or send its own NetMulticast RPC to let other Clients get that value.
No I'm sorry I don't know how to or where to implement my trace that utilizes my camera to get the trace result I'm looking for and where I should be storing that data. I can imagine a whole host of solutions, some better than others. Should it be stored on the player state, on the pawn, can it be stored on the ABP, etc.
Use the Pawn
As the Pawn is the one that is dealing with the information and providing the information
It is replicated already and exists on all Clients
So you should have no issues with RPCs and Replicated variables there.
(As you were before with the Controller since it only exists on the local client and the server, not remote clients)
So on my Pawn, I will having something like:
UFUNCTION(NetMulticast, unreliable)
void MyMulticastedTraceFunction();```
with the actual function definition having my trace which is based on the character camera, and then setting some variable that is stored on the character itself?
actually that can't work, because only the server can perform that and the server doesn't have the camera
You need the Client to send an RPC to the Server, which is Unreliable.
Then the Server does the Multicast.
UFUNCTION(Server, Unreliable)
void ServerUpdateLookResult(FHitResult LookResult);
UFUNCTION(NetMulticast, Unreliable)
void MulticastUpdateLookResult(FHitResult LookResult);
The trouble with this, is that the Client that sent the result in the first place will also receive the multicast.
So inside the Multicast you need to handle ignoring that Client that sent it.
Hmm okay. I'll have to work on this another time, there are specific implementations here that I don't know how to do
But thank you for the guidance
Is there any easy way to use a local player subsystem with a listen server design?
What do you mean?
Use it in what way?
Local Player Subsystems are exactly that, local.
They are not replicated in any way and only exist for the local player.
I'm trying to retrieve it from a component so I can listen for an event on the subsystem
On both listen servers and clients
But it crashes
if(UTestSubsystem* TestSubsystem = Cast<UTestSubsystem>(GetOwner()->GetNetOwningPlayer()->PlayerController->GetLocalPlayer()->GetSubsystem<UTestSubsystem>()))
{
UE_LOG(LogTemp, Error, TEXT("Subsystem found, binding Event"));
}
Ok well fix the crash first?
What is the crash saying the problem is?
GetOwner()->GetNetOwningPlayer()->PlayerController->GetLocalPlayer()
One of these is likely nullptr
And you have an access exception
Yeah, I know I should fix the crash first
You should always be checking pointers before trying to use them.
I'm asking to see if there is a better way to retrieve the local player from both the listen server and clients
And limit the number of null checks I need to make
The exception being if you're in a "pointer safe zone" where the input must be a valid pointer.
And this is guaranteed by the caller, not the function.
You can use the GameInstance to retrieve the local player.
Unless you are running split screen there is only 1 local player.
UGameInstance::GetFirstGamePlayer()
Looks like what you want.
👍
tracing locally to determine what you're looking at should be fine
so how would that work though? what exactly would the implementation be?
"Hey Mr. Server, I'm looking at this actor"
Server can check to see if that's plausible
well it can't be a multicast, because itll say "Use the camera to do it!"
and the server will go "I dont have the camera :)"
use your LOCAL camera
and that result needs to be sent somewhere
server does'nt care about the camera at all
then replicate a vector
hmm
"Hey Mr. Server, I'm looking at 420, 69, 1337"
yep, that brings us back to Matt's suggestion right?
For instance, I do this in my vehicular combat prototype
Dirty and not predicted but it works.
now everyone knows all 5 of those variables
yup in pawn
I see, and those variables are replicated. In my case, that means the ABP should be updated as well.
That's great, thank you. A very simple solution!
There are some considerations depending on what you're doing, like skipping owner if you want to sort of predict
in my case there's zero prediction, so not skipping owner is fine
with skip owner, you'd go like:
Tick -> is locally controlled? -> do the logic -> set variable (replicated, skipowner)-> send variable to server
Recive Variable -> set variable (replicated, skipowner)
so now owner has variable right away instead of waiting for round trip to server
I see, I definitely want to predict or even do client authoritative if that applies here
im doing a co-op game so idc about cheating
Mines all physics so prediction goes right out the window
ill take a look at these implementations, i really appreciate it 🙂
It's big lumbering vehicles though so it doesn't matter, not like Valorant or CS:Go
you could perhaps look into the savedmove stuff used in the CMC
SavedMove is a tall order with player-designed and built vehicles
i have made correctly predicted physics based sliding that way. I only get bad rubberbanding if i collide with something, but eh
op
your game sounds awesome though
hahahaa
My Server RPC doesn't appear to be called on the Server, both the actor (player controller) and the component replicate and I'm on the Client Net Mode
I'm testing it using a custom event in the player controller that has a button in the editor, I get the feeling that this is what is tripping it up as I've tested it with the tick (horribly practise but I had to test it somehow) and it seems to work fine on the Tick
c++ or bp?
C++ for the backend but the custom event is bp
I'm getting some really weird debugs as well:
LogBlueprint: Warning: Inventory: DedicatedServer: Searching for item at index: 1601070336
LogBlueprint: Warning: Inventory: DedicatedServer: Searching for item at index: 0
LogBlueprint: Warning: Inventory: DedicatedServer: Item at index 1419934112 is not valid
Those indices should never be above 20 at most
Might be a null pointer causing shenannigans.
I'm passing the index through the RPC which is getting increased from around 0-20 to 1419934112
It's just an int, I'm trying to find a way to fix it
Would const int& in the RPC help fix it?
Probably not.
I managed to fix it, it was entirely on me this time xD
I had a server index as I am using a FastArray instead of a normal TArray and I needed it to guarantee that the client calls the correct index on the server
So the Inventory Item had a Server Index, which is what I was checking but I didn't mark the item/array as dirty, so it didn't replicate, so the client never got the Server Index
Hey all, have a question about playercontrollers.
I have some logic for inventory that exists as fields for a PlayerController class. I want to use this logic for server controlled "player" bots. Is it possible for me to have a PlayerController that's only controlled by the server, and use my code to control it?
you would use an AIController for that
not a player controller
if this is some logic that needs to be shared between the two then think about putting it in a component and having that on both a player controller and ai controller
Hey, question for yall:
I want to replicate a var from the client that "owns" the Character to the server.
Are RPCs the best way to do that? I am essentially trying to replicate whether a Character is aiming down sights or not.
Should I just RPC the server and tell it whether I am currently holding the ADS key or not?
yes
you do not have any other options - RPCs are how you communicate from client to server.
Gotcha, so that's how I'm supposed to handle any sort of "input" that should be replicated, is that correct?
Aiming, shooting, reloading- I just RPC the server telling it that I have just attempted to aim/shoot/reload, do that locally as well for the local player and have the server replicate that to all other players, is that correct?
yes
Perfect. Thanks!
Oh one last thing- should I use unreliable RPCs for this?
I do not know how bad it is to use Reliable RPCs all the time for stuff such as toggling ADS on/off or reloading or firing.
You want actions that need to happen to be reliable.
Toggling ADS is an important action for the Server to know about.
Right. Yeah that makes sense.
Seems like this will be the way to go then! Thank you, both of you.
What if it’s set to hold to ADS ? On the forums someone was saying you don’t want to set things that are on tick as reliable, as they might cause bottlenecks but that hold input is checked on tick or thereabouts, no?
Inputs are processed every frame yes. But there are different types of Input.
Axis and Action inputs
Axis are ticked every frame.
Action are only executed on a change in the key state
IE: Pressed/Released
Therefore holding an Action key that is for ADS will only fire once as its still "Pressed"
It would then fire again when releasing the key
So in this case, you would only be sending 2 RPCs
Going into the ADS when pressing the key.
And going back out when the key is released.
RPCs that you want to call in a high frequency should definitely be unreliable.
Ooh that makes a lot sense
Would you know anything about using the server to mimic a client connection to a game and being able to use the player controller through that?
No, and that'd be way harder than just using an ai controller.
fair enough. thanks!
https://docs.unrealengine.com/5.2/en-US/introduction-to-iris-in-unreal-engine/ Do I still need to build iris from source now? Or not anymore? Seems that they added this page under 5.2
Hey guys, I'm trying to make character selection, is there a way to change and replicate the skeletal mesh of the player when he joins the match according to his selected mesh? thank you for any help
You shouldn't replicate the skeletal mesh. Instead, you need to index them and load it in their own client.
If they load it from their own client, how will other players see them as the correct mesh?
You replicate the index from server to each client, right? Then each client load the relative skel meshes.
Ohh I understand what you're suggesting, however I don't replicate the index, what would be the correct way to do that?
The principle is whenever the client change the avatar (I guess), RPC to server with the index, then server multicast to each client then they load the avatar by index their own.
Nice okay I think I understand, just one more question, where should I put those events? In the GameMode, or the Player Pawn, or somewhere else?
RPC from client to server: PlayerController
RPC from server to client: Usually Gamestate
GameMode doesn't exist on client side, never RPC anything there.
Okay, thank you very much!
You're welcome.
Hey, I'm running into a problem - I'm changing the mesh outside of the server session, in a separate level.
From what I understand, Game Instance is the only way to save variables across levels, but it isn't individual for each player.
Therefore, I'm not sure how to save a variable which will handle the mesh selection, while it being individual for each player and replicated
I don't quite understand it. You mean your client select some avatars in the selection level and you want them to bring into the real game match level?
Exactly
I need to store it somewhere, you're right when you say to store in Player State, but it won't keep these variables when I change the level
Luckily I've done this before. So you can create a subsystem for it (you can do it in game instance for sure, but just wanna keep game instance slim enough)
So your each client has their local copy of the avatar index and just replicate it to server right after load the real game match map.
So first I store it in Game Instance, then what?
Then your server bring all the clients in the real map. The client replicate the cached avatar info to server right after they get into the new map, right?
hmm I'm not sure what you mean
My thought it to maybe get the variables from the Game Instance, then store them in the Player State, and in the Player Controller it'll take the variables from PS and run it on server?
It needs to be after the new map loaded that's all.
Yeah so how can I keep those variables persistent?
In Char selection map: Player selected avatar-> cache them into game instance (subsystem suggested)
Level changes->New map for match
New map loaded: Client get the cached info from game instance, RPC them by PlayerController to server
Server multicasted them to each client
Client side load the avatar.
Ohhhh
All game mode related class will be destroyed after map changing so only way is game instance (subsystem)
What do you mean by Subsystem?
game instance subsystem.
If you are not familiar with subsystem you can skip it and refactor it later.
Only Subsystem I know is the Online one
I'm unfamiliar with that sorry
It's fine, you can just use game instance
Yeah okay
It's just from a view of programmer that can make the game more efficient.
And better code easier to read, that's all.
I see, I'll check that later thanks for the tip!
This is what I came up with (this is in my Player Controller), where should I call CharSelectServer?
It is a bit complicated that if you want the formal solution it will takes a bit time.
Like you need to check in the game mode that all the players are logged in
Then change the match state to pre-start
Replicate this from server to client, and the client do OnRep for the state changed to pre-start
Then RPC to server, and server multicasts to each client. Then client start to load the character.
If I'll change the meshes only after everyone is logged in, it means it won't be replicated until then, no?
Yeah, you can hide them at that phase😛
Oh I guess that's a solution 😂
But from where should I call the Event that runs on server?
From you get the OnRep event for your state changes.
Let's say I wanted to do it when I press K, just for testing, where should I put it?
Level blueprint😅