#multiplayer
1 messages ยท Page 661 of 1
Aight, but will that be able to handle alot of olayers and to be able to store world data saving/loading?
Here's a good example of how to do that: https://www.tomlooman.com/save-system-unreal-engine-tutorial/
Also wondering bout configs
that link covers exactly what you're asking
It depends on whether you're running the save/load nodes on the server or on the client.
you'll need to use C++ for that
and I would run all the saves on the server
and store it there.
Alright cheers
Is there a way I can improve this? Essentially I want to have it so If the Red team reaches the score (for testing purposes, set to 2) it displays the text "Red Team Wins", however, if the blue team reaches the score, it displays "Blue Team Wins". But i don't want to have it set up this way as both teams can hit the score limit at the same time and "both win"
You could use bool bGameWon at the start and only exec the code if it's false
Basically when someone wins it sets it to true
I also want to have it so when one team wins, a widget displays saying "team Wins!"
i've added a couple more nodes to create this
however the problem is, the widget only displays on the server and not both server and client.
I kinda know why it's doing this, it's because of here, it says "Player Index: 0" but i want that to be self for the player controller, but i forgot how to get references ๐คฆโโ๏ธ
Hi I am haivng a issue with dedicated server, I opened the port 7777 via nginx from a server to my local machine and I am getting:
Server side.
LogHandshake: SendConnectChallenge. Cookie: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
Client side.
LogHandshake: SendChallengeResponse. Timestamp: *, Cookie: (Same as the server side)
do a need to open more ports for this handshake happens?
you can just add this code inside your player controller blueprint so it will run for all
you can do this comparison inside the player controller so all the players will have this logic or you can store the PlayerState.PlayerId as a list and do it on the server side
but this still happens
im new to UE4 as well so i do wanna learn like how to overcome these obstacles for the future
change the custom event to replicate
I am new here too haha
you can change to multicast so if you are running it on the server it will replicate on the clients
the showredwins...
i tried all the options and still nothing :/
The idea is there, in terms of blueprint, it's just not properly showing on the client side ๐
if the replication does not work check if that cast to pc_... is working
for the clients
you can use the debug to check if it is going to the client and where it is failing
So i was testing the custom widget on the Red team. I have a text string to print Blue team wins in text and as you can see it shows on both client and server
i just want to display a widget instead of a text string
probably you have a has authority before call addScore
oh right
just check if you have
tried it and still the same :/
you probably have something like this hasautority -> addScore
this will pass only on the server
thing is i have other blueprint widgets that show on the client
for example, when wanting to switch teams
lemme try find it lol
this is where im having it so when i press Tab in game, this menu shows up
im stumped :/
Are you running the score code in GameMode?
No, i've tried the Gamestate, Game Instance, Player Controller and Hud
Now i just tried the game mode and the same thing happens, it only shows on the server
am i doing the logic wrong?
May wanna try running it on owning client instead
Are the casts going through?
wdym by that?
the casts seem to be working fine
Well, one way you could do it is that you store a PC array after OnPostLogin in GameMode, and when GameState sees that the game ended, it talks back to the GameMode to show the Widget to all players with a For Each Loop through PC Run on Owning Client
how could i do that with blueprints?
@rapid bronze @unborn trellis that won't work
clients don't have PCs except for their own
Hi Sinbad I just got that you can not use the player controller for this, but you can use game state
you do have a PlayerArray in GameState though
so you can loop through all PlayerStates
There's the server PC tho and if you run it on owning client it runs client side
I do that in OnPostLogin
To show Widget only to newly logged PC and only client side
you also don't need to store the PCs even for that use
GetGameMode->GetNumPlayers->For (0 to NumPlayers - 1)->GetPlayerController[Index]->Cast->ClientRPC
which is pretty much the only completely safe way to use GetPlayerController[Index]
iterating all PCs
ok let me try this. This in the Game State correct?
am i leading to believe this is the start of it?
you do need to connect index from for loop
into getplayercontroller
aside from that, yes
What am wondering is if you want to show Widget through GameState, you go through PlayerStates but iirc PlayerStates don't have a direct reference to PCs no?
I mean there's Unique Net ID that you can check against
oh like that?
yes
okay
if you want to do server to client only you can do on the gamestate like this
i don't know what im doing wrong
the add score running on the server and the showAny on multcast
just tried that and that didn't work :/
๐
You have another GetPlayerController at the end and i think you're running the entire code on the server
I just deleted everything in the gamestate, starting from scratch
So this is my Player Controller
Hi hope someone may be able to advise, I am looking into the multiplayer networking side of unreal engine.
Should I use UE4 or UE5 for starting?
It is only for experimenting, creating development tests but I would like to keep the results for future versions (progressive longer term, probably a git repo).
I'm using UE 4.15 for replication and multiplayer
im gonna take a break from this and try again another time.
If i get stuck, i'll post something on here regarding my issue
the problem to use UE5 at the moment is you will never now if you did something wrong or just a bug
I guess the docs would apply form UE4 to UE5, but probably not taking into account any new additions/changes that have been introduced into UE5.
I will use UE4, thanks.
did a direct redirect and worked ๐
@cedar tangle Even beyond networking, using UE5 for anything more than curiosity right now would be a nail in the foot. It's bound to be buggy. Things that normally work could be entirely broken. I generally avoid PointZero releases and Betas in any development software. However it's also worth noting that supposedly projects will be able to easily port to UE5 eventually. So even things you do now should require minimal effort to switch over later if you really want.
@winged badger @paper hinge @rapid bronze I got it working :D
Thanks for all the help you guys gave me.
Ill show you the blueprints now so maybe other people may find it useful
This is the Player Controller displaying the Blueprint widget on the viewport
then with ZIo's help, This is in the GameState
Then calling the custom event
And there's the proof :D
hi guys. i moved my files to a new folder. and it messed with the host and i assume join aswell in my multiplayer game. do you know what is wrong ? cant understand what it wants to readjust.
Guys. In desperate need of advice.
I'm working on an online FPS Controller prototype. I understand than in most all FPS games, the arm rig is spereate from the 3rd person rig that is being rendered by the other players. I also understand why that is.
My question:
I am creating a type of robotic character that does not have hands or fingers. All the weapons will be attached in a more modular way directly to the arm of the character. I will be using robotic types of animations and wanted to know if it's still best to create the arms spereate from the full body ?
Doing it this way, I feel like I can do most of the ADS positions / offset through animations rather than creating offsets in Unreal for the arms/weapon.
Any help would be GREATLY appreciated.
hi guys. i moved my files to a new folder. and it messed with the host and i assume join aswell in my multiplayer game. do you know what is wrong ? cant understand what it wants to readjust.
Double post ???
I have a little logic related to animation, so I m thinking not to insert it in my anim BP and instead do montage, so just wanted to know if montage is network friendly or not?
I do montage in GAS, but this montage animation is going to be played very frequently.
hey guys! anyone familiar with PlayFab? I need to send over to PlayFab a structure with my vehicle locations for a ghost replay system. I tried to serialize to JSON but apparently it's not the best solution...can someone help?
Your "As Platformer Game Instance" isn't defined wherever it is being accessed, which is probably on the "Host Session" node.
is c++ a must to be able to store data on server? or can it be done through BP? (Dedicated Server) i kinda messed up and forgot to set it to C++ when creating the project
No it's not a must. If you're creating a save game, there are BP nodes to load and save objects.
Okey good, but how do i set them so that they are saved to and loaded from the server?
Though doing a game with dedicated servers very strongly implies C++ will be needed
Can you explain a little more? ๐
By executing those nodes while running on an execution path that is running on the server.
Cheers
You only use dedicated servers if you have
A) Large (>5) player counts that prohibit listen server - you'll need to port stuff to C++ if only for performance reasons
and/or
B) Competitive play - you'll need anti cheat, report systems, probably replays, and cleanly implemented multiplayer systems, those will very likely work a lot better in C++
Yea, im tryina make a game where you basicly join in a Dedicated Server, and it will handle storing your data, aswell as world data, and hold a larger group of players at once
Yeah, your team of engineers will likely work better with C++ for that
Alright, so basicly i need to scrap it, and re-start my project
Yea, so im currently building with others, and im tryina make it so that you create a character, that data stores in the server with your inventory data, health etc, aswell as the items dropped to ground will store in world data amongst where vehicles have been parked etc
I wish people tried to do less of that, frankly
It's ridiculously hard to do and much harder to sell to players
But hey, like Datura said, just do a regular save game, assuming a player only stays on that one particular server
Yea, that's what made me look into web api and db, cuz if a player decides to change server, not to carry over his stuff
No need for a database if the player is stuck on that one server they started on
Just regular ass game saving
Yes, but the thing is, if there are 2-3 servers setup, i'd want the player to have the ability to basicly not run same data on server 2 compared to the 3rd and 1st server
Yeah, just do regular game saves
i'm doing exactly that one and it's going well so far, the catch is that there's litle to no live interaction between players, all is data base driven.
Server side
oh you can do things like this? i tought that save games on server side where not posible
such a conundrum, i'm not sure if keep going with the database setup or check for save game on server side and redo that parts
Of course you can save on server
The DB setup needs a DB server, dedis that are 100% owned by you
what would be the advantages of a DB vs ServerSide save game that you know of?
just passing the data to multiple diferent Servers?
server side save games would only exist for that server. If you have short lived servers, ie one lobby per server that eventually shuts down, then it's not a good route. A DB is useful for having data that's shared globally, ie Loadouts in Call of Duty
The only reason you would need some sort of a database for saving stuff is so you can play on one server, then bring the same character to another server, with the servers still being authoritative over inventory etc. If it's like DayZ or Minecraft where every server is basically its own world, server side save games are totally fine.
If you're doing something like Ark or Valheim, then a server save file is good as the data only pertains to that particular server and is not global.
ayy @dark edge
Honestly if you're new to this stuff, don't go dedicated server unless you have a game design that can very much leverage community hosted servers, like Garry's mod. You are not going to make a competitive multiplayer dedicated server game your first go around, guaranteed.
..but I did :/
What's your player count
Mine is sort of your tipical mobile game like travian and clash of clan, but with litle to no live interaction with players, almost all database driven.
how do save games behave if you want to make changes to the same?
Oh yeah that's a totally different animal. That probably wouldn't even have a Unreal Engine server on the back end
can you change the structure of the save games and not lose them in the process?
Can't stress enough that this is imho the best advice. The average indie game that sells well simply can't sustain multiplayer because "well" in this context means "20 players online a week after launch". Don't assume your game will be an insanely exceptional commercial success !
yeah, but if it's just doing it for the sake of doing it and learning, everyone should give it a try, knowing that it's going to be freaking tons of work
Kinda disagree that spending a few years on a game that's unlikely to do great is a good path, especially for first games. Doing small games in like 6 months that people can buy, play, give feedback on, get you to fix bugs on - that's imho a lot more formative than trying to not have your game hacked when you sleep
Having done both
Sure, you'll learn to set up a web service and maintain a database, but those aren't exactly mainstay game design skills
Then again you might be looking for a job in web services too !
yeah, the hacking stuff is going to take quite some time later on, damn it.
hm when i "play as client", the position of my player character only updates on the server 60 times per second, regardless of what net/lan maxtickrate are set to in defaultengine.ini, and regardless of the replication update frequency
more odd, if i set my fps just above 60 (e.g. 61 or 70), the server has an outdated position every other frame. i would have expected most of the frames to agree with the client, with only a fraction being outdated duplicates. instead, it's as if setting my fps to 61 is the same as setting it to 120.
maybe i'm just dumb and missing something obvious but i am pretty stumped about what's going on here
he's probably talking about aim gods. the game was relatively popular but short lived, which wasn't his fault at all
at the time we had 40k players. The game has since shut down since the company folded.
^
yup
i still haven't got my free one ๐
so 30$ x 40k players = 1,200,000
not bad after you take out all the taxes and costs
yeah....
the costs were something else entirely xD
I won't say anything bad publicly, but poor management decisions caused us to have a very expensive cost system.
Which we weren't allowed to fix
but was constantly bitched about
ยฏ_(ใ)_/ยฏ
the beautiful perks of working with a group of people
oh no, we all wanted to fix it
i miss them everyday since i quit my full time job
it was the boss man
djriff don't be a gremlin
sounds like a freethinker thing to do
what would you call games like clash of clan, travian, etc? (city building + exploring + battles)
rpg online?
hmm yeah, tey popup as strategy games, thanks!
anyone have any idea what the deal is with this
@thin stratus might know. I've never delved that far into that particular type of issue.
Is it possible to have code/BPs in a server build that is not included in a client build?
For example, code that communicates with another server and would only be relevant to the server build.
I did a quick google, but not sure what I should be looking for.
Pretty sure this is it here... You can exclude items from the server (top list) or the client (bottom list). Found in Project Settings.
How many ms should be appropriate for a multiplayer to optimize it
I am with netprofile
When the server sets the location/rotation of a client's pawn the client does not see it update (Set Actor Location/Rotation nodes). it is using a "Executes on server" event and the pawn is set to replicate.
Why is this happening and how can I fix this?
I have a very odd and rare bug; sometimes the Host loses control when a game starts. They have no control at all - can't move their character or hit Escape to bring up the menu. This is super rare though. Has anyone had similar?
Does savegames save automaticly tothe server when the player is connected to one, or does itsave locally?
depends on who calls it
if the server calls it, it's saved on the server
if the client does, it's saved locally
How do i make sure the server calls it then in bp?
mark it as a server function
Thank you
How do i mark it as a server function tho?
read the networking guide in the pins.
TLDR; How can I 100% prevent a replicated actor from getting destroyed on a Client?
The long explanation:
- AMyActor is an actor that has both bReplicates and bAlways relevant set to true.
- AMyActor::EndPlay has a UE_LOG of Error type when it gets destroyed due to EndPlayReason Destroyed, LevelTransition, or RemovedFromWorld.
- I'm spawning a AMyActor instance on the server (from AMyGameMode) and storing a UPROPERTY reference to it in UMyGameInstance (
UPROPERTY() AMyActor* MyActorInstance) - AMyActor sets itself on MyActorInstance on its own BeginPlay (
GetGameInstance<UMyGameInstance>()->MyActorInstance = this;) - On AMyGameMode::GetSeamlessTravelActorList I add the MyActorInstance to the list
void AMyGameMode::GetSeamlessTravelActorList(bool bToTransition, TArray<AActor*>& ActorList)
{
Super::GetSeamlessTravelActorList(bToTransition, ActorList);
AActor* MyActorInstance = UGameplayStatics::GetActorOfClass(this, AMyActor::StaticClass());
if (!IsValid(MyActorInstance))
{
UE_LOG(LogPreGame, Fatal, TEXT("Could not find an existing MyActorInstance"));
return;
}
ActorList.Add(MyActorInstance);
}
Expected behavior:
MyActorInstance is never destroyed on a client because nothing tries to destroy it and it is marked as always relevant. I should add that the Fatal log Could not find an existing MyActorInstance never triggers, and that I have print string from the MyActorInstance getting created, so it is safe to assume that the actor is properly spawning.
Actual behavior:
On rare occasions (1/50 games I'd say), a client will print the Error log about MyActorInstance getting destroyed, and then that client ends up crashing after trying to access the MyActorInstance. This seems to only happen immediately after doing a seamless travel to a different map.
So now, how do I ensure 100% that MyActorInstance is never ever destroyed?
nothing special should be needed. Just need to drop a breakpoint and it should be fine.
How can I check in the PlayerState whether it's local or remote?
GetRemoteRole() == ENetRole::ROLE_AutonomousProxy ?
what are you checking for?
authority or?
show where you're calling it
breakpoint the if(!HasAuthority() and see what the role is.
you want it to RPC yes?
I would structure it like this then:
void ASideScrollerRPGCharacter::JumpInput()
{
if (!bWasWallSliding)
{
Super::Jump();
}
else
{
LauncherCharacterRPC();
}
}
void ASideScrollerRPGCharacter::Server_LaunchCharacterRPC_Implementation()
{
LauncherCharacterRPC();
}
void LauncherCharacterRPC()
{
if(GetLocalRole() < ROLE_Authority)
{
Server_LaunchCharcterRPC();
return;
}
/* BREAKPOINT */ LaunchCharacter(FVector(0.f, GetActorForwardVector().Y * -800.f, 3600.f), true, true);
AddActorLocalRotation(FRotator(0.0f, 180.f, 0.0f));
bWasLaunched = true;
}```
1s let me see what that does, i don't use that function really
ah
yeah you can just use that
does the same thing GetLocalRole() == ROLE_Authority
Thank you for that.
try making LaunchCharacterRPC a net multicast function
i would remove the has authority check
you probably need to do this through the CMC
yeah, that's needed for this kind of stuff
I don't know of any resources for CMC sorry. I just read what it did and extended it as I could.
I ended up modifying the CMC in engine as extending it wasn't enough.
what is a CMC class?
messing with CMC custom movement replication is probably the least fun thing to do in unreal lol
Character Movement Component
to be honest i thought launch just worked by default with CMC replication like jump does (though in that case it'd be called from the client, not the server?). If not, you'll have to extend CMC and mess with SavedMoves to add some kind of bWantsLaunch flag so that launches are part of corrections and replays like everything else. there's detailed tutorials online but to be honest they're all a huge pain.
it doesnt
of course it doesnt lol
because then u would be sending a vector over the network
allowing the client to cheat
as they could modify how much they want to be launched
yeah one thing i never got with CMC extension is where do you put verification? there are some custom movement types where you'd probably need some kind of client input to be added to your packets, and i get how to add that, but i'm not sure in what function you would add logic for sanity checking that stuff before it gets executed on the server. i made a google doc mapping out what order everything gets called on both client and server a while back but so much stuff is called in multiple places and i wasn't sure what was the standard approach, since every tutorial just kind of ignores that part of setting things up
wdym?
you just have a CanDoThisFunction in the CMC
and call it everytime the action is performed
If i understand that correctly, wouldn't it be a case of executing it on the server and then validating it? Or do you mean the packet data before received. What is the danger.. packet size?
Actually is very interesting you say "before it gets executed on the server" must be a way of check before hand.
When I have two server instances running on the same machine with different processes, ServerTravel doesn't seem to be working on the second server:
GetWorld()->ServerTravel(nextMapPath, false, false);
for the first server it works properly, and the second one it opens the map on the clients, but it opens it locally and not connected to the server anymore
only difference I can think of is that the second server opened gets an incremented port number since the first server is using 7777 by default already
what port is each server using?
7777 and 7778
do I need to use an absolute path? Maybe relative path is getting screwed up somehow
how are you connecting to each server?
the initial connection is done by launching the client application with command line arguments
And those would be?
@fading birch i.e.
game.exe <Server IP>:<port>?PlayerSessionId=<Session_token>
If you're using sessions why not just find the session and connect to it?
why you calling LaunchCharacterRPC recursively ?
LaunchCharacterRPC
{
!hasAuthority();
Server_LaunchCharacterRPC();
}
and the Server_LaunchCharacterRPC() is calling LaunchCharacterRPC()
Oh Did it work for you?
Try to run the game inside the editor (not a new PIE window) with this option checked
I'm adding Impulse to a client pawn in CMC (as server), but since server-side correction is enabled, client velocity does not change. Can I somehow find a workaround for both not disabling server-side correction and adding impulse?
Alright, found it
Hey yโall! Iโve hit a snag with the networked CMC Iโve been working on. Iโve run out of custom compressed movement flags. Since 2 of them have been reserved and we only have access to 4. I was wondering if thereโs a feasible way to increase the available number without messing too much with the source code. Thanks for your help!
Iโve also heard it is possible to increase the number of compressed flags since 4.26 but havenโt found any guides on what to do/override or code examples
@devout egret There's been a pretty substantial rework of that system to allow for exactly that use case! There's a new NetworkMoveData class you can extend in a similar manner to FSavedMoves. Doc here: https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/CharacterMovementComponent/
But I also found a great free resource that actually has some examples of how this is used in practice: https://www.unrealengine.com/marketplace/en-US/item/50527885258c47f79ec1ebcc5e00e868
In the past, you had to do some rewrites to achieve that, or do some bit-shifting stuff like the Unreal Tournament UE4 source code. Let me know if that helps! It definitely made my life easier.
Am I correct in thinking that a Game Mode Event Graph, with a branch check of Is Server, should only execute on the server. As I see it, what seems to happen in the Game Mode BP replicates to all other clients also.
Is it down to replication that makes the print string show on all connected clients?
Actually, I think this is the intentional behavior for print string as it displays โServer:โ in front of the message. I will test printing from a reference that is inside a class to see if that works as I expect it to. If so then that answers my own question.
has anybody used Photon with UE4? Just trying to see the viability for our project.
game mode is like a manager for multiplayer. All of that stuff stays on the server and manages your session. Proof being you cannot make a reference to the game mode on client, it will always be null.
If that is the case, then that is perfect and thanks for the info.
found it out the hard way and had to stay at work overnight on friday ๐.
can imagine that hurt. Been there many times ๐
Look for Ue4 networking compendium it explains all the classes well
That looks like that I have been Google'ing for. Thank you again.
also this
Hello guys, in this video I will explain the GameMode Class, GameState Class, PlayerState Class, and Player Controller Class within Unreal Engine 4. I will explain the practical uses of these classes and how you can implement them in your multiplayer game. To move forward, you must understand what role each of these classes play in your multipla...
That video, the no. 1.. Got me looking at UE4 to do what I am doing now.
I am kind of hooked and also so impressed with UE4 and this Discord community support.
But obviously did not get to vid 3 ha ๐ .
discord is a hit or miss. Sometimes you have to figure stuff out on your own too.
Iโll check out those resources thank you so much! Iโll let you know how it goes!
is using delay in blueprints really the way to "make sure" that networked stuff is available? my PlayerController's BeingPlay is run before the server even has the PlayerState setup and id like a more proper way than just waiting an arbitrary amount of time hoping its ready after
i guess i could tick also but both of these sound like hacks
No
You should use appropriate call backs. Delays/timers are not the best way. Sometimes they can be OK if used properly. But not the best way.
eventDispatcher should do the work for this kind of things i think
but which event? is there one built into the engine? or am i supposed to make my own?
with eventDispatcher you can make your own event notifications and run code on notif
yes i understand but this does not help me. i dont know when the player is really ready (ie has its player state created on the server) so using an event dispatcher does not help me. if there isnt such an event available out of the box then i can understand how this would help me
so the player state exists in PlayerController.BeginPlay and its the correct class (im using a custom PlayerState blueprint), however the custom data is not ready/copied from seamless travel. using a delay of a few seconds "fixes" this
the player state is ready when it's owner is set
There isn't really an event that you can call to check that from BP afaik. You'll need to use code and override it
My goal with this logic is to make a widget that appears to everyone, if I run this on server, will it replicate that widget because it's a component or no?
i dont have any problem using code, im just not sure where anything is done. ill have a look through the engine source and see if i can find it
No
Widgets aren't replicated
And components that are spawned runtime don't change that fact
Oh a 3d widget can be replicated can't it...
look at ClientInitialize
that's when the player state is initially replicated
I did something on my last project that had replicated health bars
You replicate the events that create the ui
And you replicate the data the ui should show
And that's it
thanks. so im guessing i could call an event from this back to the server to get a more final "player is ready" type thing
OnRep_PlayerState is in AController which is when the controller has it's playerstate replicated
Hmm. I want to make an arrow indicator over a players head when they're targeted by an ability, and I want all players to see it. Perhaps it's easier to just make an actor with an arrow on it.
Maybe yeah
Thanks
i think PostSeamlessTravel might be more what im looking for. i might make a gamemode class and just expose all of these functions as events and play around with them
GenericPlayerInitialization may be better
it handles both PostLogin and HandleMatchHasStarted
Interesting. I'll definitely play around with these, thanks. A
np
Anyone knows a good tutorial or reference on how to replicate projectiles in C++? I tried some google searches but no luck.
you either don't use projectile actors or spawn them with multicast on each client locally and don't replicate
or do shenanigans like UT do
shenanigans ? played UT never looked into the code for it
no dont use a multicast
just set he projectile to replicated if u dont want it to be predicted if u do u have to do the magic that UT does
and call the spawn function on the server
there are so many things wrong with using a multicast in that situation
in my case using replicated actors as projectiles was impossible because by time the client received the replication projectile would already hit or fly far away
and many many other problems in close distance
so just use them as visual fx and real proj in server only
plus crazy 900 RPM weapons which i still detest
I tried setting replication on my projectile but it doesn't seem to spawn when using multiplayer. I have the below setup:
bReplicates = true;
bAlwaysRelevant = true;
InitialLifeSpan = 20.0f;
are you spawning then on server? are they fast?
I'm trying to spawn them on the server. idk if i'm doing this right:
bool ASWeapon::ServerFireProjectile_Validate()
{
return true;
}
void ASWeapon::ServerFireProjectile_Implementation()
{
//StartFire();
FRotator MFRot = GetMuzzleDirection().Rotation();
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = GetInstigator();
AGrottoProjectile* Arrow = GetWorld()->SpawnActor<AGrottoProjectile>(ProjectileClass, GetMuzzleLocation(), MFRot, SpawnParams);
Arrow->CharSpawner = GetPawnOwner();
}
in my .h:
UFUNCTION(Reliable, Server, WithValidation)
void ServerFireProjectile();
void ServerFireProjectile_Implementation();
bool ServerFireProjectile_Validate();
get rid of this in header
void ServerFireProjectile_Implementation();
bool ServerFireProjectile_Validate();
you must never have them, they're generated by uht
Would this be a decent approach to managing inventory for BR style game:
Inventory System for character using ENUM.
Setting defaults at runtime.
Character Interacts with weapon BP loot.
Add to the inventory and attach the weapon BP to characters socket.
Manage visibility/etc (Current selected weapon/etc)
I have been told just to pre-place all the weapons on the character and enable/disable as needed (upon interacting etc.) ----- but...
I do not want to do this because I want the weapons to hold the same values (ammo in clip, etc.) and be persistent. Although its possible to pass those values to the player than picks the weapon up. I feel like there's no point in doing this.
Would this be considered a good approach in general ?
Inventory System for character using ENUM.
what do you mean by enum? inventory slot type ?
Yeah, assigning the variables upon interaction with BP
eh, you can. if you have very limited amount of items. i'd prefer data assets 1 asset per item
blueprintable enum can have only 256 values, br game would have way more than that
Where can i read up on Data assets
google, they're just data holding uobjects/primaryassets
there are bunch of various inventory systems demos out there some would work in mp
Ive created one and started playing with assigning the values but cannot expose the variable in the BP...
Cannot find the one i created in the Variable Type
UPROPERTY(EditAnywhere, BlueprintReadWrite) UItemDataAsset* ItemType;
For all the UPROPERTY(specifiers) I want to be visible in BP ?
Maybe im not understanding you properly.
I cannot add the Data asset variable in the BP at all.
The data asset i created has the variables exposed like expected.
Do data assets need to be # included ?
LOL nvm, fixed it
I have a strange problem, I'm trying to test the multiplayer inside my editor by setting players as 2 and "Play as listen server".
Why does the client also have it's own GameMode object?
It is causing some strange bugs to occur.
Hmm, It still seems to behave as if there is multiple gamemodes running
editor debugging is not perfect at all times
but
Im not sure about gamemode part
server only has it but uidk
the client is printing things that originate from the gamemode
@spring tangle Please use the Job Board for this.
Hi! i'm having some troubles with the default server map on a dedicated server.
I'm running the editor on standalone as a client.
For some reason the server is not opening the default server's map, but rather the map i'm currently using in the editor, is this normal?
Do i have any other way to test the server with it's default map that's not packaging the server?
yes. Create a shortcut of your .uproject file after Target add -server -log
oh didn't knew about that one, thanks!
you can do the same thing to launch a client by replacing -server with -game
with this one i'm getting a editors window open like normally do
i'm using source version of 4.26
ok perfect
<Delete it and never come back>
Ok...wait what?
YOURENGINEDIRECTORY\Engine\Binaries\Win64\UE4Editor.exe "FULLPATHTOYOURPROJECT/PROJECT.uproject" -server -log ```
fill those all caps words in
and replace the Target of your shortcut with that
okey, so it would be like this
D:\UnrealEngine-4.26\Engine\Binaries\Win64\UE4Editor.exe "D:\UE4EngineProjects\CultPathMain.uproject" -server -log
yes
i'm not sure about \CultPathMain.uproject" -
shouldn't it be \CulPathMain\CultPathMain.uproject ?
oh that makes sense
love you, it works
the one for the client also comes in handy
yeeeeeeeeees my setup works
damn it was hard to get an entry map for the user and one default for the server
hey guys i wanna ask is there any guide to adding steam for my project on 4.27?
i wanna try to do it again and the goals for it long term to use it alongside EOS
and i wanna use it for multiplayer "matchmaking"/"world search"
think of my use case for steam is similiar to valheim
do you guys find yourselves having values that are separately calculated on client and server (not replicated) even though ideally they should be synchronized? I'm knee deep in spaghetti code with fast arrays representing values of uobjects inside of uobjects and i'm about ready to just not replicate this stuff at all and instead try to enforce that the same code is called on both client and server (the worst case is client cheats or i mess up somewhere, and then the client just mispredicts stuff)
Hey guys, why is the character loading correctly for the server but not for the client? The left screen is server and right one is the client. I am using a savegame to save the character and then load it on begin play
Not enough info. How do you replicate the loaded data?
You mean the custom events or the variables?
They are replicated
There is another level, where the player sets up their character
After that is done, there is a Widget for saving it, when it saves it to the save game
On each client?
How do you send the selection to the server?
Is that level Multiplayer?
And how do you send the server the data then?
And then the player joins the multiplayer level
Thats the problem ๐ How do i send the data so that it is fine for every player
The data should just be some struct with info about the character
Its it not a struct
You can send that via an RPC for all it matters
The meshes are stored in seprate variables
So do you think it might be the problem?
No. But you have to send the data to the server via an RPC after connecting
And then the server has to set some RepNotify variable with the data
Its like this for every piece of mesh
So everyone gets the change
Yeah that's pretty wrong
There is no reason to mark those variables as replicated
The data can't replicate like this anyway
The player cannot change the character mesh once its on the multiplayer. Do i still need repnotify?
Yes
On PostLogin you can send a Client RPC to ask the Client for their character data.
Which can then load the data and send a RPC back with that data
Then the server can spawn the character and set the data on the character as a RepNotify variable
In the OnRep function you an apply the changes then
That's why filling it into a struct is good/necessary
Just keep in mind that players can cheat how they look like in a setup like this
Yeah its fine
its not a professional game
It's my first multiplayer game
Am i on the right track?
Well that's saving stuff. Not the part that is important
I mean is it saved correctly or i need to do some rpc stuff here too
Just need to do this part which unfortunately i couldn't figure out
How do i do this part
I have completed stuff from this step
Hey Guys was just wondering if anyone could help me with this engine-ini error im getting i currently have built a dedicated server for my game and its telling me that my default material name is not defined in my Engine.ini file for the server causing it to crash
Heres the log [2021.09.05-08.06.20:822][ 0]LogUObjectGlobals:Error: Can't find 'engine-ini:/Script/Engine.Engine.DefaultDeferredDecalMaterialName' in configuration file section=/Script/Engine.Engine key=DefaultDeferredDecalMaterialName
It gives a similar error for DefaultLightFunctions and others im assuming i have to fill the Engine.ini with default values for these categories but im not sure how to do it anyways any help would be apperciated
Hi, anyone tried to implement network prediction using the NetworkPrediction plugin yet? very curious
What's the correct way to set continuously changing variables that drive blendspaces in multiplayer?
Tick?
no way
for example
character movement is has built-in replication
so you can get the values from there if you like to do stuff such as walk/run
for others
you need to be subtle
if you put on tick you will have problems
try to work with what you already have
What problems? Other than inefficiency. I don't plan to have it on tick but I want to do it on tick for now to test. I would imagine it would work but be very choppy or reduce framerates, but doesn't seem to function at all.
It's not walk/run it is a maggot npc and the variable controls how much it is bent depending on the distance of the nearest enemy player it detects.
think about it this way
can you absolutely cannot do it on client
for example lets say physics
if you know what vector you are going to impulse and start location
you dont need to replicate the movement at all
you just apply the same thing on the client as well
not everything needs to be replicated
you dont need to replicate things to do that
I dont know what you mean by bent
but you can check the distance on the client
it doesnt have to be on the server unless necessary
because lets say your Maggot sees Player A as nearest, it is the same for the player B locally
i do check the distance on client
the maggot bends via animation blueprint
i need all players to see it
all players should be able to see it
even without server
because all players know each other`s location already
yes that is true because players move via movement component which auto replicates
the maggot is an AI that has a trigger that tells it if an enemy is near, then bends towards that enemy depending on the distance
but if i want the maggot to bend, i need to set a variable in the animation blueprint, and afaik I need to set this variable on server
no you dont
server already gives everyone player locations
use that instead
and set the variable on everyone locally
how can I explain with my mediocre english let me try
Maggot is on 0,0 (Coords)
Player A is on 1,0
Player B is on 2,0
Player B already knows A is closer to maggot because it has both of their location therefore can use this
so no server needed
yeah my setup is very different to what you are imagining.
I lied about the 'nearest enemy' thing to make things simple to explain, there is no distance comparison
But thanks for trying to help.
The idea stays the same though. If you have data available on Clients, use that instead of replicating even more.
I should go into more detail because I'm probably confusing people. Pretty much I have some maggot NPCs, they are hostile to some players and friendly to others. They have a trigger box around them, as soon as a player enters, they check if that player is hostile and if so, 'lock on' to that player as long as that player is in range (even if another hostile player comes near the NPC; only once the 'locked on' target moves out of the trigger volume, the maggot is then able to lock on to other targets that approach). The maggot BP has a variable that controls how much it is bent (via an animation blueprint) depending on how far away (while still in range) this 'locked on' target is.
I managed to get it all to work via checking the distance of the 'locked on' target (on tick, but probably will change later to every 0.1 secs or so for performance) in the maggot BP, setting a variable on server and then setting the variable in the maggot anim BP, on all clients, via a multicast. I imagine this is quite inefficient and I'm doing this kind of thing a lot over my project, what worries me is that it is a continuous variable so it will be changing often (unlike some of the other instances I do this, which is just occasionally when players press certain attacks).
what you can do is then, you can make the "locked-on target" replicated
then use this
because these targets still exist on everyone
tick on server but only set it if it is different than the last time
you can use tick as long as you are not filling it with rpcs, replicated stuff changing etc
the locked on target is replicated
if let the players know only when the target gets changed you can still go with the original
its not inefficient per say
you dont need to constantly Set it
check if it is different than before before setting it
if you dont try setting it constantly you wont have problem
server can tick just like clients no problemo
but i still need to set the variable in my animation blueprint and I don't think I can set that in client
why not
you have the target
actor
and the maggot
just recalculate the distance
You can and should be setting animbp variables on the client
Hi everyone. I need some help, I'm not entirely sure what is causing problems I'm experiencing with really, really basic replication. So, I'm running server and client commands, but, the item is not really replicating movement induced by physics correctly, there is a difference in how the physics plays out.
I'm running Server command event, then a multicast afterwards which does actual item spawn.
I have item spawn BP ticked "replicate movement", but it's not exact.
The game is about sorting boxes in tandem so I'm really into making it 1:1 across clients.
Are you spawning the cubes locally on the client(s) through the multicast?
Because if so I would just let them replicate with the server saying where they should be exactly, but that doesn't necessarily have to be a good solution depending on what you plan to do with it.
Hi! i'm having some troubles forwarding ports so someone else can connect to my dedicated server over the internet.
is anyone familiar with the topic?
this is what i'm doing atm
The server ip address is my "Temporary IPv6 Address"
This is how: (SR_ is server, CL_ is client multicast)
That indeed spawns them locally for all players, like I said I'm not sure what you plan to do with it but currently the issue is that the server doesn't say where the cube(s) should be because the server doesn't know about the cube(s) that clients have. Which means that any small change / imperfection could already cause different results for players which then could be again different for someone else. I would say you should just spawn them on the server and let them replicate to clients with the correct position / rotation so that the server still has authority over them, but that could give different 'issues' when you for example want to interact with them through physics or something else based on client actions.
I srsly dont understand this, im trying to store my controller for my recoil component in this variable, which is later used to add pitch and yaw. The server does store the controller and on client side no controller is stored eg. null. I just dont know anymore how to get the controller associated with this pawn on client side anymore
Is it null for the pawn that is controlled by the player playing on that device, or is it someone else's pawn? Player controllers are not replicated to other clients other than their own.
its its own controller
just trying to get the controller thats possessing that character
Then why not just use the node for getting it from the character/pawn? https://answers.unrealengine.com/questions/532036/how-can-i-get-the-player-controller-out-of-a-pawn.html
that fails too
Then I assume it's either called too early to the point where the controller has not possessed the pawn yet or something else is wrong.
What are you doing with that variable when it's supposedly set?
ok i did some further testing, it is now set on the client which is good, but it still cant retrive the value in the component
which is very weird since the component should work on the client since the character owns the component
๐
this is called after the event tick of my recoil component and after some math
and yes its the whole time not valid
Did you check if it does get set but simply doesn't apply the rotation?
Or does the print string run?
print string runs
on client and server
so for both sides its not set
weird eh๐
ok i might have found the mistake but not sure, the function that adds the actual recoil is just a function and all the values im printing out (to modify the recoil) are all just server sided
Where do you run AddPitchAndYaw from?
from tick directly
but
the values that are added are all coming in from a seperate function
And how would I get the position of the specific player pawn?
this is the function that actually adds the target recoil, and the print string only runs on the server
Well, physics is ON for server authoritative as it allegedly should be: the "Replicate movement" is ON for the
i got it working
Well yes, but that doesn't matter if it is spawned on the client locally because you can't replicate from a client to the server. The server should spawn the cubes, set them to be replicated and to replicate the movement (and probably the rotation as well).
thank you so much for helping me, the problem was that the added recoil was only server sided@twilit radish
How would I go about server spawning? Making him the owner and instigator? Or spawn at the server event and then what?
(Transform includes location, rotation and scale)
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/ explains how it works and also has a BP section on how to actually do it.
Hi guys. I know I can launch dedicated server with some parameters like /Game/Maps/BattleMaps/Arena_Map -log But can I use custom parameters when launching dedicated server? And if so - how can I read it?
So actually, I've been learning it the wrong way. The YT tutorial from Matt Aspland is incorrect?
This screenshot is now working correctly, but I had to turn on "Replicate" and directly spawn by server, with cutting the CL node completely.
I'm not sure what your tutorial plans to do, but it was spawning them locally for each client which most likely gives different results especially over time. Which can be fine but that again depends on what you plan to do with it ๐คทโโ๏ธ
I see, yes. I'm totally not accustomed to this. Usually I deal directly with network code. This is my first week using engine at all (after changing companies last week where in the old one we had in-house engine) so this is somewhat new to me. Feels so much disconnected and lost.
I'm also still pretty new to this, also haven't done much in terms of learning for a while now so I was trying to get slowly back into it xD
But it has a steep learning curve if you ask me, quite a few complex topics and things to keep in mind etc. ๐
Anyone familiar with portforwarding? i'm not sure i'm doing it correctly so people can join my dedicated server
I have port forwarded before yes, but in my experience people always have different software for it build into their routers (if at all). Most of those companies have forums though, you may be better off searching on the internet for such places.
Is Windows Server Core (command line only) ideal for dedicated server deployments, or is it typical to also install the desktop experience (GUI) ?
i'm doing it and following a few, i'm not sure if people is stil unable to connect for this reason or another one
is this okey?
and for the people to connect, i give them my public IPV4
wich i'm getting from here
See the IP address assigned to your device. Show my IP city, state, and country. What Is An IP Address? IPv4, IPv6, public IP explained.
Usually use Linux for dedicated server deployments, saves a bit on cost due to not having to license Windows Server
you can get some really cheap Linux VM with linode
Iโm more comfortable with Linux for servers, I was just getting the impression Windows was recommended.
by whom and for what?
Thatโs a load off.
The docs and google search didnโt seem to mention Linux much.
we don't ship a linux client, but 100% of our official matchmaking servers are hosted on linux servers across bare metal and cloud
Is it better to use custom events marked with "Server", "Multicast" or "ByOwner" or use SwitchAuthority and direct BP actions?
the switch authority works after you started the action, in order to run on the server you need to do so with the replication on the event
So, it seems that if I call the event (marked as server) while using switch authority Server, it works on both, server and client. If I do is with "remote" it works only if clients instigate it, but not server machine.
If you call an event (run on server) it will run the event on the server and than replicate it on the client.
If inside the event you have switch authority (Server, for example) the code following will only run on the server
the event is fired on both, but inside the event you say "hey, only run the following if you are remote/authority"
are development client builds supposed to work with shipping server builds?
i'm not sure about that one, but i tried shipping client with dev server and it works fine, even with editor server.
how much is the ms recommendation for multiplayer that I am optimizing and I do not know the values โโin which to move
can someone clarify for me
?
Any suggestions for which function to override in AGameModeBase to bind to delegates on a newly spawned player?
handle starting new player _Implementation
but if you need after actual pawn spawn it will be a bit later, just open source
@fallen escarp The advice you got given is not accurate
Run on server - This event is ran on the server. Normal client will not run anything from this node.
Run on Owning Client - If called from server, will run the event on the owning client. If called from owning client, will just run like normal.
NetMulticast - Has to be called on server, and will run the event on all clients.
Just wondering, is it possible to connect to a listen server through both LAN and an online system? Or can you really only have one or the other?
As in, some clients join from LAN, while others join from lets say Steam.
Is it still a thing that if you want to use Steam leaderboards through the generic OSS interface calls such as ReadLeaderboardsAroundRank, you have to create a matching stat in Steamworks for each leaderboard type that matches the leaderboard name?
When using the Steam API directly, it was possible to just grab the values from the leaderboards without needing them defined as stats
Is this just the way the interface is implemented and making stats is the only way around it?
Iโm not sure why you donโt look at how the OSS interface is implemented to confirm this
Well you can do LAN discovery through Steam but I suppose you could allow NULL OSS connection if itโs over a LAN IP if you really needed that
I am trying but it's very dense and difficult to understand as someone with little experience
I have it retrieving the names and correct ranks
But the score comes back -1
There are some old posts about needing to implement the scores as stats if using the OSS interfaces
Just was seeing if anyone knew if it's still the case
Well you seem to understand the Steam API so why wouldnโt you check the implementation?
I'm trying, as far as I can see, the UE interface doesn't make use of the delegate that gets returned from Steam after fetching a leaderboard but it's quite hard to track with slow intellisense
Steam callbacks donโt run in the game thread so thereโs a bit of boilerplate for getting the result
Yeah that's the thing it hops around quite a bit
I think that it's just getting the rank and name directly but for some reason checking if a user has a stat matching the name of the leaderboard
Rather than fetching the score directly
Perhaps to allow for multiple stats per entry as they pass in null for the details array which is what Steam uses to store more than one value per entry
Looks like that is indeed the case OnlineLeaderboardInterfaceSteam.cpp line 1005
// Only take the rank from here (stats grabs the actual ranked value)
UserRow->Rank = LeaderboardEntry.m_nGlobalRank;
Pretty much all the async task implementations are in the same cpp file
Yeah it's just tricky for me to see what calls when
Ok so after a bit more reading the code it looks like the actual "score" associated with each entry does indeed have to be a separate stat if using the OSS interfaces
So rather than writing to a leaderboard directly, you are writing a stat to a steam user, then writing that stat to a leaderboard entry. Then when reading a leaderboard, you are retrieving a stat matching the leaderboard name
A bit confusing but it seems like that's how it's set up
guys what happens if i created a run on server rpc in UI graph editor
does it only run for the server
or all the clients
What does the RPC do exactly?
okay
Mostly you only create UI on the client so it wouldn't run at all on any clients
i passed a player state aray
to the Widget
then i used a server rpc to type cast each element
cause it fails to type cast if i did not do that
idk why
PlayerState is a replicated array so it's available on the server and client
Firstly you should retrieve the PlayerArray variable from the GameState, not pass it to the UI
i got the player state array from server and created a wifget for each player and i passed this array to it
yes in my player controller i have a function run on server that only iam sure the server only will run it
i got my player state array from the game state
and then i got all actor of scene
with player controller
Ok well there's no need for any RPCs if you just get the PlayerArray directly in the widget from the GameState and not pass anything in
PlayerArray lives on both client and server
and for each element i create a widget for each player controller
how can i get the player array in widget
if iam client
Get the GameState and retrieve the PlayerArray there
GameState is replicated
As is PlayerArray
So clients can get all the info there
There is a GetGameState node in BP, even though it has no relation to the widget, you can use it to get data
so game state is replicated for each client
if i cast it does it fails
?
also the client dont have the aother player states right?
All clients can access other player PlayerStates via the PlayerArray variable held in the GameState
so if iam a client not a server and i get game state then cast it then got the player state and got each element then cast it
no problem will arise right>
Yes that is fine
That's what GameState / PlayerState are there for
To query data about other players / the game
is there any way to replicate about a hundred AI Pawns without any network lag?
when i cast player state array element
because currently, im getting a lot
Write your own CMC
That's the main bandwidth killer
hmm
can i do that with basic C++ knowledge, dont know too much
ykw, ill just learn the terms as i go ๐คทโโ๏ธ
In short, without custom work it'd be very hard to have 100 pawns running around in a close proximity
CMC code is very dense and difficult
You'd have to know what you are doing to write a new one
let me try that @grizzled stirrup i will not use any replication inside the widget and test if it works
btw
yea i can see that lmao, im having to limit cull distance severely as of now
btw if here the target was a client player actor that i got from the server
does this function runs on the client player actor right
Ok this is very bad for many reasons
You have to be careful about how much data you send, when you use RPCs etc.
What you are doing here is sending the entire PlayerArray down as data to the client when they already have access to it via the GameState
I didnt read the above but if whatever you're doing %99.99 of the time you dont even need to send player controller
yeah yeah if this works i will remove the player state and players state
Server already only one who can access playercontrollers except the owning client
I'm not sure why you even need an RPC in the first place: No. of imposters could be derived from the amount of players in the PlayerState array and your player controller / player state are local
So why not just run this logic locally on begin play of the PC?
Clientside
cant do it on event begin play
Another important part of gameState is the namespace that gets replicated down for match events
Make use of that
So when MatchStarted replicates down
you can react to it
also the no of imposters happens to be in game mode
Make it a replicated variable in the GS
An OnRep one
And if that's the critical info you need before running this logic
Run it then
Rather than using an RPC
what is this?
what does it hold?
Time to do some googling ๐
yeah
that what i did when i asked
hahaha
but lets assume that to do an rpc
if i did it like i showed u above
the target is the one going to runs it , yes?
i mean if i got this client player controller from the server and passed it to the target
the target will be the client one not the server player controller
Yes
Hi, I was told to ask this question here. Iโve got a bunch of AI actors on my level that have a health bar and I only want to show the health bar if the player has selected one of these characters. Iโve already come up with a solution, and thatโs to store the selected actor on my player actor.
However, is there a better place to store this info? The tricky part is that these AI actors need to know if the local player has selected them in order to do some UI work. This info wonโt need to be replicated
Why not a simple bool? bIsSelected ?
gotcha, and i set that bool on the selected units?
Yes, clientside
let me throw another curveball
let's say that i want to show all of the health bars if the player presses Ctrl
where would i store this bool?
on the player controller?
No each AI will have its own bool
So you'd simply be setting it to true on all when pressing Ctrl
hmmmmmmmm
yea idk about that one lol
but i definitely like your bIsSelected idea
i'm gonna set that bool directly on the "units" client-side as i'm calling them for now
If you don't want to select all and simply want to view health bars, then you could have a secondary bool bIsHighlighted or something on each AI
yeah it's gonna be bIsHovered
for the Ctrl idea, does it make sense for these actors to be looking at the GetFirstPlayerController() and then checking a bool?
You also don't necessarily even need a bool if you correctly show and hide the Ui at the correct times
@grizzled stirrup this is very true. i was going to do this on tick
basically just check if bIsHovered
No need, just show the UI once when you press Ctrl, then hide it again whenever you let go or press ctrl again
Or however your controls work
so the problem is that the health bars are stored on the actor
i guess i should just make the health bars public?
feels weird
gotcha
That then will hide or show the UI
other actors won't need to know about the healthbar
yeah that's an interesting idea
and then what, when i select another actor how would i know to deselect the previous? do i keep a pointer?
You also could make the AI subscribe to a delegate that the player broadcasts when pressing CTRL
that way there isn't any direct communication
this is my favorite idea by far
this is a fantastic idea
yeah, i didn't really like having to iterate on all of my actors from the PC
i REALLY like the delegate idea
i think im gonna do that
That in general is bad yeah
delegates are bad?
right right
@grizzled stirrup it did not work
i have another question, but i guess i'll give it up for @grand stratus lol
thanks @grizzled stirrup
super helpful
i guess now that i have you i'll just ask
i've got some agro tables designed right now and they're working
but it feels fucking off. like, should i be storing agro tables on the game mode? probably not i think??
is there another unreal entity where the agro tables would be?
What is an agro table?
yeah i have like multiple players and shit
and they generate threat
and some players are more threatening than others
so i have a agro table, or a threat table
that keeps track of who is the most important
and the AIs then use this threat table
Have you set your GM to use the BP_Amogus class for the player state?
You could store this in many places: the gamemode, a dedicated AI manager, or any other level manager
from prject settings u mean @grizzled stirrup
You could also just do it per AI
it should live on the server though
got it
yeah i probably just need to have it per AI
GameMode is only on server plus you can easily gate a level manger to only run things on server
Also AI Controllers only live on server
No GameMode BP
i can't remember why the hell i added this functionality on the game mode... there has to be a reason
let me check
now that i think of it, this freaking sucks. i'm gonna change this. thanks @grizzled stirrup , back to coding!
Yeah that's correct so it should iterate through playerstates, log to verify
casting fails
so i log when it fails
it fails
@grizzled stirrup game state fails in cast
btw as i said this happens on client side and in user widget BP
Hi, how would you do a "position correction ogic" for pickups ? Like i'm dropping two items and i want them stack on top of each other and instead second pickup move to a defined distance from the first pickup
Im thinking about sphere traces to get all pickups in the player field and then get their position and take the one that will be close from the pickup dropping pos ?
But what if there is another pickup close from it, a third one ๐ค
I'm trying to get basic movement replication working. I'm trying it out with crouching. It's working when the player is the server but nothing happens when they'r the client.
What am I missing here?
Iirc crouch is already replicated through the CMC
You don't need all of this
It doesn't work for your client because you are executing it only on the server
The CMC replicates it through the flags it sends to the server each frame. So setting it on the server for the client is pointless and wrong
@tacit bough
Not sure what you are doing there but there is a high chance that your GameState on the Client is just not replicated yet. That's tricky to solve in BP only. Best thing you can do is check on tick in the widget if it's worth updating your UI based on multiple test (like did the playerArray length change)
Or you step into cpp and craft yourself a callback for when the GameState is available
yeah it is. I'm just using it as an example to replicate sliding movement later on. Probably not the best idea.
anyone know of an open source implementation of a master server (Server browser) for UE4 i'm using one from the marketplace i got a while back but it isn't written great i've had to hack and slash to get it to even work, it has no external IP detection so servers report the NAT IP if not public, also the plugin itself only supports IPs for exxample the master server connection is hard coded to the IP which i think is bad since that could change.. I know there was an old github project that used python to acomplish this but it is brokken for 4.26 just wondering if anyone knows of anything i don't
If you already have existing code (Unreal side and server side) it'll be easier to port that. Otherwise a master server can be 200 lines of Python, and 50 lines of C++ - you really just need to have a few basic requests go as JSON over HTTPS
"Hi I'm a server he's my IP and map and player count"
"Hi I'm a client what's the server list"
"Hey here's the server list"
Yeah the biggest code part is the handling of settings, player sessions, player count etc.
/Source/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/GarbageCollection.cpp] [Line: 885] Invalid object in GC: 0x00067f6f00067f6f, ReferencingObject: PlayerCharacterController /Game/AlWathba/levels/TourdeFrance/UEDPIE_0_TourDeFrance.TourDeFrance:PersistentLevel.PlayerCharacterController_0, ReferencingObjectClass: Class /Script/PhotonDemoParticle.PlayerCharacterController, Property Name: MyGameController, Offset: 1640, TokenIndex: 42
I've written a simple API server for this kind of stuff. It's incomplete and I haven't yet written a plugin for UE. Might inspire though. It's not open source yet but dm me and I'll send you what I have.
No other live object owned it through UPROPERTY
Why do you use an extra class/pointer though?
You change the player controller class in game mode settings
Is this a PlayerController?
wdym ?
So show the line in your game mode constructor
What you are doing there seems wrong. You don't need a pointer to the PlayerController
The GameMode has a class variable for it and spawns it for new players
All you need to change the PC class is one line in GameMode's constructor
That is automated
its not actually all my code
i am working on it in between
Look : the only line you need is in GameMode's constructor
No, it is not
MyGameInstance = ((UMyGameInstance*)World->GetGameInstance());
if (GetLocalRole() == ROLE_AutonomousProxy)
{
MyGameController = MyGameInstance->myGameController;
HardwarePlayerPower = 0;
HardwarePlayerRPM = 0;
HardwarePlayerBPM = 0;
}
and change my game instance
like it is test game instance
Okay, I have no idea what you're doing here so I'll leave it up
okay thank you
yes it will do
No, it's not, but if you test your multiplayer code in PIE you should expect the client to have terrible multiplayer performance since the server will run at like 1fps
Better test in standalone
mostly it happen you have test latency or it is happening due low frame rate
No
It happens because you have multiple PIE viewports and the ones you don't focus simply run at low framerate
Don't test your multiplayer code in PIE
No shit
okay
PIE jitter is a known issue
we never rely on PIE testing, always do standalone, proper internet tests.
PIE is just not a serious test case for multiplayer in any scenario
PIE is strange sometimes..
i was having the same issue but i solve it with syncting script
if it was a player, then its likely rubber banding due to corrections
it was rubber bending
Also in editor sometimes the extremely high framerate can cause banding too because the saved move buffer on CMC overflows
^
The point is that PIE will create an insane amount of rubber banding that has no relationship with reality
So just don't do PIE
Use standalone and test carefully there
Use pie to make sure things work, but never rely on it. Real world testing is the only way.
you can do it with LAN and multiple pc's, just setup a way to create some latency.
Or just use standalone with packet lag ini settings and you have 95% of real world issues
i still don't trust that, cause we have seen stuff we could not produce with any packet lag/packet loss in editor
and only happened in live testing
Yeah, of course
Replication races/connection issues, urgh, those were fun days debugging.
by the way it never worked for me until I use lerp or sync algo some kind
Just start with a serious setup in standalone with 50 pkt lag (which means like 130 ping) and you can safely develop your multiplayer code in a decent real-world approximation, without PIE bullshit, and with a joining scenario that's more likely to happen
No shit you need to lerp stuff
BTW, the ability to hot join into a running pie session, is good for rapid testing your stuff is working
shame not many people know how to turn on the "Add Client" button in UE4
it's rubber bending happen when cross the player
Where is that button?
see ^ point proven ๐

editor settings -> experimental -> Late join iirc
ye
then you can late join clients into a pie session
good for testing those OnRep's/states.
Yeah, very useful
OMG wut
has some issues, like randomly can crash, etc (might be fixed in 4.26+) but 4.25 has some quirks, but overall, its fine.
I never knew about that ๐
.. ๐
when i found it, it changed everything
honestly, when working on a multiplayer game, its so handy
making sure the client generated the same procedural map
was the big use case for it
Yeah can see how it would be useful for that for sure
even making sure the world state after things have been destroyed/blown up is correct.
"Things to test before shipping specifically" would be a cool post title for your blog btw ๐
how to compress a struct of location and rotation into binary data? I need to send this to the server
tried with JSON but it's way too heavy and I don't think it's the right solution
Well JSON is always going to be the worst way to send anything because it'll be strings
When you say server do you mean a UE4 server instance or something else like a MySQL etc?
If a UE4 server, just send it as a parameter of an RPC
sorry I mean Playfab backend...we use that one to store data
it's my first time with networking and compressing data
Oh no idea in that case RE playfab
but the struct serialization it's something I have to do in ue4 so...any way to do it?
Unreal has struct serialization built-in for USTRUCTs
any doc I can read? first time with this topic
You just need an FArchive of some kind to actually put the data in
well I'm more confused than before now haha
FYourStructType::StaticStruct()->SerializeBin(Output, &YourStruct);```
Assuming USTRUCT, UPROPERTY
I'm having the same issue, did you ever find a solution without having to directly use the Steam API?
I got a test variable / leaderboard to write but setting up a new one identically nothing happens
Did you ever find a solution to this without using the SteamAPI directly?
No I had to use steam
Ah it's annoying because I had it working perfectly using the Steam API but I'm moving back to only use generic interfaces.
Weirdly it works fine every time when calling it from the PC on begin play
But not in a session
I'm thinking that the SessionName passed into the LeaderboardsInterface->WriteLeaderboards func may be messing with it
Hello, is there a way to increase the size of the reliable RPC buffer
Please don't multipost
I was literally asked to ask here ^^'
Ah, right, nevermind then
no problem
since I work mainly with bp...where should I do this? In the game mode? into the struct directly? It's not so clear to me it's the first time
Im guessing ServerMovedPack and ServerUpdateCAmera are UE stuff I dont have control over
I'm not certain whether binary serialization is exposed to Blueprint, or what you'd do with binary data in general in BP
it's ok in c++ I just don't understand how to place this
You asked for how to serialize a struct into binary so I take it you have a struct, and binary output
I just need to compress this struct and send over to playfab ๐ I can't understand exactly how it to move the struct into bin
That part is the code I gave you, the variable Output is an archive storing the data
What do u mean that game state is not available yet for client , u mean it takes time to be replicated for client?, so should i delay?
Yes and no
Yes it make not have replicated yet
and no, this is should never be fixed via delays
Nothing in Multiplayer should
You can simply check that it's valid
Or you can have each value in the game state have an invalid default value, and don't do anything until each value is not invalid
okay

