#multiplayer
1 messages Β· Page 370 of 1
Same
And that was the fix that did it for me
I'm not sure if it's "Game", if I go to the variable definition in VAX it doesn't lead me anywhere sensible
UnrealNames.h
Oh wait, that leads to UnrealNames.inl
Which defines the NAME_GameSession as 287
Well, the FName index 287
I doubt hard-coding "Game" would result in that same FName index
So you probably ought to try with NAME_GameSession
Well
Usually you use "GameSessionName"
Steam only works with two different ones
Game and Party
You can't put anything else in there
Well yeah, but whatever the case might be, I tried "Game" and I tried GameSessionName, neither worked
NAME_GameSession worked for me
So I'm searching for a way to bypass the Server for a local client
Currently my customization data is set and replicated on Possessed
But the local client already knows its customization, however I'm missing an entry point to set that
BeginPlay can't be used, as the Pawn isn't possessed yet at that point
Like, a ClientRPC on Possessed is not what I want
I want the Client to know when he has the pawn
And instantly grab his local customization info
I COULD poll the stuff via Tick and check once the controller is valid
Buuuut, that's ugly
That's already the case
and have the local pawn grab it from there once it starts
But WHEN is the local pawn ready
BeginPlay, local, calls on everyone
I can't be sure that's the local players pawn
Only if I can compare it with controller or PlayerPawn, but BeginPlay is too early for that
Well actually
Someone points this out
Called when the Pawn is being restarted (usually by being possessed by a Controller).
I was gonna suggest your controller's BeginPlay bu that won't work either...
If not Restart, then I'm sure the game state has some sort of callback when all players have pawns assigned.
Hm, only need the local one to have that
I guess "Pawn" in the PlayerController might have an OnRep
But hm
Question is, how much faster is that than doing a ClientRPC
Do both and check logs
a few dozen times π
A small digression but, how does a client leave a Steam session?
Caling DestroySession has Steam bitch at me that I'm trying to destroy a null session
Usually exactly that, destroy session
I have that in my MainMenu LevelBlueprint
As I know that there, no session should be available
At least no game session
I'm trying to debug to see why it's not finding a session on the client but I have no idea how to attach my debugger to my build and actually have the necesary debug symbols load to break in OnlineSEssionInterfaceSteam.cpp
ListenServer?
Well, as said, you need to use GameSessionName
well, I have the listen server make the game and I'm trying to leave from a client
Hosting works, the client connects fine, it's just leaving that's the issue
hm, the IOnlineSessionPtr doesn't seem to have a way to iterate over all sessions
Alright, last question from me... if I dump session info I get this:
[2018.01.31-13.32.49:973][ 26]LogOnline: Verbose: STEAM: Member of 1 lobbies
[2018.01.31-13.32.49:973][ 26]LogOnline: Verbose: dumping NamedSession:
[2018.01.31-13.32.49:973][ 26]LogOnline: Verbose: SessionName: anDRey
[2018.01.31-13.32.49:973][ 26]LogOnline: Verbose: HostingPlayerNum: 0
[2018.01.31-13.32.49:973][ 26]LogOnline: Verbose: SessionState: Pending
[2018.01.31-13.32.49:974][ 26]LogOnline: Verbose: RegisteredPlayers:
[2018.01.31-13.32.49:974][ 26]LogOnline: Verbose: 0 registered players
Are the registered players significant and do I have to manually transition the SessionState once the game starts?
also @thin stratus - GameSessionName is literally just #define GameSessionName NAME_GameSession
Then it's "Game"
Is it possible to destroy actor only on client that was on map from the beginning?
Yeah, let the client call destroy
Should this work?
https://i.imgur.com/P1wZsSd.png
I'm surprised that my session dump shows the session name as anDRey then, since I used GameSessionName for CreateSession...
Hey cedric, have you ever used SteamNetworking()->SendP2PPacket and ReadP2PPacket?
Nope
If I am reading source code correctly, it's impossible to locally destroy actor that was in the world since level creation.
// Can't kill if wrong role.
if( ThisActor->Role!=ROLE_Authority && !bNetForce && !ThisActor->bNetTemporary )
{
return false;
}
such actors are most likely under server's authority
Can confirm. In blueprint I couldn't destroy level stuff from a client even they were not replicated
some guy told me it used to work in 4.8 (BP)
yep
u can only destroy it on the client
if it was spawned on the client
its very strange tbh
how difficult is it to implement an 'official' dedicated server that host multiple session instances, with steam OSS?
I'm using steam oss listen server right now, which is pretty straight forward
Unreal provides a very user friendly framework I can understand. That is, after I learn A, B and C I'll be able to create the design I planned.
But I can't really estimate the compexity for game server backend. Is two weeks enough to setup a very basic dedicated multi-session server on something like amazon gamelift? I have sufficient skills for web hosting and stuff.
It's adding to my anxiety pool :x
Hey there. I'm about to work on a Network system that need to be online so i would guess using the steam server would be simpler. Do i need to go through this ? (Using the Steam Work)
https://docs.unrealengine.com/latest/INT/Programming/Online/Steam/
Is there any documentation that could help me to go through this process ? It would be the first time i'll work on Networking on C++, not on BP.
An overview of Online Subsystem Steam, including how to set up your project for distribution on Valve's Steam platform.
Hey how can i resolve this error?
Error C2084 function 'UMyCharacterMovementComponent::UMyCharacterMovementComponent(const FObjectInitializer &)' already has a body
It says it "already has a body" but this function isn't duplicated anywhere, been trying to fix this for a while
here is a paste of the file
did you put {} at the end of the declaration in the header?
canΒ΄t make work when i pickup a item the item its destroy only the server
how i put work the item its destroy when i use the cliente and server
Anyone familiar with Multiplayer in Blueprints? I'm trying to make a Item Pickup Actor but I dont know how to give the Actor Remote Authority. I tried copying the functionality from a working Weapon pickup. I manually dragged in my new Item pickup into the Level but I am stuck because I dont know how to give it Remote Authority
Anyone had tutorials for Gamesparks?
@worthy wasp hey man just getting back to this after winter break. So you mentioned you resolved it by not using AGameMode, what does your solution look like? what other way could I manage player controllers and pawns with a dedicated server?
What got resolved?
@Slayder#0513 There isn't much to tell about UE4 and GameSparks. Check the GameSparks docs.
Their UE4 plugin comes with the same functions/nodes.
@fierce oriole You need to call "SetOwner" on the ServerSide and pass it the specifics client PlayerController/Character
@full scaffold How does the Header file look like?
@thin stratus I think I got it fixed!
It had to do with constructors, had to create my own constructor for a class
I'm about to do some more tests, if it still is giving me trouble I'll post back here. Big thanks to #cpp for helping me out!
@thin stratus Thank you. I would declare that inside the pickup actor correct? Oddly the other existing and working pickups (from Generic Shooter) arent doing SetOwner that I can see.
Well, why do you need the Client being the owner?
You usually only need that to call RPCs on that from Client to Server or Server to specific (owning) Client
And that's usually not what you do. When you create a pickup system, you want to make sure that you call a ServerRPC in your Character/Controller, right after pressing the PickUp key
and then from within the serverRPC you perform your pickup code
Tbh Im trying to replicate the existing Weapon pickup behavior to my new Items, so I'm not sure why lol becuase Im barely learning Network stuff. This is the part in question, which fires when trying to pickup a focused item, which works on the existing weapon pickups
@thin stratus it's regarding game mode and client pawn possesion in dedicated servers. my clients can't process input when running a dedicated server to host them. a listen server will allow input to clients just fine. very weird. I asked walldiv a while ago but he said he moved on from this problem.
@soft hamlet That is indeed weird. There shouldn't be a difference in DedicatedServer or ListenServer
@thin stratus yeah i tried many combination, packaged games, editor games, listen and dedicated servers for both of those. same outcome apparently, but my game was using the generic gamemode class with super::postlogin, i also changed it and added my own client restart RPCS there, nothing seems to enable input to get through to the pawns. they're static if dedicated server is hosting. tried looking player controller uniqueIDs on console and they keep changing all the time on both dedicated and listen server so that didn't tell me anything.
Can someone help me with making a multiplayer resource gathering system?
Anyone dealt with old rep notifies being called when an actor gets loaded on a client when you move close enough to it?
Or even happening if you disconnect and reconnect. the rep notifies that were being sent as you disconnected all fire when you reconnect
does anyone know how to display players name that they saved to show on widget?
@unborn nimbus that is how repnotifies are supposed to work or im misunderstanding your problem lol
calibur . you need to save the name into the player state or another class . then set the variable on the server . make it repnotify and have each client set the playername
@opaque tinsel
im afk but if you're still stuck tonight i can send you screenshots
hey i shouldn't have to define _Validate and _Implementation versions of replicated ufunctions in my header files, should i?
because the compiler thinks i should
but then when i add it, it complains about that too
No, you don't need to have them
And the compiler shouldn't say anything
What's the error log from the compiler output ?
@bitter oriole if i don't include them, i get a whole bunch of errors about the Validate and Implementation functions not being a member of my class
that's if i don't include them anywhere, even in the cpp file (which is wrong, yeah)
but i still get them even if i do include them, and more (along the same lines)
and by "include" i mean define or declare in this case, just to be clear
because i also #include net/unrealnetwork.h
i'm guessing i'm either doing something really dumb, or it's because i'm doing it on an ActorComponent
@small temple Can you quote the compiler output ?
To be clear, you need to declare the method in the header (without _Validate/ _Implementation)
And you need to implement both _Validate and _Implementation variants in cpp
@small temple Intellisense is likely to complain that the methods are undefined, too, so do compile to check
@bitter oriole https://hastebin.com/raw/asahitagix
Move the body of both methods to the cpp
Yes, with "```" around it
what i doing wrong
Three ` symbols
dun dun dun
BTW, just copy what's at the very bottom here : https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Actors/RPCs/
Designating function replication across the network
ahh
The two last code blocks are what you need to have
so i've got this in my header: UFUNCTION(Reliable, Server, WithValidation) void SetServerPosition(FVector Location, FRotator Rotation);
and this in my cpp: ```void UPhysicsReplicationComponent::SetServerPosition(FVector Location, FRotator Rotation)
{
GEngine->AddOnScreenDebugMessage(0, RepToServerRate, FColor::Green, TEXT("Server position updated"));
GEngine->AddOnScreenDebugMessage(1, RepToServerRate, FColor::Yellow, Location.ToString());
GEngine->AddOnScreenDebugMessage(2, RepToServerRate, FColor::Blue, Rotation.ToString());
}
bool UPhysicsReplicationComponent::SetServerPosition_Validate(FVector Location, FRotator Rotation)
{
return true;
}
void UPhysicsReplicationComponent::SetServerPosition_Implementation(FVector Location, FRotator Rotation)
{
}```
ah?
UPhysicsReplicationComponent::SetServerPosition shouldn't exist
Move its content to SetServerPosition_Implementation
hmmm
SetServerPosition_Implementation is the method itself
SetServerPosition_Validate is the checker
SetServerPosition itself is not really defined
Well, really, it's defined as "if validate() then implementation()"
So you did remove ```void UPhysicsReplicationComponent::SetServerPosition(FVector Location, FRotator Rotation)
{
GEngine->AddOnScreenDebugMessage(0, RepToServerRate, FColor::Green, TEXT("Server position updated"));
GEngine->AddOnScreenDebugMessage(1, RepToServerRate, FColor::Yellow, Location.ToString());
GEngine->AddOnScreenDebugMessage(2, RepToServerRate, FColor::Blue, Rotation.ToString());
}
GENERATED_BODY()
i'll try
without Reliable i get an error saying i need to have Reliable or Unreliable so i'll try that now
Yeah I was confused because I write Server, Reliable, WithValidation but that's exactly the same, sorry
You do include the .generated.h file too I guess
in the header, yep
Can you share the header ?
Looks fine Β―_(γ)_/Β―
And the error is still on the GENERATED_BODY ?
At that point I'd remove the intermediate folder, the .sln, re-generate project files and do a clean rebuild. Kind of nuclear solution but it looks like you have a problem with the generated code
k
wait because that is pretty nuclear, lol
but yeah i'll give it a try
meanwhile, are you sure it has nothing to do with this being an ActorComponent? @bitter oriole
I am, since I have basically exactly what you're doing myself
ah
Network physics component
nifty
Well, fake physics, anyway
yeah i did it in blueprint before so it's a silly question actually
One thing I don't have is a server method with two parameters but surely UE4 isn't that broken
i guess i should build my project without the server function first yeah?
actually, no
never mind that
the point is, it fails to compile
Again ? Same issue ?
seems like it
it's hard to tell because c++ error logs are fucking incomprehensible but the first error in the output log is this so... PhysicsReplicationComponent.h(14): error C2039: 'SetServerPosition_Validate': is not a member of 'UPhysicsReplicationComponent'
Try with one parameter ?
alright
should work with 2 though, since it works in bp
but maybe some other magic is required
Dunno, I usually pass structs myself
doesn't work with one parameter
Yeah, I figured... Can you share the cpp too ?
Sounds like you did it well but I don't know anymore π
You'll want SetIsReplicated(true); in the constructor I guess
i'll be damned if that's it
I wouldn't expect it
nope, that's not it
Why does the header require two params but the validate and impl only have one?
(sorry coming in late)
the header is old
He tried changing to one since that yeah
i removed the second param since then
Ah, I see!
I'm super confused here, it all looks correct
yeah π€·
That's super maybe territory
haha absolutely
doesn't look like it matters in other examples
But, alas i've seen stranger things
I'd just comment out all the code and paste the doc example
(good show)
void SomeRPCFunction( int32 AddHealth );```
i'll try that
{
if ( AddHealth > MAX_ADD_HEALTH )
{
return false; // This will disconnect the caller
}
return true; // This will allow the RPC to be called
}
void SomeRPCFunction_Implementation( int32 AddHealth )
{
Health += AddHealth;
}```
Well, you're going to need Reliable, so even that doc is out of date
i'll build first, might take a minute
oh it was fast actually
it's weird how it doesn't define (?) the namespace
So move back to your code bit by bit ? Start with one int32 parameter , etc
will do
i bet that'll be it
nope
oh hold on, made a mistake
mmmm, interesting
so i kinda messed up in my test here but i changed the parameter to an int32 and also commented out one of the prints in the implementation function
then i compiled, and it worked
now the weird thing is, i reverted those changes and it still works
so it was either the print function that was causing a problem, or the parameter type
i guess they were somehow stopping the compiler from generating the generated.h
and declaring the Validated and Implementation functions
and now that they're generated, it doesn't matter anymore
Strange
very
someone ought to file a bug report
someone who knows more about this stuff than me π
Hey guys. Is it possible to destroy actor on server, but keep it in the world on clientside?
Trying to make this, but Actor still destroys on client.
try disabling replication on the client as well? @wary wyvern
btw @bitter oriole do i call this function with SetServerPosition() or SetServerPosition_Implementation() now?
SetServerPosition()
great, thanks
@small temple It is a server function. It wont execute, i guess
What do u mean?
right-click > custom event > set it to Run on server
in that event, disable replication and destroy the actor
then call it after your delay
also tick the Reliable box
the authority check can be a bit finicky iirc @wary wyvern
i'm not sure though
it shouldn't really matter because SetReplicates executes on the server anyway, but you never know
The authority check isn't finicky in the slightest
@grand kestrel you're not finicky in the slightest β€
Anyone know of a good resource for inviting friends and / or joining a friend via Steam without them having invited me?
Hm, given you have the Friendlist ingame
You should be able to do "JoinSessionViaFriendID" or so
So when I am in my game, and I turn on the steam overlay, right click on a friend and do "invite", their game gets a delegate fired for that?
Does that delegate get fired even if their game was turned off at the time of accepting the invite (i.e. after Steam automatically launches the game?)
right-o
Ehm
I should be things like these
SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle
SessionInterface->SendSessionInviteToFriend
Not 100% sure anymore what is all involved
But as seen above, the SessionInterface has delegates and functions for that
They all work similar to the normal Create/JoinSession stuff
The first step is getting the friend list in-game, after that I'll poke around and see what's there. I doubt there are many pitfalls in there.
There I have a tutorial for
Check UE4s official Streams
I was hosted once for that
oh neat
Getting your game working with Steam is frequently an important part of one's development cycle. Cedric will begin with a walkthrough on how to integrate the...
That one?
Yus
Thanks
The best advice I ever got regarding any sort of video tutorial is to watch it at 1.5x speed
or 2x
Yeah, I'm generally not a fan of video tutorials π
yikes
i'm trying to replicate a property and i'm getting this error: error C2065: 'OutLifetimeProps': undeclared identifier
along with more errors after that as usual
i've got #include "Net/UnrealNetwork.h" in my header as well as this UPROPERTY(Replicated) int32 Doinks;
and this in my cpp ```void UPhysicsReplicationComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty> &OutLifeTimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifeTimeProps);
DOREPLIFETIME(UPhysicsReplicationComponent, Doinks);
}```
anyone got any idea why?
OutLifeTime
oh, GetLifeTimeReplicatedProps is also declared in my header of course
capital T
I still struggle on finding a proper way to setup data before a player joins
The stuff from yesterday?
On GameMode::Login I get a PlayerID. I used that instantly to retrieve customization data on the Server for that Player.
In the Character Possessed, I used that Data, stored in the PC, and set that on an RepNotify
But race condition between Possessed nad the data retrieve event
I hope possessed would be later, but it seems it calls in between
-.-
Now I moved all the "get customization" stuff to each instance
damn
And replicate the ID to the players instead of hte customizations
I don't know what class I can use to properly set this up
I grab the ID as soon as the player logs in and gets a PlayerController
So that's already the soonest
Well, the way I do it, and the way it works for me, is that I have my loadout and customization inside my player state. In my Pawn's OnPossessed I fetch that from my playerstate and send it across with a multicast to everyone. Each client then just instantiates all the cosmetic items, abilities etc.
oh
Cause sometimes the PlayerState didn't get the stuff before Possessed called
How do i remove instanced static meshes for all players ?
@ripe raptor But that isn't optimal either
As I don't want to do that every time the drone gets respawned/possessed
I might just offsync the possess
And let it wait till gamesparks returns data?
Well, it is optimal if it's the only option π
That being said, and this is a silly suggestion probably, but what's stopping you from doing this:
Your game mode gets the ID, fetches the customisation, assigns it to your player state. Your Possessed event reads the player state, gets the customization from the player state and stores it in a class variable of its own which is then replicated and should be usable in OnRep on all clients?
I can already store it in the PlayerController
Since I replicated on the drone, I don't need the PlayerState
But yeah
I currently use the native ue4 spawn system
That's why I didn't want to do that yet
Well, can't you do a combination of RPC-ing the customisation in OnPossessed with late-joining clients using BeginPlay and reading the data from there (It seems that all replicated data is available at this stage in pawns)
Why would I. OnRep is totally fine for that
It's more about the time between GameSparks callback and possession
Server asks GameSparks for data but the Client already gets his drone before he gets the customization data
Ooooh, now I get it, sorry, all this time I've been wondering where the delay comes from
How do i remove instanced static meshes for all players ?
@thin stratus I had this problem so I set a timer by event on my event OnPostlogin with a branch . It grabs the joining controller casts to playerstate and just checks if the data is valid yet if so it breaks out of the loop. Clears the timer and carries on as normal . During this time I just show loading screen .
Yeah I do it with a boolean and a dispatcher
What about overriding prelogin?
Yeah that too
Will show the system once working
Idea is basically this
With this in the Controller for loading the data
The thing I find hardest is knowing when to use what. I swear nearly everything is an interface/dispatcher or repnotify but I fear I'm overusing stuff maybe or doing things wrong . But as long as it all works for now I'm happy lol
So if the boolean isn't true yet, I just subscribe to the Dispatcher
And wait with the spawning
Also enabled "spawn Player as spectator" in the defaults of the GameMode
Let's see if that works
@worn nymph I think you misunderstand what's happening. The player stands in a group of enemies and takes enough damage to be killed. OnDeathEvent gets called and replicates to all clients through the rep notify. Player clicks respawn and respawns at the respawn point. Player moves back to the enemies that landed the killing blow causing the OnDeathEvent to be called. When that actor the landed the killing blow loads on the player's client, the rep notify gets called again.
Whats the proper way of turning a specator into a normal player?
Cause Spawning an pawn and possessing it doesn't work
@unborn nimbus OnReps always fire if you get into the distance
That's what OnReps are for
C++ has an "OldValue" to compare to
In case you re facing double OnRep
BP though not
Yes I understand that, but there should be no old value
everything should fire and succeed and be done when the player dies
there shouldn't be waiting rep notifies when the player returns
i think changing from spectator to normal player is just ChangeState(NAME_Playing), then spawn and possess as usual
it calls EndSpectatingState, which destroys spectator pawn, sets bIsWaiting to false and bisspectator on playerstate to false
Yeah, currently BP only GameMode :/
Guess I could expose that
It will spawn the default pawn then?
dont think it will spawn anything, just set player state to playing
after which you can spawn/possess like normal
Hm will test! Thanks!
yeah ive been struggling with the whole spectator/inactive stuff myself
it seems very messy
trying to replace it with my own spectator system where gamemode handles it instead
more convenient with collections of activeplayers and spectators
Everything works so far with specatating
Just going to playing again didn#t out of the box
Will expose the Change event to BPs
And test
aplyercontroller's BeginPlayingState is empty
Yeah it's okay, will just call RespawnPlayer
ye, should do it
there's also the pc's inactive state, which starts a timer that calls UnFreeze after minrespawndelay
kind of a hassle reworking all of this into a round-based system
For now it would be enough to revoke the spectating
I only need that whole thing to delay spawning
Shouldn't last longer than a few ms anyway
But cleaner to handle longer outage
Is there a pre-processor macro to know if Steam is actually enabled in a project?
hello
how i put when i pickup a item the item its remove from level
i only can put work if its the server
and not the client
this channel here is so bizarr ._.
@manic pine Any idea what "Name_Playing" is actually?
Na, will just make two functions /shrug
Still can't spawn. My goodness
"Start Player As Spectator" and "MustSpectate" setup.
Then, when it's time to spawn, MustSpectate is false, State is schanged to Playing. Still not possessing
Let's delay a frame
Well, Spectator Pawn gets properly despawned. My possess stuff doesn't work though. Hmpf
I can't believe there is no paltform independent system for getting friend avatars, meh.
@thin stratus - Hey, I know you're busy with your customization thing, but I have just one small question regarding the stuff from your video
yo
Just the #include <steam/steam_api.h> bit
I suppose I need to use the same steam SDK that my UE4 installation is using?
and I suppoes I need to add that sdk folder to my VC include directories?
All steps for making steam work are in the video though
Okay, so one thing I noticed is, that "NumPlayers" and "NumSpectators" never got reduced/incremented
So I did that now and it properly starts the match
But I still can't possess the damn pawn
you asking to posses on the client or server?
All Server
put a onpossed on the pawn and see if its ever triggered
maybe its being kicked out straight away
Already have a print for Possessed and Unpossessed
Both not happening
The Pawn itself spawns though
is the actor replicating ?
It must be some kind of protection
is there a bool on state or something that specifies if its a spectator
maybe you need to turn that off first
or the player controller
there you go
you probably want to set this to false before trying to posses a player pawn
Already doing that
void AHLPlayerController::K2_ChangeStateToPlaying()
{
if (GetStateName() == NAME_Spectating)
{
AGameMode* GameMode = Cast<AGameMode>(UGameplayStatics::GetGameMode(this));
GameMode->NumSpectators--;
GameMode->NumPlayers++;
ChangeState(NAME_Playing);
}
}
void APlayerController::ChangeState(FName NewState)
{
if(NewState != StateName)
{
// end current state
if(StateName == NAME_Spectating)
{
EndSpectatingState();
}
else if(StateName == NAME_Playing)
{
EndPlayingState();
}
Super::ChangeState(NewState); // Will set StateName, also handles EndInactiveState/BeginInactiveState
// start new state
if(StateName == NAME_Playing)
{
BeginPlayingState();
}
else if (StateName == NAME_Spectating)
{
BeginSpectatingState();
}
UpdateStateInputComponents();
}
}
void APlayerController::EndSpectatingState()
{
if ( PlayerState != NULL )
{
if ( PlayerState->bOnlySpectator )
{
UE_LOG(LogPlayerController, Warning, TEXT("Spectator only UPlayer* leaving spectating state"));
}
PlayerState->bIsSpectator = false;
}
bPlayerIsWaiting = false;
DestroySpectatorPawn();
}
BeginPlayingState does nothing
Yeah well
I don't know what that should be :/
PlayerState->bOnlySpectator = false;
bPlayerIsWaiting = true;
Guess there were more booleans epic didn't reset
...
bit of question, im trying to get my gun module to replicate the data table of sounds/names etc across all clients, i've got a custom event for the "fire" in the componment thats on the MasterCharacter leading into https://gyazo.com/2f9c2e8afa78fa1f474d091148470f9a
yet when gun fires client returns the printstring empty.
nvm im a dummy,
needed to pass Weapon data thru the multi cast π
@thin stratus hmm, looking at playerController::possess, it actually does a ChangeState( NAME_Playing ) itself
the checks i can see that can fail a possess are: !HasAuthority() or !( PawnToPossess != NULL && (PlayerState == NULL || !PlayerState->bOnlySpectator) )
so not authority, null pawn, or a playerstate with bonlyspectator true are the three conditions that can fail a possess call
i think bonlyspectator is only meant to be used for players joining purely as spectators
e.g. spectators at pro matches, who can never actually join the active game
Well that's the thing though. It only works if I set "MustSpawnAsSpectator"
Setting the boolean for "Spawn is spectator first", it doesn't actually do that
Only with the MustSpawn it properly not spawns the Player
And then it flags him as "Only Spectator"
ah yes, the silly default implementation of HandleMatchStarted asks CanRestartPlayer on every player controller in the world(including spectators)
which in turn asks PC if he can restart, which says yes unless bOnlySpectator is set
if you were to override APlayerController::CanRestartPlayer with a condition that checked spectator state instead of bonlyspectator, that should do the trick
@thin stratus so you sorted it?
It's in testing now
ok
i am currently figuring out why UE adds like 30ms to my dedicated servers ping, testing different net tick configs atm π
Didnt get a reply from epic about it https://forums.unrealengine.com/unreal-engine/feedback-for-epic/1414496-example-networking-config-from-epic-games
"NetClientTicksPerSecond is used to throttle how many clients are updated each frame, hoping to avoid saturating the server's upstream bandwidth, although"
Documentation in source isn't really detailed
it's used here though: float ClientUpdatesThisFrame = GEngine->NetClientTicksPerSecond * ( DeltaSeconds + DeltaTimeOverflow ) * ( LanPlay ? 2.f : 1.f );
Ok seems like NetServerMaxTickRate clamps the servers tick rate on everything
Ok then it's used 'ActorInfo->NextUpdateTime = World->TimeSeconds + FMath::SRand() * ServerTickTime + NextUpdateDelta;'
ServerTickTime is NetClientTicksPerSecond
"This also means all other connections will force an update (even if they just updated, we should look into this"
It is at 30 tickrate, when i ping the server directly with cmd i get like 50ms, ingame i get 85-90ms
it's not saturated in any way
ive done netprofiles etc
just seems like UE adds ~30ms onto the actual ping, i am wondering if i should just offset peoples pings to show a more realistic number
well 40ms would be worst case if running at 25 fps ye
in addition to travel distance ping
so if you up server tick rate(and it can actually manage higher fps), you'd lower added ping
im doing mine at 100, but im building a fast paced mp fps
which just feels much much better with high server fps
im doing open world 50 player server
yeah, wouldnt go too high with that amount of players
fortnite is at 30fps i think
maybe even lower
yeah i hit some issues with CPU at ~40 players, so i have been rewriting a lot of my code
as there's AI in the world too
And i have like 3000 replicated actors spawning / despawning constantly
that does sound heavy
yeah haha
its possible youre simply cpu limited and not actually reaching the 30 tick rate
i've done profiles, but you know what they're like.. cpu stalls throw it all off
guess you could do a print from the server to tell you the deltatime
yeah, the ping should really just be regular network ping + whatever deltatime is
no, cuz players are interested in the effective ping ye
hmm
doesnt matter if you have 10 ping but the server uses 100 ms to respond to commands
thats the same as 110 effective ping
youre using the regular playerstate ping ye
yeah, it can lag behind for a few seconds if ping changes abruptly
5 seconds to catch up entirely
it messes up my lag compensation ;|
oh well, player's fault if they have unstable connection
lol :p
I tried in blank project and i still get like 20ms added
i guess default server tick is 20
hmm that seems excessive though... are you doing pie?
nope built
i built the server, put it on a VPS
blank third person project
all default
i ping with cmd, get 50, net stat get 70-80
could the vps be adding too?
i have a local linux box which i want to try
yeah, i think trying different hosting would be a good idea, just to rule it out if nothing else
actually no i tried amazon ec2 and it was the same ping
ooh
increasing tick to 45 reduced it
its spiking around a lot though
but overall is lower
yeah working on stabilising it
ideally it would be able to keep the same fps constantly
better with stable ping than lower ping
so if it cant run 45fps smoothly, 30fps would be preferrable despite the higher ping i'd say
reduced? you mean it was higher?
ill turn off AI and see
but it was interesting when i was doing stress tests, the more players the higher the ping got. But I assume that would be because of the CPU bottleneck
yeah, lower fps for every player it has to service
Seems like AI wasnt the cause of the spiking of ping
so ill turn AI and item spawning off
see if it becomes stable
items are spawning just like that? e.g. no detecting player presence or stuff?
the AI have radius checks, but items no
it constantly keeps 3000 items around the world
ah right, but it doesnt keep spawning after 3000 has been reached
so there should just be an initial spike
yeah and my math for spawning is pretty optmised atm
alright so i turned item spawning off and no major spikes
sitting around 68 ping
64-68
so thats 18 ms~
servers at 40tick
going to turn graphics up and see ping impact now..
ok 30 fps on client = 80-84 ping
yeah but thats to be expected
keep in mind most games will just show you the network ping
yeah but im not sure showing them actual ping is a good idea, because you know what people are like lol
bar?
like call of duty did
oh true
like those cell phone bars ye
yeah lol signal
just define a playable ping by yourself testing with someone
who knows, maybe in your game 95 ms is 4 bars π€·
ye, depends very much on the game and lag compensation etc.
yeah well i have my net code pretty good, like i do stuff on client for reponsiveness etc
so player doesnt feel the ping
i can play with 300ms and still play alright
apart from some very little rubberbanding due to movementcomp speed changes
If you have time or want to expand your netcode of this project on a future
I would suggest double approach for certain ping thresolds
server side/client side as BF1 did
you mean like both delay and compensation?
ive seen some games if ping > X, delay shot by 100ms then do regular compensation
yes, at high ping, I believe it was around 110 or 120
why do it that way if you can do it in the server straight away π
i still verify bullet traces on the server
but i use the clients trace if the server completes the verification
so much can happen if the shoot command is still in transit to server
anyway, at a certain ping point it becomes impossible to make it good for all clients
thats the thing, If you have high ping, you should deal with it, not others.
best to punish the high pingers
yeah, i know this other game which has some kind of...weird compensation ping
if a single bad ping guy joins the game, everyone has to deal with absurd lag compensation
lmao
as a result, brazilians and north americans are hated in the entire player base
you can always ping lock, but me being in new zealand, i know what it's like being locked out from playing with international friends
and actually games like PUBG, most of their playerbase are chinese
ye, better to just delay the shots from the highest ping players
but a lof of their chinese playerbase play on US and UE servers
and indeed, this is a problem
"unlagged" rails + high ping = around the corner death - Clipped by acidreign3
or you'll have good-ping players running behind a wall and getting shot a full second later
So i changed the config on the server to 20 tickrate, getting 84 ping now
anyway you'll have to experiment to find a solution that makes good sense
UT is at 60
30 should be fine unless youre doing high paced fps
yes
yeah true
that will mess up your lag compensation
all my players are like "where are you servers, i get such high ping"
and im like.. well uhh UE adds it's share + network time
i think it might be better to just show them the net ping
LOL
thats why I wouldn't manual compensation for high pingers
tsk tsk I'll screenshot π
thats a 10ms add ye?
thing is that you are alone in the server
true
very nice
the more peeps you get into it, the more you will notice how 120 will β
but these investigations will help others too
yes for sure!
at least now you know everything is working correctly
as I say always, write about it!
lmao
write your findings somewhere and documment them
are you using assets for things like decals and footsteps?
huh?
hes just spawning player items i think
every 0.25 seconds an item spawns
oh ITEMS!
up to 3000
i though players haha
yeah lol
huh that shouldnt cause an issue
should be able to do a dozen spawns every tick without much fps impact on server
well that depends what is the item doing
well items have a mesh
yeah, if it has to load assets and stuff as well i guess it could hurt a bit
nah for an item is fine since it just holds some materials
in the case of a character with footsteps and everything going on is a bit more harshing
footsteps are easy
items have a mesh, but do they have any code?
yes items do
is there any reason not to just spawn them all immediately though?
separate the "usable item" from the "world item"
at a rate of 1 per 0.25, players can search through an area, not find anything, then have it spawn as they leave
oh
can't you pool it somehow?
not a BR game where u can just spawn and be done with it
instead of destroy it and spawn it?
pool it then
on construct of the items they create a shape based off the meshes bounds
hmm this is still not sounding very intensive though, unless that item logic is insanely complex
so they can use unreal's 'try adjust location if overlapping'
construction and destruction are expensive operations, if you spam the hell out of them of several Actors (idk which is the rate @raven holly 's working but have that in mind)
yeah but one item per 0.25 seconds
yeah i've been profiling etc, all that is causing hitches now is some physx sync
4 a second shouldnt be noticeable
ok, now I understand more
do you rely a lot of physics on your game?
the items simulate physics
but only on the clients
they used to simulate on the server, but yeah it caused server crashes
that could give you offset problems
hmm then why is item spawning causing physx problems on server?
it's called 'sync' hold on ill find it
that could happen
yeah it's an .. what do you call
I call it a bug
compromise
hehehe
whats the word
haha
lol
compromise is good ye
ayee I guess it is
like if it's in 2 different places but not by much its ok
i dont know, it could get annoying in some cases, but for 99% of cases the items will be almost at the same place
the fringe cases will be weird though
one client sees the item at the base of the cliff, the other sees it at the top
yeah has happend on top of buildings
it could go even worse, if the item has bounciness each client will simulate their bounciness version
projectile + physics
so 120 tick, with item spawning 60-80 ping
I had to totally disable physics on a multiplayer project I'm on, people were like "BUT WHYY" - I reprogrammed a light version of faked physics under the premise that clients cannot kick an ammo pack π
poor ammo packs
ye
I gave them an oportunity
automatic ban on kicking an ammo pack
but it's sad anyways, they live only for 30 seconds
a short life ye
when you forget item code for water and you need to try survive when testing 
ayyyyy
ok doing some profiling
i rarely understand this profiler
sometimes its obvious, but more often than not it just tells me "something is wrong"
which i already knew
what did you call this physics thing it was doing again?
but you didnt have physics on the items on the dedi ye?
thats a large amount of physx going on
this is an average frame?
im doing a few profiles to see
im pretty sure it did this even without anything running
like no ai or items spawning
hmm youre sure the items youre spawning have SimulatePhysics turned off?
yep
how are you turning it on on clients?
with autothority ye
ofc π
without**
if!hasauthority -> turn on
right
could it be affecting path finding
e.g. you spawn object, it recrates nav map or some such
caneveraffectnavigation i think its called
pretty sure i disabled that
i do use realtime nav
Thats basically all the logic it has
ok thats with no items or AI
average
with items
but its not simulating π€
i havent tried it myself, but isnt that something you additionally have to activate per actor
I've got a simple setup where I shoot a projectile and then have the ability to pick it up. It works great about 60% of the time. The remainings times the projectile either stops too early or goes too far on the client resulting in the object not actually being where its supposed to be. I have bReplicates and bRepilccateMoevemtn set to true but I think i'm missing something more or do I need to aggressively combat desync in some way? I'll need the position to be as accurate as possible later on in order to dodge the projectiles
I believe I am
from what i can see it looks like the client is incorreclty assuming physics
Try using the ProjectileMovementComponent instead
what do you need to do when making a online game?
what are the steps
first, make.....?
hiiiii
is that a question?
jep
@twin juniper https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/OnlineNodes/ maybe that will help you?
Describes the different kinds of Online and Error Related Blueprint Nodes.
correct the "hi I....." sentence. letters missing
Problem solved π
For testing purposes can I disable client prediction for the projectile movement component?
Or any thoughts on making it more accurate in general
it seems to be predicitng stuff that isn't accurate, when my projectile hits a wall sometimes the client think it bounces further than it actually does
dang the amount of times friggen begin play trips me up on a replication issue. i always forget it gets called for both server and client lol
This is my functionality for dropping an item in my game (Dedicated server)
The system works perfectly fine when the delay is removed, when playing as server.
The system does not work without the delay when playing as a client as the items only refresh after an item is dropped (So effectively you can spawn two items before the node is removed from the inventory)
If the player drops the item, then closes and opens the inventory, the inventory will show that item has been removed.
I've added the delay and its fixed the problem - Its hacky, but its a temporary solution.
Does anyone know why this error is persisting? I spent about an hour today with my lecturer and he couldn't figure it out either.
@icy nacelle You need the Client to remove the item from the inventory locally before you send the RPC to the server
I've tried to cast it to the client on the second sequence pin, and it still doesn't work.
The RPC should also return to the client an verification step that lets the client know that the operationwas successful
Also tried to cast it straight after the 'Remove from Inventory'
RPC it to the client***
Your client needs to "assume" that the Server will eventually remove the Item
So the Client does it in advance
Locally
This removes the perceived effect of lag
why is your create inventory a rpc to server?
@mild hull I just noticed that, probably did that a couple months ago when I first created the inventory, and didn't know as much about RPC...
Okay @fossil spoke, so
pin 0 - server rpc for dropping item + remove from inventory
pin 1 - Remove from inventory
pin 2 - refresh inventory panel
???
Sure sounds right, you will need the Server to RPC back to the Client to tell it whether or not the Item was dropped, because if it wasnt then you need to readd that item back to the inventory.
You dont want players to lose items π
Okay, but if I'm removing the item from inventory twice, doesn't this mean the second time its just removing it from an empty array?
So your Inventory is completely Server side?
Nope, inventory is client side
Then how/why are you removing items from your inventory on the Server then?
I think I sometimes confuse myself with RPC. God knows why I'm making a multiplayer game aha.
I thought that when you remove the item while RPC server, it removes it from the player, but does this with the server's knowledge to prevent any cheating?
Not exactly lol
So the idea of an Server Authoritative architecture is that there is an single governing body (the Server, can be another Player which is an Listen Server or it can be an Machine which is an Dedicated Server it has no GUI at all) and then other bodies connect to it and attempt to "Simulate" whats happening on the Server as best they can.
Each Player in an Dedicated Server is Simulating what the Server is doing, this is what Replication is.
The Server is telling each Client, "Hey something changed, this is what it is, update this on your end please"
This means that the Clients have an copy of everything (almost) that is on the Server
Yep, I understand that part
Clients can modify their version of the Simulation as much as they like, but the Server has Authority over them if something changes on the Server.
This is how Clients cant cheat an effect the gameplay experience for other users.
Because they can only modify their own Simulation
They need to ask special permission of the Server in order to change something (Client to Server RPC)
This is also why variable replication is an waterfall, only the Server can cause an variable to replicate down to clients, clients CANNOT replicate up to the Server.
So if Clients are simulating whats on the Server then that means they have an copy of whats on the Server.
If you have an Inventory for each Player on the Server Side version of the Player, then the Client should also have that same Inventory locally.
Because they need to Simulate it themselves in order to see whats going on.
If an Client wants to drop an Item
He needs to do the Drop locally and then tell the Server "Hey i just attempted to Drop this Item out of my Inventory, can you please do that for me and send me back the result" (Client to Server RPC, then an Server to Client RPC reply with verification)
If the Server sends back an negative result, as in the Drop operation was denied by the Server, then the Client can safely go ahead and update their Simulation again by adding the Item back to their local inventory.
If the Server accepted the operation, then all is good as the Client had already removed it locally and the Server has updated its Inventory.
Does that make sense?
crystal clear.
The hardest thing for most people to grasp is the concept that both the Server and the Client have the same "version" of the game running. As in that both the Server and the Client has the same version of each Actor etc etc
I am with them on that one π
Good. Its tough if your new to this type of concept as it can be pretty abstract
Thanks for the help, I've saved everything you said so I can re-read it until I fully understand!
Another bit of advice. If i was you, i would build your Inventory as an Actor Component.
And attach it to your Player Controller
Yeah, I think I stumble a lot on replication. Cedriks compendium is good, but its sometimes difficult to get specific things right.
Yeah, I have been thinking about moving the inventory system somewhere that isnt the character.
Modular code is much much easier to maintain
Seperating specific functionality out into an Component is an ideal solution
how would i add a kill score?
Probably add an Integer to the PlayerState would be the most ideal solution.
Kills
Deaths
Points
PlayerState already has an inbuilt Score variable
@fossil spoke you really do that with replicated vars?
i just tell the server to remove the index and wait for replication to update the inv
Huh?
lol the inv stuff
that's a common thing
really? strange
i thought if you modify it on the client its overwritten by the server anyway
I currently have it as what you said. When the actor dies, i cast it to the PlayerState, get the kill variable and + 1 to it. However its saying both players got the kill.
Same thing. You gotta clean up if it doesn't get removed either way, or have a laggy update on your UI
The Client always bases its assumption on the fact that the Server will return with an correct result for that operation.
9 times out of 10 it will be correct
Its all about maintaining the illusion π
Or you can just deal with having an laggy UI
you wouldn't do that for everything
No of course not
i never change any replicated vars on the client
with some things its worth the effort
but doing stuff clientside and letting the server correct it if need be is definitely a thing
or you end up with lots of laggy actions in a game that will annoy players
hm maybe
Anyone know why I cannot change this Array Element? Is it the Constructor?
I call AddItem from the pickup actor after the Player does the Interact event
If I run AddItem on the Pickup Actor it works but then I have to bypass functionality:
anyone have a clue why local multiplayer might not work properly in standalone
but be fine in editor >_>
When sessions just stop working after working for ages, for no reason, both LAN and Steam, yet "open 127.0.0.1" works fine.
3 weeks chasing this down, literally killing the enjoyment of all the work prior.
Read at least 30-40 google page results that all my links are purple, many of those threads never being solved either. Why are sessions so damn fickle? Why after 3 years of random issues people have, are they still this fickle? #funkiller
When logging, I see the broadcast happen, and I see the 16 bytes both sent and read, but after that, nothing happens anymore. What's crap is, all of this worked and one day just stopped working but nothing in relation to sessions has been changed or edited in that epriod of time. Literally had the rug pulled out, and others have had the same problem, made threads, not had it solved and given up on their project. I don't really want to dot hat.
This was copying the MP Shooter tutorial. I also see many complains focus on the same tutorial. Is that tutorial inherently bad these days and should be avoided?
@dull stream You need to be more specific "works" and "doesn't work" is too vague
what is not working
hosting sessions, joining sessions
It's generally better to play by right clicking the .uproject and do "launch game", it's required for steam services to work
its fine, I fixed it for now.
but while i have your attention
when you set up local multiplayer, aka CreatePlayer, spawn a controller and pawn... you typically do that in gamemode? or do you create a playerManager class of sorts
whats the "best" way to handle this sort of thing
from like a design perspective
in the game mode or server side player controller
but usually game mode since it can be different
alright, yeah i was doing it in gamemode
thanks I think Im good now for the most part
I decide which pawn to spawn in player controller, but I tell game mode to do the actual spawn (find player starts, spawn and possess)
ahh right
yeah i think thats what i did
do you typically use playerStart actor for spawning?
In my particular situation I threw my pawns in the map rather than using playerStart. I guess it just depends on the game eh?
for multiplayer I would always use player starts
When I use net PktLag=200 there is high chance of stucking in aimed state after aim button is released. Why is this happens and how to fix it?
@cobalt whale Show us what's going on in there