#multiplayer
1 messages ยท Page 551 of 1
sort of thankful Epic has tried it to some extent with the gameplay abilities
im fine C++'ing up all my game if that's what it takes
Does every player get their own copy of the GameInstance or is it just the host's copy that everyone gets?
ty
probly a really simple solution, but I kinda lack the knowledge...
how can I intercept this message on the server? All I wanna do is call "Quit Game" when receiving it
(basically just gotta know when someone leaves. It's a 1-v-1 game type and the overarching server will work perfectly if I can just shut the game down automatically)
I think the OnDestroyed method of the PlayerController on the server should be called after a player disconnect, maybe there is a more "direct" function
in C++ or BP you can override the "OnDestroyed" (in BP it may be OnEndPlay)
well yes it should work
actually, it assumes that you never destroy player controllers in any other way so probably not the best solution
the previous one gave a compile error hahah
well, the game is 99% functional ๐ I quite literally just need this to work whenever ANY player leaves
max player count is 2 per server anyway
I mean, depending on how you change maps, PlayerController could be destroyed
I mean I'm not I know every way a PlayerController could be destroyed, so maybe you would have some suprises along the way x)
Actually looking in the code:
void APlayerController::Destroyed()
{
if (GetPawn() != NULL)
{
// Handle players leaving the game
if (Player == NULL && GetLocalRole() == ROLE_Authority)
{
PawnLeavingGame();
}
else
{
UnPossess();
}
so PawnLeavingGame() in APlayerController seems to be when you can be sure it's actually your player leaving the game
if you can't access it in Blueprint, just doing the check they do should do the trick, if the comment is correct
sounds like I've got a solution. Thanks ๐
@glad wharf nope ๐ฆ didn't work
still getting that same output, and the game didn't shut down
can anyone help?? how can I intercept this message on the server? All I wanna do is call "Quit Game" when receiving it
I've currently got it bound to: PlayerController's Event Destroyed and Event End Play
as well as GameMode's Event OnLogout
How can I replicate a timeline?
Does a Projectile as an AActor sound like a bad idea? How else would be an optimal way to do it, where the unit firing isn't responsible for the projectile(unit dies, but projectiles continue) but the replication is efficient?
Also since I'm doing an RTS with 200+ units, I expect there to be a ton of projectiles..hence why I don't think the AActor way makes sense
How can I replicate a timeline?
I dont think you can
nor you should
what do you want to do @empty matrix \
@cosmic trail dont replicate your projectiles
just fire them both on client and the server at the same time
but check for hits on server
@twin juniper hmm so replicate the firing portion through the firing unit maybe, but spawn them separate but can be aactors still
yeah only let the both client and server know the direction
not necessary to replicate and its bad for fast things to replicate
it will definitely lag if you with replication
ok that sounds good. Thanks @twin juniper will try that.
I'm making a skill system for each character, and I made an ability for a character and made a very smooth disintegration effect
I did not understand
is disintegration effect has any functionality regarding gameplay ?
Yes, I did to balance the skill, as the other players need to see the disintegration working
well than go with multicast
timeline uses tick
Multicast is heavy too but better than replicating the timeline
Im not exactly sure what you are trying to achieve
but still timelines shouldnt be replicated
and I dont think they can be
Im not exactly sure what you are trying to achieve
@twin juniper I'm doing an invisibility stealth system
so is this effect for going in - out of invisibility ?
Then I put this effect to make a skill balance.
so is this effect for going in - out of invisibility ?
@twin juniper Exact
I'll send a video
you can use multicast for the effect
instead of firing the effect on only server and replicating it
you tell everyone to play effect on this player
It worked, but then when I click the "Z" key it doesn't work again
what do you mean Z ?
It doesn't actually perform the effect, but invisibility works
what do you mean Z ?
@twin juniper Z key on keyboard
Yes
cant say much without seeing the code
@twin juniper Copy and paste in some project, for you to understand
how did you manage the skill ending
@empty matrix shouldn't you use multicast/repnotify for such an ability
this is a problem
so you don't fall out of sync with the server
@empty matrix shouldn't you use multicast/repnotify for such an ability
@twin juniper Why?
there us too much delay node
so you don't fall out of sync with the server
@twin juniper Why?
there us too much delay node
@twin juniper So what do I do?
this effect wont fire until initial timeline`s stop + 6.5 seconds
from my knowledge if other actors aren't relevent when you go invisible they can fall out of sync with server
use timers
timehandles
if they are always relevent shouldn't be a problem i guess i'm new to networking though
Fire Go Invis effect on timerstart
leave invis after timer ends
dont use delays
they are bad practice on multiplayer
I am not really sure but someone else told me so I am a liar of someone else
anyways
what you can do is something like that
since those render in main pass and all those things need to be fired on every client
there is no need for server other than inital calling and setting the variables\
on server go multicast to go invis
Timeline for "Start" effect
and continue from Finished
sure use 6.5 delay
I dont understand
and put in the stop
and put in the stop
@twin juniper Please... I really need this
Hello,
I assume that because Widgets are client only, using GetController with index 0 will return the local controller?
all clients are index 0 usually
3rd time I'ma ask this here today... cus I really need a solution ;_;
How do I close the game when there's no players in it? Or when a player leaves? or just generally ANY way for me to shut down an abandoned instance??
Hello all,
I always get: "LogNetPlayerMovement: Warning: CreateSavedMove: Hit limit of 96 saved moves (timing out or very bad ping?)"
It works perfectly when dedicated server is run in Editor, but it doesn't work when I try to move on external hosted dedicated server.
I used "AddMovementInput" to move the character.
Everything else works: effects, items, players. I can connect but I get this error and do not know how to solve it.
For some reason the server is not getting / processing the SavedMoves
If someone can help me, I would be so happy.
@cursive mortar
you're probably not timing out when in-editor cus of no latency. Though I have no clue what the thing is you're actually using or whatevs
@thick jungle It's been already 2 days I am trying this on my own. Also tried to get some help and tried some tutorials, and it doesn't seem to work.
try sending it 20 times per second instead of every frame?
movement packets are usually not sent 96 times within the timespan of 90ms ping ;p
I don't suppose you've got any ideas for my issue right above yours??
@thick jungle Sorry Joey, can't help you. I also am not sending anything, or set the amount to send, I just use AddMovementInput on tick().
I really do not know where to search anymore...
@thick jungle when a player leaves, check how many players are left and call QuitGame if its's 0
@cursive mortar then you're sending it every tick ;)
set a timer on 0.05 second and send the packet in there
@hazy siren yeah, that's the theory... Where do I actually build that? Cus so far the 3 spots that I've found aren't doing that
what doesn't it do
I'm currently running build #6 of today having added this... I'm starting to lose hope..
shut the server down. I go into the game, get waiting on player 2, and press alt f4
the server then receives a "player left" log message, but none of this code is triggered
@thick jungle I will try with a timer, thanks ๐
@cursive mortar happy to help where I can ๐
I hope it works XD
@hazy siren every build takes me like well over an hour ๐ฆ any other suggestions?
Why would that be? You're not rebuilding anything
cus it's the dedicated server that needs to shut down.. so I need to package it into something that I can then upload to SVN, download it onto the server, and try again
you can invoke a dedicated server right out of the editor
and it will override the join ip address command to localhost??
(I did NOT know that btw)
gonna try it out once this build is done running ๐
if this actually works for testing... it should make it soooo much easier
@thick jungle I tried to move the character with timer, but it doesn't move at all anymore. XD I have no idea what happens....
@thick jungle It seems that as long as I have a timer in my Character, it can not move at all for some reason :/. Curiously the game runs at 400 fps when connected to the dedicated server. Maybe that is why I get ""LogNetPlayerMovement: Warning: CreateSavedMove: Hit limit of 96 saved moves (timing out or very bad ping?)"
I think I found the solution. Actually I am more than sure I found the solution. I will test tomorrow more and post it here for eveyrone else.
Anything special I need in terms of the code, etc when attempting to build the dedicated server?. I made a new Targets file.. rebuild the project files.. went in to build the "Development Server" and get: "Server targets are not currently supported from this engine distribution." I'm on 4.25.1
how does one kill and respawn a bot and keep its playerstate?
apparently i needed the full server code from github. Sometimes just asking the questions lights enough of a fire, eh?
If I'm a remote client, I don't have any knowledge of the NavMesh data. So, if I want to know whether I'm able to issue an order to an AI Character to move to a location... it seems like the only way is to ask the server to perform that check and get back to me.
Obviously, that doesn't scale at all because for every remote client on the server you'll have frame-by-frame queries going back and forth as people move their mouse around the world. So, surely there must be an alternative... right?
I hope there's something I'm just not aware of yet to help deal with that use case. At the moment, it seems like I would have to fake the navigation query for the remote client by just allowing the player to "think" that they can order the AI Character if they're just looking at any Static mesh in the World, so that the navigation check only happens when an order is actually issued, at which point we can tell the remote client that it's not doable.
league does something similiar i guess
you click it draws the second u click
and.gets fixed later on
Has anyone here messed around with making their own "components" like UCharacterMovement and replicating those?
I've found this related to the idea: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/30142-replicating-tarrays-crashes-game?59275-Replicating-TArrays-crashes-game=#post336177
For gameplay programmers writing C++ code.
When you find sessions, should it be returning full sessions by default? I'm currently using advanced sessions, which seems like it should return full sessions by default, but it isn't. If I set max 2 players and host, then join, and use a second client to search that session isn't returned.
@cursive mortar yeah. Probably.. ๐ youโre sending 400 movement packets over every second ๐
@thick jungle Yeah :))) I found now try 3 solutions for this, but need to work on the 3rd one which might be the best
@cursive mortar good luck! Iโm still stuck on shutting down the server when a player leaves :(
... ffs... I need to go live tomorrow and I need that thing resolved or I canโt ๐ญ
@thick jungle I hope you will solve it! best of luck to you! ๐
@thick jungle I don't understand, yesterday I totally forgot about GameMode::OnLogout, this one is not triggered on the server?
nope... none of the 4 methods I'm using are working... lemme re-send screenshots
(btw it's also based on the PlayerController being destroyed)
did you manage to run a dedicated server through the editor? It will indeed reduce significantly your iteration time
trying to get that dedicated server up through the editor atm. It's 8:30am and I just started 10 seconds ago
If you put a Print String right after the "OnLogout" (with the "log" option checked as it's in dedicated), is it displayed when a player leaves?
"D:\Engines\UE_4.25\Engine\Binaries\Win64\UE4Editor.exe" "C:\MyGame\MyGame.uproject" /Game/MyGame/Maps/MyMap -server -log -port=8003
Replace the paths and put this line in a server.bat and it will fire up a dedicated server on port 8003
(the port option is, well, optional)
"D:\Engines\UE_4.25\Engine\Binaries\Win64\UE4Editor.exe" "C:\MyGame\MyGame.uproject" -game 127.0.0.1:8003 -log -ResX=800 -ResY=600 -WINDOWED
And this line in a client.bat you can fire after the server started
you can of course use the editor interface but sometimes I find the .bat solution more straightforward and less buggy
your screen is too low res, what is in the Quit Game node?
default options. Quit and boolean disabled for Ignore Platform Restrictions
(I suppose you already found that thread but just in case: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/79760-dedicated-server-how-to-give-server-a-notice-when-shutdown-server)
So, while testing in editor, try with also EndMap
that thread does tell me that QuitGame should work, which is at least good to know ๐ but the actual solution it offers isn't useful in my situation ๐ฆ can't rely on a "proper shutdown"
I don't know if using the editor to launch a dedicated server means QuitGame won't work. I seem to remember that in PIE that's the case, you have to call EndMap or something like that.
But in packaged it should not make a difference
If you can go to C++, you could test this brute force:
#if WITH_EDITOR
GUnrealEd->EndPlayMap();
#else
FGenericPlatformMisc::RequestExit(false);
#endif
what end map? ๐ฎ
Well, it may be only available in C++
but just the RequestExit should be enough. It's not exposed to BP but it's easy to do
is your project BP only?
just use like UBlueprintFunctionLibrary exposing to BP the RequestExist
ok cool
Before that, you could also just put a DoOnce before your ApplicationQuit. Not sure the engine likes to be asked to quit each tick
so, it may be another reason the exit does not work (beside the fact that your OnLogout seems not to be called)
I've currently put that bit of code into a function, followed by "exit(0);"
compiling now and hoping lol
that should avoid that DoOnce issue as well I'm guessing?
don't know ๐
but we would need to be 100% sure the OnLogout is not fired on the dedicated. That's nearly impossible that it's not, the bug must be somewhere else
I would also try to disable all the calls to QuitGame in your code, and in the GameMode begin play, put a delay like 10 seconds and then call ExitGame. Just to be sure the node works / does not work, even without any player connected
I've got a launch date tomorrow, kinda don't wanna risk turning stuff off I don't need to ;p
but I'll give that second option a shot ๐
I meant just for testing, and isolating the problem ๐
because right now it's not very clear (at least from my pov) what's working and what's not
hahaha, yeah same sentiment exactly ;p
I'd be happy to give you TeamViewer control if you want to, but I'm also very happy with the help I'm getting just now
where did you get this variable from??
haha I'm also working in // so not very practical for me ๐ (and actually I have no other idea right now ๐ฎ )
yeah figured as much ๐ Just wanted to offer it just in case
but I'll give that second option a shot ๐
@thick jungle
Since you are a very very responsible project manager, that backups his work using source control, you can just not commit your changes :P
well, the exit(0) may be a bit dangerous (I don't know tbh) but if indeed this is called and does not do anything, that would be really surprising
@warped stream just stressed out man. My mental state of the code is too important right now. You're right though and that is a valid option that I was aware of ;p
hahaha thanks ๐
@glad wharf where did you get that GUnrealEd variable from? I know it's the editor, but don't know how to access it
(15 years of C++ experience.... 3 months of UE4 lol)
#if WITH_EDITOR
#include "Editor/UnrealEd/Classes/Editor/UnrealEdEngine.h"
#endif```
Sorry forgot
not sure it this one
if you want to be sure:
#include "Editor/UnrealEd/Classes/Editor/EditorEngine.h"
#include "Editor.h"
#include "Editor/UnrealEd/Public/UnrealEdGlobals.h"```
also, I just found that QuitGame is for players only apparently
so, if it's that, seems logical it does not work in dedicated
checking
thanks โค๏ธ
the includes are from an older version of Unreal, so they may be wrong :/
QuitGame actually executes a console command: quit/quit background/quit force
So indeed, RequestExist seems more sure
got a linker error on the GUnrealEd after I'd changed the includes to
#if WITH_EDITOR
#include "Editor/UnrealEd/Classes/Editor/EditorEngine.h"
#include "Editor.h"
#include "Editor/UnrealEd/Classes/Editor/UnrealEdEngine.h"
#include "Editor/UnrealEd/Public/UnrealEdGlobals.h"
#endif
but the exit(0); does work when I call it on boot ๐
unfortunately my code doesn't let me connect to the server while it's in editor for some reason ๐ฆ but I'm certainly a step closer now!!
mmm, you can remove the Editor part, it was just to be sure
you mean launching server.bat, waiting for it to be ready, and then launching client.bat won't work?
lemme try that ๐ Like I said, not used to UE4 at allllll
client one is just without the -server -log -port?
nope.. that boots up the editor hahah
Can anyone tell me when i should use RPC and when i should RepNotify?
"D:\Engines\UE_4.25\Engine\Binaries\Win64\UE4Editor.exe" "C:\MyGame\MyGame.uproject" -game 127.0.0.1:8003 -log -ResX=800 -ResY=600 -WINDOWED
And this line in a client.bat you can fire after the server startet
you need -game and your local IP
(with port)
@brittle tulip RPC are for fire and forget events from server to clients, and the only way for clients to send data to the server. RepNotify works only Server->client and is the way to go when you modify the state and want your clients to react to it
(for instance, imagine that a player "late joining" some time after a RPC has been fired, won't ever know the RPC has been fired, whereas they would receive the RepNotify)
@glad wharf you're being a hero <3
Almost there with booting it up... getting an error on the map
had the fake path (the one you gave) there first and that gave the same error. sec
I see, so for something like the depletion of player stamina whilst running i just use an RPC?
/Game/Maps/ExampleArenas/Arena_CR
Unreal has kind of a virtual file system with /Game pointing to your project content folder
โค๏ธ
๐
yeay!
thank freaking christ
haha no problem, glad I could help
you're a life safer man
if it's meant to run in prod though, I would test without the exit(0)
why?
well, the "proper multiplatform way" is through "FGenericPlatformMisc::RequestExit(bool)"
but well, if exit works...
however it's not good practice
yeah, I'll give that other one a shot. It shouldn't trigger the WITH_EDITOR through those .bats right?
mmm I think they would but actually I'm not sure
I mean, it's not PIE but it's still the editor exe
#if WITH_EDITOR
//GUnrealEd->EndPlayMap( );
exit( 0 );
#else
FGenericPlatformMisc::RequestExit( false );
#endif
giving this a shot just now
@brittle tulip that's a special case and I'm not sure. Because you don't want to flood the network with stamina update but at the same time it's kind of part of the state.
ok, then you can try to build the server and check locally (you mentioned having to push to SVN for that but I don't understand why)
@brittle tulip so maybe a mix of the two where you tell the client it's starting to loose stamina so it can simulate the loosing, and when the action is finished, the server updates the stamina variable to be sure it's in sync with client
the client is hard-wired to that IP address. If I'm running it through a packaged build, I am forced to connect to the C++ queue server that I built that then connects me to a game instance on the specified port
ah, there is no way to build a test client with another IP? For instance in development mode you can use the console and "open IP:port"
yes, when you package, you can choose between Debug/Development/Shipping
in development, you can toggle the console and run a lot of stuff
(on an AZERTY it's the ยฒ key, on qwerty I believe its ~)
yeah, so far we're forced to use Development mode since the Accessibility features for screen readers (we've supported play for the visually impaired) doesn't work on shipping build :(
which is reallllyyyy obnoxious.. but don't know how to resolve it lol
THANKS!
uh, strange, don't know anything about accessibility features in Unreal but indeed strange if they don't work in shipping builds
Explains how to enable 3rd party screen reader support for your project.
thx
it's not something you'd normally try and do ;p
took us 2 months of a single programmer to get implemented, on a game that happened to have a design that fit it perfectly
ok so it's not that built-in ^^
that feature is about 25 lines of code inside the UE4 engine itself :P
it literally just reads out the bit of text that is underneath your mouse...
oh, now I've got someone with experience on the other end anyway... have you ever had to have multiple game instances running?
what do you mean by multiple game instances running?
like, say you have games of 10 players max. And you've got 100 players all wanting to play at the same time
I see, thank you for the help, gave me a little more insight into how this multiplayer thing works lol. @glad wharf ๐
From what I know (but never dealt with that), you need one exe running per game, each one on its own port. Then you will have a matchmaking service wiring players to the correct server
right, then I did go for the right path ;p
ended up writing a custom matchmaking server lol
Unreal has a OnlineSubsystem interface, with implementations for Steam
(at least) and you can write your own
yeaaaah.......... it wasn't released at the point we started ;_;
it got released like 2 months ago or so
arf
in any case, their OnlineSubsystem interface seems to be cool, but not easy to grasp when you need to write your own. But the advantage is that then your game/application can support any online platform the engine already supports "natively" or through a vendor plugin
yeah.. it really does sound like a good system. It doesn't support cross-platform just yet, but I'm sure that'll come soon
(currently I do have cross-platform working ๐ just requires the RakNet plugin)
I'll probly use their OnlineSubsystem on my next game
it does not? I thought that was the point
you can override the Online Subystem used in the xxxPlatform.ini
from what I understand at least, I may be wrong
but they indeed started to change how multi-platform is handled one or two versions ago
I can't seem to find the launch page from that anymore, but I quite clearly remember that it got delayed by a year, launched bout 2 months ago, and was so bare-bone that it didn't have cross-platform
we might be talking about something different?
those online subsystems seem to be really quite useful though for stuff like friends list and achievements ๐ฎ
saved that link ๐
I don't know if we are talking about the same thing indeed ๐ I was talking about the switcheable nature of the Online Subsystems, so you can easily use Steam, or PSN... only by changing a line in an ini file or specifying it for each platform
yeah, it's actually really quite good! :D
I still need to get used to the fact that not everything needs to be custom-coded, lol
been working on a custom engine for 4 years which we've now switched over to server-side only and using UE4 for client-side
aaah that's why Raknet
yep ;)
I already had the code lying about anyway ^^
Just needed to get UE4 to work with it and I had a working connection to a working server ๐
but in this project you are using unreal for server right? because if not, none of the GameMode stuff etc would apply
I'm using RakNet to create a connection to that C++ queue server, which boots up game instances of Unreal servers and sends the port back to the client
the queue server expects the game to be shut down when it's done, and it goes wrong if it doesn't since there's no communication between the 2 servers
so yes ;p
ah ok I see
@thick jungle I manage to make the movement in a thread, limiting the time thus also the sending of the packages. It is still more fluid if done in Tick() but I have to limit the FPS to 90 in order for AddMovementInput() not to overflow the SavedMoves
thanks so much again for the help man ๐
I wouldn't risk it at 90 pal. If they'd get a higher latency than you do atm it'll still cause overflows
glad to hear the issue is resolved though ๐
Should I limit the FPS then?
It seems that both clients running on the Dedicated server run smooth with 90 fps. That is the max limit. Otherwise I could change the SavedMoves from 96 to a higher one. Everything replicated, cost about 80kb/s upload.
I am really open to other ideas ๐
I am glad you solved that @thick jungle
I'm not sure about your actual implementation ;)
But I'd say give the thing about 100ms delay and make sure it still works in that case.
Or better yet, record the ping and use that to modify the thread speed?
If it works with 90 for now, you might also just keep it at 90 until you're getting the error again
Be aware character movement already does a lot of work to stop that happening
CombineSavedMoves is what you should look at, that's supposed to prevent you outright overflowing the move buffer
I will try with some delay @thick jungle , But I have no Idea how to modify the thread speed. you mean the processors Thread speed?
@chrome bay . I use only AddMovementInput() which is run in Tick(). AddMovementInput() only adds a FVector based on the key W/S/A/D I pressed. For higher frames, it goes in overflow, with more than 96 SavedMoves. I tried to use AddMovementInput() inside a custom Timer, which is limited at 90 times / s
Also - you can make that move buffer bigger
Yes but the moves you do will be combined into one move up to a maximum delta time. So long as the input isn't changing every single frame, the moves will be combined and sent to the server in brief batches
I was thinking of making the move buffer bigger, but I need to figure how
FNetworkPredictionData_Client_Character
I know it is that one, but do not know how to add it to the CMC
You can either mod the engine to change the value, or you create your own child-class of CMC which creates your own child of FNetworkPredictionData_Client_Character for the network prediction data
but tbh - even at 90fps you shouldn't be running into that move buffer because the moves should be combining
Yeah well 400 FPS will definitely cause problems
when I do not limit the game's FPS, it happens
But nobody in their right mind is running a network game at 400 FPS
But I was thinking of capping it maybe at 144, in case someone would be able to achieve that
You'd be hammering the Server with packets
And vice-versa
There's a good chance it just won't be able to keep up
hence why I suggested sending movement packets once every 0.05 seconds (20 times per sec)
Character Movement already does that, that's what I'm saying
then how does it get flooded, ever?
UCharacterMovementComponent::GetPredictionData_Client_Character() is the function you need to override btw to change what prediction data is created.
Usually because people have customised character movement in such a way where moves can't be combined, so it breaks
Or the input can't be easily combined because it's variable
I.e. changing direction every frame, or input not being very binary etc.
like sending over a float instead of an int?
@thick jungle It is not getting flooded when I send the Movement inside a Timer, but it is not as fluid as using Tick()
It'll break if you send it via a timer
Have a look at UCharacterMovementComponent::ReplicateMoveToServer() and FSavedMove_Character::CanCombineWith
If you are failing to combine moves each frame, that's where the problem starts
Because then it has to send every frames move individually
@chrome bay I try combining when WS + AD are pressed, but AddMovementInput() is doing the rest.
It can't combine them into batches
Thanks a lot!! ๐ I will have a loot at those
TL;DR, you don't need to do anything manually
CMC has all the tools to do all this for you
All you need to do is hook AddMovementInput() up to the input bindings
And it just worksTM
But I would start by checking that moves are combining. 144 FPS is a very high rate for char movement to be running at
@chrome bay Thank you a lot! ๐ I will look at all those ๐
They should really implement a min tick time for CMC
So you can limit it to 60 FPS or something
You need to limit the FPS of the game XD
Or, make a timer
that also works
but not as fluid as with Tick()
Best way would be to add a delta time accumulator in UCharacterMovementComponent::TickComponent
Yeah well, char movement is very finicky about delta times
what I don't understand is why you call AddMovementInput() in Tick, I thought it was designed to be called in an input callback?
It is yeah
I tried to combine them, from WASD, and make a Nomalize() when they are combined
You don't need to
Plus it won't work anyway
AddMovementInput() adds all the input you give to it into an accumulator
that accumulator is then "consumed" by the character each frame and passed to movement
Moving at angles is already normalized by the movement component internally
You're normalizing is 100% what's breaking it most likely, thinking about it
Because those normalised inputs will be difficult to combine
@chrome bay , I tried with and without normalizing. It works the same, but smoother with Normalize, since a diagonal vector would be in size 0.07. Non-Normalized, would be 0.1
the input vector doesn't matter to char movement
Acceleration = ScaleInputAcceleration(ConstrainInputAcceleration(InputVector));
AnalogInputModifier = ComputeAnalogInputModifier();```
It already does what you're doing
also bear in mind the input "vector" to char movement isn't strictly a vector
at least it's not treated that way
It's a dumb naming convention unfortunately
I will keep that in mind ๐ Now I have "homework" to do. Thank you a lot guys!! ๐
Basically, UE already did all the hard work for you ๐
Just copy-pasta what they did in the sample projects and all should be good
@cursive mortar is that what they call it these days? ๐
@chrome bay I used some other tutorials for this XD maybe I should learn from their official templates.
@thick jungle or home-office-work :))
yeah be wary of third-party tutorials - especially multiplayer ones
80% of what I've seen is total nonsense
@glad wharf FIXED! ๐
awesome!
@chrome bay I added AddMovementInput() inside the Callback, but the movement is so jitterish ๐ฆ
hmm I guess it depends if you've added anything else there
I only have and If (!HasAuthority() && AxisValue != 0) { AddMovementInput(FVector(0.1f, 0.0f, 0.0f) * AxisValue, PlayerMovementSpeed);}
Are you moving with a gamepad or WASD?
WASD
Here's an excerpt from ShooterGame:
{
check(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AShooterCharacter::MoveForward);
}
void AShooterCharacter::MoveForward(float Val)
{
if (Controller && Val != 0.f)
{
// Limit pitch when walking or falling
const bool bLimitRotation = (GetCharacterMovement()->IsMovingOnGround() || GetCharacterMovement()->IsFalling());
const FRotator Rotation = bLimitRotation ? GetActorRotation() : Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Val);
}
}```
Shouldn't need the 0.1 vector btw
just pass "Val" straight in
Movement speed should be set in the character movement comp
MoveRight is even simpler:
{
if (Val != 0.f)
{
const FQuat Rotation = GetActorQuat();
const FVector Direction = FQuatRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
AddMovementInput(Direction, Val);
}
}
The "Val" is my "CharachterMovementSpeed"
Yeah that's where it's going wrong
You want the val to be the literal input from the binding
The movement speed and other params are determined by the movement component
Example:
{
float MaxSpeed = Super::GetMaxSpeed();
const AShooterCharacter* ShooterCharacterOwner = Cast<AShooterCharacter>(PawnOwner);
if (ShooterCharacterOwner)
{
if (ShooterCharacterOwner->IsTargeting())
{
MaxSpeed *= ShooterCharacterOwner->GetTargetingSpeedModifier();
}
if (ShooterCharacterOwner->IsRunning())
{
MaxSpeed *= ShooterCharacterOwner->GetRunningSpeedModifier();
}
}
return MaxSpeed;
}
The server and client need to be able to independently and deterministically determine the MaxSpeed at anytime for replaying moves etc.
Ok, ok. I get now what you mean ๐ I hope
Only with AddMovementInput(Direction, Val); it moves really really slow. But I will pass in the MaxWalkSpeed for this
ok, thanks a lot for the tip and help! ๐
Yeah you probably need to tweak the movement comps' params
np's. Not sure what tutorial you were following but don't do it again ๐
I did about 8-9 tutorials. And this with AddMovementInput() seemed the nicest to use. Other were using CharacterLocation and Making special list of SavedMoves and Intepolations to run on server.
I know, that's why I like this more XD Except these minor setbacks.
If i have a setter for a replicated property do i need to do it like this?
void UPlayerStatComponent::SetCurrentStamina(float StaminaValue)
{
if (GetOwnerRole() == ROLE_Authority)
{
CurrentStamina = FMath::Clamp(StaminaValue, 0.f, MaxStamina);
FString staminaMessage = FString::Printf(TEXT("%s - Current Stamina: %f"), *GetOwner()->GetFName().ToString(), CurrentStamina);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, staminaMessage);
}
}```
Looks okay yeah
sorry im just trying to get my head around this replication stuff, somehow it is boggling my mind lol
What i don't understand is that if i took the ROLE_Authority part out it seems to work fine
Well the important thing is that function as-is will only do anything if you call it on the Server.
(Assuming the owning actor was spawned by the Server, that is)
okay thank you
Hello! I'm trying to have an ACharacter movement being completely controlled on the server - that works well for everyone but the owning player (third person; character won't rotate and movement stutters). I suspect that the client tries to use the local movement data to interpolate, but causing these effects due to no local movement happening. Any hints on where to look would be highly appreciated!
My advice would be not possessing the character
The Character systems is specifically designed so that the owning player can move it without latency.
thanks - I've considered that as a work-around (not tried it yet, though), but this might cause me issues with other parts that I do want to be locally controlled (e.g. rotation while not moving)
btw, as that character is currently the default pawn, is there a typical way to still spawn it, but prevent it from being possessed automatically?
i need urgent help with the following error: NotifyAcceptingConnection: Server (levelname) refused - it occurs randomly and causes PostLogin to fire, attempting to do Steam authentication all over again, and no matter what i try i can't make it acknowledge that the player was already authed, like all variables are getting reset. can anyone suggest a good way to see if the player is authenticated via Steam?
@jfaw while you still want the server to handle the actual moves, you can turn on client-side navmesh generation in your project settings and use it for client side pre-checks
Hey, i have a problem i just setup a way for players to sprint which changes the players speed, this works, and on another client the player looks as though he is running. However, on the client running the animation seems to stutter. Anyone know why this could be happening?
@brittle tulip looks like this might be exactly the same issue I'm having (and didn't solve yet)
@void pasture I just fixed it by doing setting the MaxWalkSpeed on the client side
it might because the replication of the flag that sets the max speed, and the replication of the movement using the max speed, are out of sync conversation about that above
What do you mean - replication of the flag?
also is there any way to sync them up?
@brittle tulip sounds like it's not the same issue than (although somehow related) - so won't help me ๐ฆ but thx!
Ah sorry about that
Is it actually okay to do something like this or is it going to bring up problems later?
void UPlayerStatComponent::SetMaxWalkSpeed(class UCharacterMovementComponent* CharacterMovementComponent, EMovementSpeed MovementSpeed)
{
if (GetOwnerRole() < ROLE_Authority)
{
CharacterMovementComponent->MaxWalkSpeed = GetMovementSpeedByEnum(MovementSpeed);
ServerSetMaxWalkSpeed(CharacterMovementComponent, MovementSpeed);
}
else if (GetOwnerRole() == ROLE_Authority)
{
CharacterMovementComponent->MaxWalkSpeed = GetMovementSpeedByEnum(MovementSpeed);
}
}```
hey, does anyone know how I can persist a USTRUCT owned by the GameState when seamless traveling?
Can you move it to a third party actor that can be duplicated similar to playerstates?
GameState is kept with seamless travel isn't it?
Override void AGameModeBase::PostSeamlessTravel() and handle it there
so you mean that this struct should be already kept as is?
because it does not seem so ๐ค
@mystic pilot I suppose I could, I thought being in GameState was already a good thing but maybe not
The GameState will be kept for seamless travel, then destroyed afterwards
But you can write your own functionality to propagate it to the new gamestate
aaah ok I see, will check that, thanks!
Check out AGameModeBase::GetSeamlessTravelActorList()
^ that.
(by default gamestate is included)
well I tried to override it but just adding the GameState seems to crash the game (or the crash comes from somewhere else, don't know with this 4.25 + Oculus Quest nightmare x) )
ah, I missed that
but if it's included, why the need to propagate?
Because the original actor will be destroyed
Seamless travel doesn't technically keep the old actor, it just brings it along, then destroys/replaces it in the new world.
ah, without copying it's old values
Yeah, PlayerStates have some built-in functionality for doing it, but nothing else AFAIK
ok, that's not very clear in the doc! Thanks a lot you saved me a lot of troubles ๐
np's. Actually a bit surprised the game state doesn't also have that functionality, would be useful
PlayerState seems to have void APlayerState::SeamlessTravelTo(APlayerState* NewPlayerState)
It mentions various things in World.h
* GameModeBase::PostSeamlessTravel(), and/or GameModeBase::HandleSeamlessTravelPlayer() to handle preserving any information
* that should be maintained (player teams, etc)
* This codepath is designed for worlds that use little or no level streaming and GameModes where the game state
* is reset/reloaded when transitioning. (like UT)
Funny it mentions UT there... as last I checked, it didn't use seamless travel.
probably an ancient comment ๐
thanks! so the Gamestate is meant to be reset, I will override GameModeBase::PostSeamlessTravel and try to see if I can grab the old one and the new one to do some copy/paste
๐
mmm, it seems to be the responsibility of UWorld::CopyGameState ๐ค
Hmm... just when I thought I was doing alright with SteamSockets and such, it starts up again.
sigh
in fact PostSeamlessTravel seems to be too late, and the UWorld methods are not virtual so I can't override them, so it seems that...I'm screwed xD
Make a new actor then.
Make sure to include it in the GameModeBase::GetSeamlessTravelActorList().
the thing that puzzled me is that I see how the PlayerController get back its saved actor list (in HandleSeamlessTravelPlayer), but for the GameMode I don't see where
Oh.. hahah yeah that's pretty annoying
oh maybe I just need to get the game state, and it will be the old one...
I wonder if you can override AGameStateBase::PostInitializeComponents() and copy the properties there before it calls SetGameState();
Certainly don't make it easy...
the thing is, the GameState is set through UWorld, not the GameMode
through CopyGameState
It looks like they set it in a few places
World->SetGameState() is called all over the place by the looks of it
in SeamlessTravelHandler::Tick it does CopyGameState which calls SetGameState yes
but as @mystic pilot suggest, I could just use another Actor, but I don't know how to get it back
Yeah I see calls in AGameModeBase::PreInitializeComponents() and GameStateBase::PostInitializeComponents() too
If in doubt, dump it in the game instance
then copy back
or I just take the first player controller and use its own mechanism to get it back mmm
ah yes indeed should work
So long as that player isn't lost during travel ๐
it's a struct with a TArray, just copying the struct pointer should work shouldn't it?
haha yes indeed
would have to copy the data itself
pointer would become stale once the game state is GC'd
(Y)
TheActor->bActorSeamlessTraveled = true;
So I guess push comes to shove, get all the actors of such and such a class and look for that value.
something like for (TActorIterator<MyActorClassWIthTheSavedStruct>) { It->GetTheData(); and then actually copying the data to the game state
well, with just a check for bActorSeamlessTraveled before
well, actually the GameMode seems to persist and not being destroyed/respawned, so that may be the easiest solution
Yeah that's fine so long as you aren't changing to a different gamemode IIRC
Hi! Noob question about sessions, how do i change/load a map taking all of my players? I created a session and players were able to join to a "Menu level", now I want to load the "Match level" and take all the players on the session to that level. How do I do this?
I've seen something about executing console commands but im not sure if this is still done like this as the most recent answers are form 2015
ServerTravel
and the easiest way to do this in BP AFAIK is "Execute console command" with ServerTravel MapName as argument
Okay its what i saw, just wanted to be sure that that was still the correct way
Thanks!
just to be sure, it's impossible to test server travel in editor? You have to package right?
yes
thanks ๐
Did anyone have issues with Oculus online subsystem with UE 4.24.3?
Find session always return On fail
I think 4.25 is my worst nightmare, never had so much crashes so often everyday. last mystical crash: a ProcessEvent wrongfully called on a PrecomputedVisibilityVolume instead of the Pawn after a ServerTravel ๐ฑ (well, the event should not have even fired in the first place)
Not sure, possibly not a replicated actor?
Or no valid network connection at the time you call it etc
If it's something like an actor placed in the world, I'm pretty certain it won't have a network GUID until it's actually referenced at least once via the network.
It is spawned by the GameMode
I.e. pre-placed objects will resolve via their full path name until it later acks a net guid
Right, and it's a replicated actor?
yes
ok
Thing is, GUID's are unique for each connection - so since the server has no connection to itself, if you call that function server-side I can sort of see why that would be the case.
Can anyone help me, on the right hand side when the player sprints the character glitches out hoever on the other players screen it does not. Anyone know how to fix this?
(sorry for low quality)
this is better
@brittle tulip Judging by the fact that it seems to go away when the character slows, my first guess would be that you're setting a movement speed somewhere for like a sprint effect, but you're somehow not setting it correctly for both client and server.
@chrome bay is it maybe because i'm in the editor
void UPlayerStatComponent::SetMaxWalkSpeed(class UCharacterMovementComponent* CharacterMovementComponent, EMovementSpeed MovementSpeed)
{
if (GetOwnerRole() < ROLE_Authority)
{
ServerSetMaxWalkSpeed(CharacterMovementComponent, MovementSpeed);
}
else if (GetOwnerRole() == ROLE_Authority)
{
CharacterMovementComponent->MaxWalkSpeed = GetMovementSpeedByEnum(MovementSpeed);
}
}
bool UPlayerStatComponent::ServerSetMaxWalkSpeed_Validate(UCharacterMovementComponent* CharacterMovementComponent, EMovementSpeed MovementSpeed)
{
return true;
}
void UPlayerStatComponent::ServerSetMaxWalkSpeed_Implementation(UCharacterMovementComponent* CharacterMovementComponent, EMovementSpeed MovementSpeed)
{
if (GetOwnerRole() == ROLE_Authority)
{
CharacterMovementComponent->MaxWalkSpeed = GetMovementSpeedByEnum(MovementSpeed);
}
}
this is how im setting it
I'm not familiar enough with C++ to comment on it. I'm used to doing stuff like this in Blueprints. All I do for that is have a bool that is replicated to all, on button press or release, make an RPC to server with a bool input. Use that input to change the replicated bool on the server. On Repnotify set the player's movement speed to normal or sprint based on the bool. In C++ you'd also have to call the same function for the repnotify manually on the server. But basically your server version and all client versions need to have their movement speed set at the same time. If one is moving at different speeds it'll cause that sort of jittering.
@polar lotus wouldn't think so, most of the underlying networking is the same
The problem is that your sending in object via the RPC.
Make it simpler, it'll be faster.
oh okay
@brittle tulip override this in your own custom movement component instead:
UFUNCTION(BlueprintCallable, Category="Components|Movement")
virtual float GetMaxSpeed() const;
e.g.
{
switch(MovementMode)
{
case MOVE_Walking:
if (IsProne())
{
return WantsToRun() ? MaxRunSpeedProne : MaxWalkSpeedProne;
}
else if (WantsToLean())
{
return GetMaxWalkingSpeed();
}
else if (WantsToSprint() && !PauseSprinting() && (FMath::Abs(GetMovementDirection()) < 85.0f))
{
return IsCrouching() ? MaxSprintSpeedCrouched : MaxSprintSpeed;
}```
are you saying to do that in my UPlayerStatComponent or make another component derived from the CharacterMovementComponent
Another component derived from the CharacterMovementComponent.
Hello again, I am testing the Create Session / Join Session workflow in a build, I'm using steam subsystem for this (I don't know if this is relevant) and I have a bug on which players who join cant control their character, I think that its the controller that doesn't auto-posses the character it creates when joining the session but I'm not sure, does anybody now what may be causing this and how to fix it?
Thank you @mystic pilot
Are there any good examples of how to implement networking for components?
I understand how to set it up, but I'm more asking for "practical" examples of it being used
just trying to get a feel for how I should design things
WTH!?! Code that is behind an "Is Dedicated Server" branch check is executed on P1 client-side?????
has anyone else experienced issues with seamless travel? Iโve had things like player meshes not loading, cameras not properly respecting spring arm length, and even client-side crashes at times
Hey everyone. In my UE4.24.3 I have set number of players to 2 and I moved PlayerNetworkStart to be next to the 'original' player. However, when I start the game, I can't see the other player on any 'client'. What might be causing it?
However, it just is rendering - physics (collision) works fine.
Nvm, fixed the problem. ๐
@polar lotus hijacking an earlier conversation, but are you having issues with an actor not spawning because an asset's network GUID is invalid?
we had that, got worse in 4.23+
this would randomly happen after a seamless travel, seemingly affecting the same actors each time
@unique jungle Plenty over the years.
Been using a fix for the following issue for years that helped until UE4.23, where I started getting different issues (NetGUID related).
Switched to non-seamless travel for a bit.
Recently sat down in another attempt to fix the issues and what do you know, there were small changes to the fix along with a single addition.
That single addition seems to have sorted out the issue UE4.23 added.
We are currently using UE4.25.1 with this PR mentioned in this issue and seamless travel seems "fine" thus far.
I only say "fine" because I am paranoid it'll break when its goes out to the wild :(
https://issues.unrealengine.com/issue/UE-24280
@lost inlet See above
The minor change in question:
If you want this fix, you will need to manually patch it into a source build version of the engine, as it is not due to be included until UE4.26.
Jesus really. That would actually explain an issue im having as well with missing meshes...
that's not what we were suggested: https://udn.unrealengine.com/questions/581912/view.html
for non-UDN, this was resetting the Ack'd GUIDs in UNetDriver::CleanPackageMaps
which involves resetting AckState on each connection's PackageMapClient
our issue was: client seamless travels, server doesn't send GUIDs because they haven't timed out yet, a gameplay critical actor doesn't spawn because it's waiting for the GUID for an asset
actors not replicating in a sublevel was another issue we had a long time ago and managed to fix
https://udn.unrealengine.com/questions/488539/view.html if you have UDN access, this is the issue we ran into in 4.21. in the end it looked like your fix
Seems I may need udn access then ๐
(If just to read suggestions)
are you having issues with an actor not spawning because an asset's network GUID is invalid?
@lost inlet What was the error message/warning?
Warning: UActorChannel::ReceivedBunch: Received a MustBeMappedGUID that is not registered.
Damn, not the same as the one we were getting.
Thought we might have some common ground ๐
UPackageMapClient::SerializeNewActor Unable to read Archetype for NetGUID bla / bla
After seamless travel only though.
Non-seamless, all good.
the actors not replicating on a sublevel was fixed in 4.25, no?
the issue where the level visibility for clients is wrong
4.26 going by this:
If we're talking about the same issue/fix:
https://issues.unrealengine.com/issue/UE-24280
never saw the above error
Apologies - don't mean to be spamming that one link.
In our case, the assets would load, but not be synced between server/client.
Oh, the UPackageMapClient::SerializeNewActor() warning? Only started happening in ... 4.22/23??
For us anyway.
i had that when the actors were allowed to replicate before world's beginplay, while spawning
procedurally generated map
after we noticed it affects only actors near player starts, we overrode IsNetRelevantFor to return false if the server is still spawning prefabs
after that didn't have a single incident
we do spawn the entire level separately on clients/server, with same names, and lie to the engine so it treats those actors as loaded from package
note: the actors that weren't replicating were still net addressable just fine, you could loot a broken locker and get the loot, just not get any feedback on the locker that you did
in our case, the asset IS loaded, it's not getting the GUID. so the "fix" was the just reset the acknowledged GUID list when doing a travel
reset the acknowledged GUID list
Guess that is what non-seamless travel does by default?
non seamless is hard travel, server is basically seeing the clients for the first time, as far as it knows
Yeah, I kinda phrased that wrong.
non seamless basically kicks all the clients
While seamless maintains the same connection and carries them and other actors with it.
how normal is it for clients to get randomly disconnected during seamless travel causing logout and login events to be fired again?
Ok so
I have a super weird issue with my TPS
When my player aims, he puts the gun up to his face
But, if a client aims, the other clients only see the world location change if they can see the player (if it is rendered)
There should be some settings on the MeshComponent to tick while out of view or so
Ok that seemed to fix it
I never knew about that setting
is there a way to just update the pose once when my player aims so that the server processes the weapon shot properly
there is a way to manually tick the pose, but it'd probably be tricky to get correct since you'd need to know how many frames to do it for and track all that
the whole problem is only when I shoot
@mystic pilot thanks for the response! I guess Iโll stick to non-seamless for now, travels arenโt happening often anyway
@unique jungle hard travel doesn't do too well with steam sockets, if thats a consideration
if you have a lobby + game level
Ah ok thanks for the info. That probably wonโt be relevant for this project but who knows, definitely something to keep in consideration
first connect to the server is always hard travel
after that, if server changes map you have a choice between seamless and hard
Hello guys i have a problem with my find sessions advanced, when i am looking for online session it also displays LAN sessions why ? (please @)
I made this video to learn how to use PhotonCloud plugin to add online multiplayer to the 3rd Person Template coming in Unreal 4.25 https://www.youtube.com/watch?v=7oHQl0lxeH8
A briefly intro of howto add online to a thirdperson template with the integration of character replication, translation, rotation, and animation blueprint.
Plugin:
https://www.unrealengine.com/marketplace/en-US/product/76bee07c672c4dbba14df190d82f7f33
Source code of the tem...
Hey ive just tried to add the function in and use it but im now getting some stuttering? any reason why?
float UMOWCharacterMovementComponent::GetMaxSpeed() const
{
switch (MovementMode)
{
case MOVE_Walking:
return WantsToSprint() ? MaxSprintSpeed : MaxWalkingSpeed;
default:
return WantsToSprint() ? MaxSprintSpeed : MaxWalkingSpeed;
}
}```
This is where im using it:
```cpp
void AMOWPlayerCharacter::StartSprint()
{
GetMOWMovementComponent()->bWantsToSprint = true;
GetMOWMovementComponent()->SetMaxWalkSpeed(GetMOWMovementComponent()->GetMaxSpeed());
}
void AMOWPlayerCharacter::EndSprint()
{
GetMOWMovementComponent()->bWantsToSprint = false;
GetMOWMovementComponent()->SetMaxWalkSpeed(GetMOWMovementComponent()->GetMaxSpeed());
}```
When i was just using `GetMOWMovementComponent()->SetMaxWalkSpeed(300.f);` this was working fine
you need to set the walk speed on client and server, also you should send sprint through the saved moves
Like how im doing with this?
i mean the only thing i can see that would cause it, would be client/server having wrong MaxSprintSpeed/MaxWalkingSpeed
I have the set max walk speed like that too
WantsToSprint should be sent in saved moves
{
if (!CharacterOwner)
{
return;
}
Super::UpdateFromCompressedFlags(Flags);
bWantsToSprint = ((Flags & FSavedMove_Character::FLAG_Custom_0) != 0);
}```
like this
Hi, if I change some replicated varaibles in BeginPlay are they replicated to the client ? or does this change is not taken into account because the replication process is not yet started?
Hi @sweet flint as far as I know if the client hasn't initialized yet (the server initializes first) and you do things in server they don't get replicated to client because the client is technically not there yet
So you have to either do the changes in server a bit later (with a delay or something) which is the bad way of doing it because you cant know for sure how much time it will take the client to load or you can send an RPC from the client saying when they are ready and then when the server receives it it sends the data/changes to the client
For me begin play is called on both side so I can load static data without involving network.
I was just worrying to see my static data replicated for nothing as they will be loaded on the client side also ๐
If you have data created in begin play on server and client and that data is replicated the server will try to replicate and if the client is ready it will "replicate for nothing" in a sense because the server doesn't know if the data is being initialized on client. Anyway, if you are initializing the data on begin play and it doesn't change anywhere else and it is static as you say I think you dont need to replicate that data
And well, changing of topic, I have a question myself channel:
The problem:
I have made a game using sessions with steam subsystem, right now I have a really simple menu with 2 buttons "HOST" and "JOIN". "HOST" creates a session and opens a level with listen as option and "JOIN" joins the first session it finds.
The player who hosts can host perfectly fine, the level opens and they can move around but the players who join can't move, they can see the host moving but they can't move, attack or do anything that requires any input.
What I have tried:
I read that some people had this issue because they were using GameModeBase instead of GameMode and I actually was doing that so I changed my custom game mode class parent to GameMode from GamemodeBase but nothing.
I thought that maybe the player controller was not possesing the player correctly but I print the controlled pawn on the controller and it actually prints it.
So any idea of why joining clients can't control their pawn?
Thanks in advance ๐
Edit: Formatting
IOnlineEvents - Interface class for events
How is this used?
I have tried to search from the shootergame project and scoured the internet but I can't find how it works
there's nothing that uses these strings
where does that code come from @vagrant fjord ?
shooter game
why cant i find any steam sessions for my game?
im using 2 pcs on the same network, i can host and join in editor and standalone
only in the packaged game i cannot find any sessions
hi freinds! about dedicated game server.. for my multiplayer android game project i need build the server with win64 option or with android options? i talk about the server side and not the client side...thank you
does the OSS you use even implement IOnlineEvents?
it looks like only xbox live has this implemented in UE4, unless you have a custom OSS that implements this interface but by that point you should know what it does
What do I set as the owner for an enemy actor spawned using SpawnActorDeferred ? I have to set an Owner and Instigator for an enemy spawned on the server.
Do I just leave them as null or can I set the server as the owner of the enemy?
an owner or instigator is not necessary for a replicated actor to spawn
the only time you'll really need it in a networked context is if you have client RPCs you want to call on that actor
You can leave them null I guess. You could set the Owner or Instigator to the Spawner/Manager that spawns them if you have one.
But ultimately, it's not so important if you spawn a Server Owned AI.
At least in "most" cases.
ok thanks. they are being spawned by a function in my GameMode class
why doesnt my game open up 7777 port when i host a session / run listen server?
its clearly forwarded on my end
[2020.06.27-22.27.25:483][515]LogNet: Created socket for bind address: 0.0.0.0 on port 7777
does this seem ok?
[2020.06.27-22.27.25:483][515]LogNet: GameNetDriver IpNetDriver_2147481850 IpNetDriver listening on port 7778
neither 7777 or 7778 are open during session
why doesnt it open the ports?
How would I go about handling different game modes (deathmatch, team deathmatch, ect.)
there's probably a million ways of doing that lol
if you have a separate GameMode classes, when you load a map you can override a gamemode by setting ?Game=/Path/To/Gamemode on the travel URL
our game uses a scenario system which allows you to enable certain sublevels depending on the game mode
@thin stratus Thanks for your comments and compendium on the 2018 UE4 multiplayer blueprint comments; I had to refactor that entire project and I am taking into account all your inputs. Thanks again, you're a life save
@shrewd tinselIt isn't designed to open the ports for you - just listen to them.
The ports have to opened elsewhere.
@jovial stream In addition to that, you can also setup GameMode ShortCodes in your Project Settings under Maps and Modes. So you can basically link the shortcode "DM" to the gamemode asset and just do "?game=DM".
Can't remember what the exact setting was called but it's somewhere in maps and modes.
Makes it a lot easier to work with
@mystic pilot if i make a listen server, shouldnt the port open so i can find it?
i made a http server on 7777 port, that opened the port
Was that via SteamSockets/SteamNet?
My bad, you mentioned as much above.
No expert when it comes to what a router will/won't allow through.
Could be as simple as being ok with what ever traffic HTTP likes, but not what the server does.
๐คทโโ๏ธ
aight
any way to check?
where its being blocked?
if i use steam online subsystem do i have to launch game through steam? do i need to forward ports that way?
While using the Steam sub system with a listen server with Steam running, you're all good.
As a dedicated server, no, need ports opened.
can someone plssss explain why my function is getting CALLED but NOT TRIGGERED?
what bp is that in?
cause you cant call Server RPC's from a non owning actor
if that actor is something in the level, then it would never work
it has to be owned by an actor with a player controller.
Can someone help me: I have a strange issue and need a tip to avoid it. how to spawn two Character in one world at the same location. I use Spawn actor from class an gave them the same location, but they spawn in different locations
make sure they don't collide with each other
they donยดt
Also I want to spawn them on different player starts: I have one with the tag 1 and one with tag 2. If I now want to let spawn all at start 1 the client just spawns at start 2 most time. I gave the spawn a bit randomnis so they should spawn on a bit different location, but nothing helps
Is there a way to send "diffs" to a client instead of replicating an entire variable
or does that mostly need to be done through RPCs
depends how much effort you are planning to invest here
probably not a lot, I'll probably end up just not caring because the size of the replication will only be somewhere around 1kb for something that wont change that often
just wondering if there is a somewhat simple way to do diff-ing
I found this https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/FNetFastTArrayBaseState/index.html earlier
===================== NetSerialize and NetDeltaSerialize customization.
@fleet viper yo what are those red things?
@shrewd tinsel breakpoints
@meager spade it's a normal replicated actor, but it's owned by a player controller
then it should work as long as it is owned
when is spawn ship event excencuted?
BeginPlay is too early btw
@meager spade what is the best way to do multiplayer? online subsystems? custom solution? amazon?
do u use advanced steam sessions?
no
listen servers?
port forwarding requried?
no we use steams nat punch through
4.24+ has a steam subsystem that works
no all c++
but you use unreals create session?
i didn't originally
i used UWorks
but ended up changing it a week ago to use the UE4 session system
gotcha
still use UWorks for most of the steam stuff tho
as its handy and has nice BP exposed stuff
in my end i cant find any sessions in packaged game, not sure whats the issue
listen server?
i have a suspicion thats the issue for me
cuz checked everything, but still no sessions found in packaged
its $99 for a app id right?
yea
im still waiting my first 99 to pay off
i tried opening ports and creating session through epics online subsystem, but port checkers say port is closed when the server is running
do you know if it should be open for a listen server?
its 7777 normally
yeah
made that sure bunch of times
also sessions should come through
without portforwarding
when you create a steam lobby
i know
that is searchable
when you join it, you join using the steam.OwnersSteamID command
if it does show up in standalone, means im doing it right, right?
why would that be?
automatic failsave mechanism or something>?
cuz im definately checked lan false
Fax, you have steam open when testing packaged yes?
Hello, could you please help me with a validation question I have?
Can I somehow react to server validation returning false on client side?
Hi trying to make a chat system, following this tutorial series https://www.youtube.com/watch?v=08q0vJ7GzDA&list=PLnHeglBaPYu_aUsm78py_O_OENKhdCGZS&index=60
Though I am getting an error trying to compile it, and I do not understand much of it unfortunately.
https://pastebin.com/ujs39945 ChatComp.h
https://pastebin.com/ReVv9DML ChatComp.cpp
Sorry for taking up so much space - any help will be appreciated.
In this video we create our chat component class along with some basic functions that we will use for our chat system.
@twin juniper What does the compiler say?
I think you have to mark the parameters const in your cpp file as well
you have
bool Server_SendMessage_Validate(const FString& Message); in your h file
but
bool UChatComp::Server_SendMessage_Validate(FString& Message) in your cpp file
and I think it should be
bool UChatComp::Server_SendMessage_Validate(const FString& Message) in your cpp file
Yes true
thanks
now it tells me
Severity Code Description Project File Line Suppression State
Error C4717 'UChatComp::Server_SendMessage': recursive on all control paths, function will cause runtime stack overflow chattest C:\Users\malth\Desktop\chattest\chattest\Source\chattest\Private\Components\ChatComp.cpp 29
Guess it's in a loop
Is your current implementation of that function in that pastebin above?
No sorry
void UChatComp::Server_SendMessage(const FString& Message)
{
Server_SendMessage(Message);
}
In ChatComp.cpp
Well, you can't have that, because now the function calls itself. + You should not even have this implementation in you cpp file.
you can delete this whole method
and keep only _validation and _implementation in your cpp file
in your header file you have to keep all 3 of them
np, you are welcome
WithValidation is not required anymore
if you are just going to return true
void Server_SendMessage(const FString& Message);``` is all you need in the header
in cpp, you have void AMyClass::Server_SendMessage_Implementation(const FString& Message) { //Do Something here }
Hey guys, a question regarding network relevancy. Is there a way to set actor component to be always relevant, regardless of parent actor relevancy?
nope
All components replicate through the actor function ReplicateSubobjects
On clients, when the actor is out of relevancy its destroyed
meaning there is no components on it
as there is no actor.
Destroyed?
yes destroyed
Wow
I was thinking that when actor goes out of relevancy, it just stops receiving updates
no its destroyed on clients
if you want to stop it from recieving updates
set it Dormant
this won't destroy it client side
but it won't recieve updates.
So, make it always relevant, but go dormant?
yes
Gotcha, thanks a lot
if you want to send a single update
and go dormant again after, use FlushNetDormancy
ForceNetUpdate
FlushNetDormancy calls ForceNetUpdate aswell
Oh
AActor::FlushNetDormancyForces dormant actor to replicate but doesn't change NetDormancy state (i.e., they will go dormant again if left dormant)
np
And I guess there is no way to do that in blueprints, right?
By default
Unless I expose it
Not that I should do that anyways, managing network relevancy in Blueprints is kinda bad idea anyways, lol
Oh, didn't see that
Ok, big thanks
Does the host have access to everyone's HUD?
no
yeah i put a function to show the loading screen in the HUD, but realized i can't tell the player's to call it because i can't get to their hud
so gotta move it out
WithValidation is not required anymore
@meager spade
Thank you - did not know that ๐
you can client RPC to ask client to show it
client RPC?
Hey, Guys what are the best Hosting services that i can use to use as a server ?
Hey, when using advanced sessions plugin, do i have to port forward?
if so what port? and is there anyway to negate having to port forward for each person wanting to host?
@clear copper "remote procedure call" he just basically said Client tells himself to add it.
Hmm ill look it up
@meager spade here is what my testing brought so far..hope you can see whats triggered and what not. Now my question, is something wrong on my end or is that actually an issue in unreal?
ohh shoot
yeah right
wait but if i have to set the owner on all (multicast) how do i do that? because i can only replicate things if the owner is set
when you spawn the actor
you set the owner
on the server
why not just move that server rpc to the player controller
and call that function pass in the ReplicationActor
and job done
problem is that the actor was already dropped in the level
i figured it out now, but the problem is that the actor should spawn another actor and im now thinking of moving the spawn part in the player controller who ordered it
but that would allow cheating
Is there a way to update a variable based on change in another variable?
Anyone Familier with replicating could help me with a issue with a ladder. DM me if at all possible. Thanks.
@chrome bay is this your work? https://www.unrealengine.com/marketplace/sparse-grid-plugin
I am confused here. I'm just trying to figure out which one is the server and which one is the client by printing the role of the locally controlled character on the screen. I expect one window to be the server and show "Role: ROLE_Authority" and the other window to be on client and show "Role: ROLE_AutonomousProxy". Instead both of these lines print to the same window.
Also why do both windows show [NetMode: Server] on the top bar? Should one be NetMode: Client? Is this related? In the editor options I selected "play as listen server".
Yeah that's mine @lavish cypress
I'm running into a issue with a ladder.. Serversgoes up fine, client however does not.. and im not sure why?
@glad lintel If you're on 4.25, the windows names are broken. Someone submitted a PR but it hasn't been taken yet IIRC
I assume you were able to use the Sparse Grid plugin on HLL as well, right? Did you create any other tech to make that project happen? Do you write about major engineering problems you solved for the project anywhere?
We're not using it on HLL no, and I haven't done any writing for HLL
Were your requirements simpler than what the plugin offers?
We just don't need it. It solves a very specific problem
If you need objects querying the position of lots of other objects often, that's what it's for
I see, thanks
@twilit patrol That looks like an issue completely specific to your game. Best guess is that you are receiving corrections from the Server which are snapping you to the floor because the ladder movement has not been built into the C++ prediction side of character movement.
Explains the jitter, especially in editor where you are probably getting corrections / network info at a high rate. In packaged/real-world connection it'll probably look like constant rubber banding.
The Server probably works because it can do whatever it wants with it's pawn.
well, ive ended up fixing the jitter.. to where the client can go up.. but now the server, doesnt actually see him go up on the screen. and it's starts to do this crazy desync.
Ah so the window names are just bugged. Any reason why the server is getting both debug messages when I am only printing it for IsLocallyControlled()?
it's something to with replication i assume, and im not that good on replication stuff yet i guess lol
Yeah, as Jambax said, it sounds like whatever code is moving the client up the ladder is not being run on the server.
So I'm wanting to transition my listen server based game to use a dedicated server. This is with a 4.25 project. Is there a recent guide out there than this one? https://www.ue4community.wiki/Legacy/Dedicated_Server_Guide_(Windows_%26_Linux)#Section_1_Building_a_dedicated_server_in_Unreal_Engine_4
but this documentation is from 4.14
hoping to find something a little more recent
I will probably also need to learn to cross compile for linux as I want to use it on AWS. If anyone has any tips, would be much appreciated.
Got a quick question; if I'm holding a player controller as an object; when the player leaves this object becomes invalid (i.e. "is valid" test can be done?)
The controller will be destroyed, so yeah
Thanks
Hello everyone,
Cooldown timers for example, should those be run and processed by the Server?
depends on how much security you want... a client can technically just bypass it if it's local
on the other hand, if cheating's not gonna be a problem at all then you can save yourself a bit of work by doing it local only
To answer my own question, I found this which looks like a pretty good recent guide: https://medium.com/swlh/building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker-75317780c567
How easy is it to cheat? for the average person
for the average person it usually amounts to visiting some website to download a hack created by someone not average
I see
For an arcade game that is meant to generally be played with friends. I think for now I will have a moderate/high amount of security in mind.
Setting up a timer on server isn't hard so I'll go with that for the time being
Even though it might be annoying for UI
to track that timer
well, you can always keep two timers, one local and one on authority
the client one just for visuals
True
doesnt have to be an actual timer either mind you, it could just be something like MinimumWorldTimeNextExecution that you set when you fire this thing whatever it is
Anyone know how to make an installed build of custom engine that will work for building dedicated server targets? My "rocket" or installed build is giving me this error: UnrealBuildTool : error : Server targets are not currently supported from this engine distribution.
Thanks raap
Is the PlayerID inside the PlayerState a reliable value to identify client proxies on server RPCs?
yes
hi anyone here good with steamnetworking?
im getting this and not sure whats the problem
Any simple ideas on making a rank systems and gold system for buying items ?? For ranks I'm thinking of using the epic leaderboard but not too sure for gold. If I save players gold amount locally can they change it and cheat ??
This gold will be used to buy skins and will be the main income for my game so it's very important that people cannot some how change this
If any stat manipulation is done client-side then yes they can cheat
Only way to ensure they can't is have a dedicated server managing it.
nope
Also worth pointing out that if someone knows the App ID for your game, and their Steam ID, there's nothing stopping them writing whatever values they want to leaderboards with the Steam SDK
They don't even need to be in game.
fuck
Any code running on a players' machine is subject to cheating/hacking
Steam has one method of securely uploading stats which is it's "Official Server Stats" system, where you give it a bunch of IP addresses and it will only accept values changes to those stats from those IP's
i mean still cant think of how that would help
In our case we whitelisted the subnets of our server provider
With listen servers it won't help, it'll only help with dedicated servers where you know that the players don't have access to it.
I wish steam used a certificate system instead at the very least, whitelisting IP addresses is a bit 2010, but that's Steam for ya
well i fucked then hahaha. I guess will have to charge for the initial purchase of the game (but this is a problem since if there are no active users people will be paying for the game and not be able to play it) I was planning on making the game free and charging for in game currency which they could buy skins with :/
Just do it via regular in-app purchases.
eeeeeven then though, it's not entirely secure.
If a player really wanted to they could probably do a bit of mem-hacking to unlock all the items locally anyway.
We verify client unlocks server-side to help with that. At least that way, they can see what they've done locally, but everyone else just sees them as defaults.
I think im going to make it "hackable" for the time being and not charge for anything and if the game gets a bit of popularity, then introduce in game currency and try hire a professional to come up with and implement a solution
Any solution where players can "unlock" stuff via a listen server or a client machine is fundamentally unsecure
(if any professional tells you otherwise they are full of shit)
You might at best be able to write your own backend system which you host and it manages and checks for obvious spoofing, but ultimately the most secure way is a box running code that nobody has access to
wdym box running code?
Not to mention the cost of building infrastructure like that is pretty high
Like a dedicated server, running on machines that players can't access.
AKA "rentable" servers
or similar
At least you found out before launching ๐
But yeah, been through the pain already.
so i have some replicated UObject - they replicate just fine, as long as any replicated variables are in c++
if i add a replicated variable in a BP derived from that c++ base, that variable doesn't replicate, or call BP OnReps for clients
Ah yeah
One sec
if (const UBlueprintGeneratedClass* BPClass = Cast<UBlueprintGeneratedClass>(GetClass()))
{
BPClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps);
}```
Add that to GetLifetimeReplicatedProps
Is it possible to make an AI that takes control of a player (The AI can simulate button inputs, register as a connected player in the session, ect.)
Hello, does RPC_Validation just end one RPC call, or does it disconnect player completely?
Hi there, I'm trying to find more information about how UE4 handle server -> client assets. Such as a map. If we have a map that is only on the server, would it be downloaded by the client when opening, or is this functionality something we need to develop ourselves?
the map is packaged with the clients build
the client simply loads there own map when told too by the server via seamless travel
so if you need a map from the server only, you would need to somehow send the map to clients
and make sure they can load it
Is there a diagram someplace of all the events in the various multiplayer classes (e.g. OnPostLogin, BeginPlay) and they order they'll be executed?
I'm trying to build a mental model and the documentation does not seem to want me to do this.
thanks @meager spade !
@fathom dust I was in the same boat as you till I actually read through GameMode and it becomes clear
Not seen any diagram anywhere tho
it seems like reading the source is the move here yeah?
I'm currently wiring up every event available in the GameMode BP to Print String lol
if I make the diagram I'll post it here ๐
[JanKenGameMode_BP_C_0] Server: Initialize HUDFor Player(JankenPlayerController_BP)
[JanKenGameMode_BP_C_0] Server: OnPostLogin(JankenPlayerController_BP)
[JanKenGameMode_BP_C_0] Server: Handle Starting New Player(JankenPlayerController_BP)
[JanKenGameMode_BP_C_0] Server: BeginPlay()
[JankenPlayerController_BP_C_0] Server: In Game
[JanKenGameMode_BP_C_0] Server: OnChangeName(JankenPlayerController_BP1, MSI-3A1C8DE84895A766, false)
[JanKenGameMode_BP_C_0] Server: Initialize HUDFor Player(JankenPlayerController_BP1)
[JanKenGameMode_BP_C_0] Server: OnPostLogin(JankenPlayerController_BP1)
[JanKenGameMode_BP_C_0] Server: Handle Starting New Player(JankenPlayerController_BP1)
[JankenPlayerController_BP_C_0] Client 0: In Game
[JanKenGameMode_BP_C_0] Server: OnLogout(JankenPlayerController_BP)
[JanKenGameMode_BP_C_0] Server: End Play(End Play in Editor)
[JanKenGameMode_BP_C_0] Server: OnLogout(JankenPlayerController_BP1)
this is for sure not the order I expected lol
i wouldn't be trusting BP order