#multiplayer
1 messages ยท Page 501 of 1
as only changed values get repped, not the entire strue
struct*
RPC will send the entire struct
my character's "dash" system uses a Launch Character at high speed and a Stop Character Movement. while using it in a basic multiplayer environment with dedicated server, only the host client's dashes work.
why would this happen?
Is this called by a serverRPC of sorts?
it's in the player controller
no, i don't think it is its directly copied over from the player controller i developed in a single player environment
Multiplayer requires you to let the server perform stuff like this for the client
If the client tries to call this locally it would probably be overriden next frame
So you have to rpc first
ah so that's why
thx I'll go look it up
Check out the pinned compendium of this channel
4th link from the top
@viscid bronze
eXi, I'm not sure if you're interested in this, at all, but UE4 Japan has dozens of powerpoints (mostly in Japanese), one of which is a 4 part series on Multiplayer.
But they did have a slide accredited to you. https://www.slideshare.net/EpicGamesJapan/ue4-multiplayer-online-deep-dive-getting-started-ue4dd *slide number 8
(The 4 part series is pretty cool, has cool pictures, Japanese though).
@thin stratus alright sure thing
@viscid bronze I wouldn't use launch for a dash, I'd use forced input with high acceleration and speed. Basically really really fast walking. Using a launch interacts with friction, so if the dude is somehow off the ground he's gonna launch waaaaaaaaaay harder than if he isnt
@dark edge i disable ground friction before launch
and use stop character movement to stop him
@worthy perch Ah cool, the image is a bit outdated but i think the link is fine below it. What does it even say?
Iirc Epic's slides about the community (the whole if you succeed we succeed thing) also had it.
on "Get Player Character" and "Get Player Camera Manager" nodes, when in multiplayer (LAN or not) how do I get the specific player index that is being controlled by the player
if you do this logic in the player character you dont need to do all that
@viscid bronze
but i use those to get velocity and camera direction, which in turn decides the direction of my character's dash function
also it is in the player character blueprint yes
@faint dock
then you dont need to use get player character you are already in it
ok the Get Velocity doesnt give complier error when without Get Player Character
but Get Camera Rotation needs Get Player Camera Manager
@faint dock
just get the camera from the component list top left
Thanks @faint dock , everything works now!
oh, okay cool
In my game because of the random spawn, when a player joins a session he appears in the void in the sky
Why?
@silent birch what do you mean by random spawn?
Random spawn of the character. Whose character goes spawn to a place but not that the game will choose in relation to the target point @dark edge
Why when a player joins a session he takes control of the character who is designated to spawn from game mode instead of controlling the character who spawn by my random spawn system
I think this problem is due to my problem of the last time
@silent birch you need to override the Get Default Pawn Class for Controller function in GameMode.
I know but how to replace it? @dark edge
GameMode has a lot of functions that you can override, if you hover the functions tab it should show the override button
You technically don't need to add any code outside of these functions to get a random spawn system going
Which replacement button? @thin stratus
In the game mode?
:P Just try to check for yourself
Are you trying to spawn a random pawn or spawn it at a random location?
Spawn it at a random location and It already works but my problem is something else @dark edge
remove default pawn from the GameMode if you are spawning your own pawns
and not using the default pawn class
Exi, any chance you know how to check if a session is valid (not nullptr) to prevent crashes when calling things like StartSession() in PIE when playing directly on a map where a session hasn't been created through the main menu as intended (without creating a custom bool or using the if PIE checks as there are times when I DO go through the main menu in PIE)?
Currently setting bSessionIsValid = true on the create / join callbacks and setting it to false on destroy but it feels hacky
I tried GetNamedSession(NAME_GAMESSION);
And?
It still crashes
I did it but when I do it, at the beginning of the game the client does not have any characters to control. I believe that when I do not remove the Game Mode counter it is this character that the client controls and he leaves the character who spawn without control @meager spade
I did it in an if check though
@grizzled stirrup And the crash says?
It made it past the if check
if (GetNamedSession(GameSessionName))
{
// Session interface nullptr checks here etc.
....
SessionInterface->StartSession() etc crashes here
}
Yes @meager spade yes
I answered wrong. there is not a player on the level @meager spade
@grizzled stirrup callstack, crashlog, etc.?
I'll get it now
That would be the correct way to check if a session is valid though right?
What does GetNamedSessions return when it can't find anything?
Yeah I may need to move it out of the if check
And have it return something then check if that is null
It generally returns a pointer
Could also try
IsPlayerInSession
FNamedOnlineSession* GetNamedSession(FName SessionName) override
{
FScopeLock ScopeLock(&SessionLock);
for (int32 SearchIndex = 0; SearchIndex < Sessions.Num(); SearchIndex++)
{
if (Sessions[SearchIndex].SessionName == SessionName)
{
return &Sessions[SearchIndex];
}
}
return NULL;
}
That's what steam does
Thanks! Interesting yeah in that case it shouldn't make it through the if check
Trying it again now in a slightly different way
Will fall back on IsPlayerInSession if it fails
If it does go through the if check, check what that pointer returns
attach it to vs and breakpoint
bool UMasterGI::GetIsSessionValid()
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
IOnlineSessionPtr SessionInterface = OnlineSub->GetSessionInterface();
if (SessionInterface.IsValid())
{
FNamedOnlineSession* NamedSession = SessionInterface->GetNamedSession(GameSessionName);
if (NamedSession)
{
return true;
}
else
{
return false;
}
}
}
return false;
}
Moved it to this obtuse getter to be sure and it works fine, I'll check again with the direct if check now
Probably just messed something up and didn't realize
I don't quite understand what GetNamedSession does -- when would you want to use it?
Basically my gamemode calls StartSession() at a point in time when players are ready to start and the game can begin (MatchStates::ActuallyStarted), if I however don't go through the main menu and create a session etc. as you normally would when actually playing the game, no session gets created. So in situations where testing and playing directly on a map in PIE, when it hits that line the game would crash
GetNamedSession() returns a non null pointer if there is a session so now I can only run the StartSession() code if there is indeed a valid session in use
GetNamedSession does not return true
It returns a pointer ot the session
AHA
EDITED, i see
Sorry I meant my GetIsSessionValid() function returns true ๐
@worthy perch You can use that to get info about the session your are in
Like the state, the ownerid, the players in it
If the player itself is the host of it
If it's joinable from outside
Basically all the info
Oh, alright. That makes sense. I misunderstood its context.
RIght, and it should return null if you are not part of one
Cause it just pulls it from an array
If it still crashes etc., please put the game in debug and attach vs to it
eXi do you have a similar check in place when playing in PIE on specific maps to quickly test? Or you create a temp session for cases like that? I know ShooterGame handles a bunch of cases like offline etc. but I thought this might be easier
You don't have to package for that
Will do!
Technically it shouldn't crash
That's the default print you see in the logs
"can't start game session that doesn't exist" or so
I set the join in progress bool to false and update the session in the same call
I have a PIE check but not for that
So it might be that
MySessionSettings->bAllowJoinInProgress = false;
SessionInterface->UpdateSession(GameSessionName, *MySessionSettings, true); ```
Yep not crashing on StartSession(), crashing somewhere on the above. Edit just had to check the MySessionSettings TSharedPtr wasn't null and it no longer crashes. Thanks for the help!
can't you do a print screen? Kind of difficult to read what you sent ๐ค
That random node is used so damn wrong
0 to max (probably including max) using length, so 0 to n -> out of bounds.
But then you -1, so if it hits 0 it's also out of bounds
0 is at minimum
also you need to kind of reserve the spawn point
Why last inex @thin stratus?
if you have 5 spawn and 5 players connect, 2 can end up on the same point
Nathan, what is the range of indices on an array?
Just in general
Like, if you have 5 entries, which is the lowest and which is the highest index?
With the last index it's just going to be the last index-1 that will just give us the next-to-last index @thin stratus
I said remove the -1
OK @meager spade
What I know is that in computer all the tables do not start with 1 but with 0, that's why I'm doing lenght-1
but what you are doing is Random in an invalid range then removing 1
say you have 5 spawn points
5 spawn points right?
can you see the way the numbers are
In my game there are too many points of appearance (uncountable)
it doesnt matter, just listen and follow
what would be the Length?
@silent birch
I make a get all actor of class then I try to get the number of this actor that there is in the level by a length
look JUST LISTEN.
i don't care what you do, i am trying to help you understand
if i have 5 items in the array, what is the length?
I would love to have that array to throw some euros into
๐
Because I was told that in a computer table the value starts not 0 not 1
so length is 5, @silent birch
5 items == 5 length
so when you do this http://www.interkaos.com/grabs/UE4Editor-Win64-DebugGame_TNMxqXrStF.png
you are doing 0 - 5, but 5 is not a valid index
@silent birch The "Starts at 0" is correct, but you have to shift the end index too
OK
In normal human language, you'd assume 5 items have indices:
1
2
3
4
5
In Computer language they are
0
1
2
3
4
So offset by 1, starting at 0 and ending at n-1
Length (n) describes the amount of items in it, being 5 in the example
If you get a number between 0 and 5 you might get the 5
And 5 is, as seen above, invalid
So you need to get one between 0 and 4.
So 0 and Length -1
LastIndex is basically Length-1
OK
do you understand now @silent birch ?
Yes
So what you are doing atm, is getting a value between 0 and 5.
And then subtracting 1
So what you get is a value betwen -1 and 4
The 4 is fine, but the -1 is shite
So instead of doing the -1 and Length
You just use LastIndex
So if I use the last index I do not do -1?
Correct
also like i said above, you would want to reserve spawn points once they are used
as they could be picked again
OK
i did mine by shuffling the array, and just going sequential ๐
it works for testing, for now
I have to use the get all actor of class? for appearance points
@thin stratus you ever used PrimaryDataAssets?
That's just DataAssets exposed to BPs, right?
no its an asset which is not loaded until manually loaded
contains a bunch of soft pointers
yeah trying to decide when the best place to load my weapon assets
i don't want to load the full weapon asset until the game starts travelling
possibly on connection to server would be fine, on the way to the lobby map, i can load all the gun definitions
I have to use the get all actor of class? for appearance points
just trying to find the best place to handle it, tbh i need to ensure the definitions are loaded before the game starts, not sure how i would handle there not being a weapon actor in the definition
@silent birch Yes, and?
I have to use a knife to cut my bread.
What the hell does that tell anyone xD
Epic, can we get a tutorial on how to properly formulate questions and support requests?
you need to disable the spawning of the default pawn
Where?
Is it possible to get the appearance points on which the character appeared? @meager spade
what is appeareance points?
you mean Spawn Points?
Set the DefaultPawn in the GameMode Settings to none
That was already suggested
You should do what we suggest before asking a million times
And if you don't know where then google is your friend after all
I know, but when I do it the client does not control anyone and does not spawn even in the level but he spawn in the sky
That's a different problem though
First you have to make sure that your character only spawns once for each player
Not the solution?
Hi adriel
@silent birch Start from the beginning. What EXACTLY are you trying to do?
In my game there is a random spawn system and it works. But the problem is that he also the character that is designated in the game mode that appears) (that is to say that there are for example two players but there are three characters) the third character is the character designated in the game mode @dark edge
Either move the random spawning to the game mode, or set the default pawn to none and call Possess on the character generated by the random spawn system.
For the possession of the actor who spawn I did it but when in the game mode I put none the client at the beginning of the game has no characters to control @dark edge
You need to call Possess for everyone.
Then you didn't do it. Confirm that you are spawning 2 pawns and calling possess on them for the 2 controllers ON THE SERVER
Or just move your randomized spawn stuff to the game mode and let it handle spawning like it should.
My guess is your calling Possess from the client which does nothing.
I don't understand
Show a screenshot of where you are calling possess
You are only calling possessed for one player there
Move all your stuff to game mode, just override the functions the choose what class to spawn and where to spawn them
So move all of the spawning logic there and it will work if you do it right. as of right now you are only calling possess on the first player.
How make? @dark edge
Just override Spawn Default Pawn For and it should let you choose the pawn class and the location that it is going to be spawned at
i am sure there is documentation on this all over the forums
its very common and basic
i am sure GameMode has Choose Player Start function
you don't need to do any possessing or anything
In game there is no player start @meager spade
there is
There is?
if you are using the same character
just use this to provide a start point
and delete your other stuff
Get all actor of class (for the target points)? @meager spade
target points?
In my game did not put any player start in my game but I have it is replaced by target points @meager spade
No default character but random appearance @meager spade

Apparently it worked but the client seems to be spawn almost in the same place
I have a weapon pickup that works by switching a boolean "Weapon2PickedUp" inside main player blueprint to true. How do I get it so that it will know to let other players than the host pick it up
@viscid bronzeUse the switch has authority at a place in your code (in this node the authority is the server and remote is the client
I'm not sure what I'm saying but try first @viscid bronze
kay looking switch has authority up in documentation
I don't understand @viscid bronze
What do you say in your last sentence? @viscid bronze
you mean original post?
It means that right now, only the host client can walk over the pickup and get "Weapon 2 Picked Up" switched to true. Other clients cannot pickup the gun.
I want to make it so that all clients can pick up the weapon
Host client is server?
Is it possible to do multiplayer if your developing from a mac
@silent birch no its running on a dedicated server with 2 clients
@silent birch its alright ill ask elsewhere
@vocal flint why wouldn't it be? Although I would suggest you do yourself a favor and slap Windows 10 on it to avoid a million headaches.
from what ive seen visual studio is used for multiplayer on windows and its just not the same on mac
isnt there a visual studio equivalant on mac
@silent birch you need to specify the class to search for
i really think you should learn the basics, do some tutorials instead of asking people on here constantly. Genuine questions sure, but we can't help you with everything. This is basic BP knowledge. i know you are only young, but now is a good time to follow actual tutorials online, learn what is what. There are tons of tutorials. And honestly doing a multiplayer game with little or no knowledge of the engine/blueprints, is very bad practice. I am all up for helping you and so are other people here, but you need to help yourself aswell.
@viscid bronze you want to gate the pickup behind an authority check, also how are you telling the client they picked up the item?
No it's good it already worked @meager spade
it's not good tho @silent birch, you really should specify what actor to spawn at.
@meager spade When the actor overlaps the pickup item, it switches a boolean "Weapon2PickedUp" in the player controller blueprint to True. It is ported directly from a single player project and I have no idea how to implement it
yeah but you are also using GetPlayerCharacter0
which is very bad practice for multiplayer unless you understand what is happening
I have a lot of knowledge to make a game like my game @meager spade
@meager spade yes i kinda have an idea of why that's not suitable but is there a replacement
well what is OtherActor going to be on that node?
the player who overlapped it
cast that to the player
um how do i do that
i already cast to ThirdPersonBlueprint
You can get multiplayer without dedicated server. but if you want dedicated server you have to build the whole engine from source code using the Server option. That can take all day to compile. I also dont know if you can compile the engine without Visual Studio but maybe
I dont want that headache so I designed my game around a listen server and kept number ofnplayers to 16 or less
That can take all day to compile.
It's like an hour on a mediocre computer.
It took me 24 hours to compile one time, but I was compiling it on a $10 month digitalocean cloud server LOL
what are you guys talking about i just ran it game and ticked "run dedicated server" under the play button
He's talking about building a dedicated server, not just firing one up with an installed engine.
You have an installed engine you can start up a headless server just by adding the -server command line argument
i see. i still have no idea but im new so i will probably get to that like years later
@viscid bronze if you knew just focus on learning how the engine works.
alright sure im trying to do that
If I have a multiplayer with 2 clients and I want a boolean to be changed in whichever client walks over an object what do I do
Make it replicated and change it on the server.
how do i do that i have my character blueprint and the blueprint for the object only
i use this for object overlap blueprint but this one only lets the host client switch boolean
Never use GetPlayerCharacter or GetPlayerController in networked games, at least not if you are not 100% sure that this is supposed to reference the calling player
Whatever actor you are in there is most likely replicated, right?
(the image)
idk iif it is replicated but i can see it on both clients
also nice book
You are coding this project
You must know if you marked it replicated
And if you are spawning it or placing it
Who else should know that :D
Either way, if it exists on everyone (visibly), then you can't use GetPlayerCharacter in that overlap
It will overlap on server nad all clients
Everyone will call this with their own character
And not with the one overlapping it
replicates in replication is unchecked
But it's placed in the level?
Then that still exists on everyone
So what I just wrote still counts
The overall calls on everyone
ClientA runs over it (whatever that is), Server and ClientB see ClientAs character running over it
So it calls for everyone
If you only want to affect the character that touches it, then you need to use the OtherActor pin on the overlap
And if this is something that the Server has to do (due to replication, authority, anti cheat etc.) then you also need to limit it to authority
ok sure i will try to implement this
cause you would have used many "bad" practices that work fine for single player, but will break/fail/do something undefined in Multiplayer
yeah, theres quite alot you can get away with in a singleplayer game that will quickly bring your MP game to its knees
ok i kinda made it work
but
there are 2 of this "pickup object" on the level
after one of the client "picks" it up (changes boolean and destroys actor)
when the other client "picks" the other one up it only changes boolean and does not destroy it
First of all
Second of all, this is a multiplayer game
You have to mark stuff like that boolean as replicated
aight noted i will go do that now
also for simplicity sake, just run this on the server
HasAuthority
is this correct usage?
ohh so thats what that function was
should i connect it to true or false
should they both have suthority
good now i got this
i dont think any of them have authority tho, the blueprint is not working now
there is always an authority
you say its not working
but have you placed break points
what's that
Pause execution using Breakpoints to inspect graphs and the values of variables.
worth reading
yes i did some breakpoints and this
yes it has authority but its still not running the rest of the blueprint hold on
print string aint break points
after using a bunch of print strings, the entire blueprint seems to function, but its not changing the boolean?
I know but im using them to check if the blueprint is actually running
yeah, the "Weapon2PickedUp" is apparently not being switched on, it doesn't let me switch weapons
also all the print strings are from the Server:
yes thats right
then the server has to equip the weapon to the client
you need to understand how replication works
if client "equips a items", it will only be local, no other player will see it
server is the only one who can tell other clients what they can see
with regards to replicated stuff
so if i have a weapon pickup, i would check overlap on server, then the server will equip that weapon on client
actually my weapon "equipping" is just 2 Weapon Base blueprints with one set to invisible
turning the "Weapon2PickedUp" bool just makes it so that I can switch so it isnt even really a pick up i think
the bool in Character Blueprint is now set to replicated, replication condition is None.
I can switch weapons now, but the other Client will not see the weapon switch, and the pickup will no self destroy
@viscid bronze what triggers the weapon switch?
the 2 weapon bases are actually always present, just one set to invisible
2 input action keys can switch thru, but only if boolean "Weapon2PickedUp" is true
actually it is 5:30 AM in the morning and I have stuff to do tmrw so thx @meager spade but I will try to actually understand multiplayer replications tmrw and try it
@viscid bronze I bet any amount of money that you're just switching it on the client. You need to use an event that is replicated to the server the changes the weapons.
Nothing you do on a client can ever affect the server or any other clients other than being sent through a replicated event
Yes use Run on Server event to tell the server to make the change. Replication of variables only works from server to clients. To replicate any other direction you have to use RPCs. This is to make the server the source of truth and reality which keeps clients in sync and prevents cheating
Hi guys, I have been struggling with implementing something for a while now and I was wondering if anyone could tell me where I am going wrong. I am trying to make a multiplayer game where each character has a line of sight beam that affects the other players (think Mercys healing beam from overwatch). The following are my blueprints for this functionality. What happens is when I run it, the listen server can set the targets isShielded boolean to true, but the client cannot set anythings isShielded boolean.
I have a good question
why does only character actors update automatically on listen servers?
And how can i make other objects update on everyones screen?
@twin juniper characters have special code for handling shooter like movement smoothly over network when you add input movement, without you having to add your own rpcs.
But everything else except maybe floatingpawnmovement does not have that and does not have network smoothing and prediction built in. You have to make up your own network smoothing and prediction if you want no stutters when over 20 ping.
Other things do replicate movement if acfor is replicated and you check replicate movement checkbox. But only from server. Updating from client relies on Run On Server RPCs to tell the server to move the pawn.
@sonic ice can you confirm that all of that logic is running on server only?
@dark edge Hey so, I believe everything aside from the button input, and the change of IsPressed is on the server only, as I have set the HealingBeam Event to run on server only. I've tried messing around with RepNotifies on the booleans but still no luck.
hmm
I think when the client presses F, the server's IsPressed stays false, so the top part never runs
@sonic ice is pressed is going to be false on the server
Yeah that's it. You shouldn't need a Boolean on the input side just have a server start and server stop hooked up to the press and unpress
Other than what gets triggered buy a replicated event to the server, absolutely nothing you do on the client will ever affect anything on the server.
Character movement component and player controller have their own internal events, which is why you see things like character movement input and control rotation replicated to the server, but under the hood it is all replicated events
Okay thank you, I'm still wrapping my head around the whole client server relationship. So if you were to send a constant line trace to something, to change one of its values (e.g. my bool), but then as soon as the line trace is no longer touching the actor in question, OR the line trace has been stopped, how would you see that working?
This is where I've ended up after a few more hours of trying
I have IsPressed as a rep notify that runs healing beam, and the reason I am using that bool is so that I have a something to tell the server whether or not I am still holding the button
Ohhhhh I just figured out that you have to store the most recent actor hit so that you can set its bool to false whenever the line trace can't find anything, thanks for the help guys ๐
Hi, can someone explain the difference between building a shipping server build and this guide https://wiki.unrealengine.com/Dedicated_Server_Guide_(Windows_%26_Linux) which covers development build?
Not sure what to do, we built the engine for both shipping server and shipping client, and tried following the same steps as development build explained above but it didn't work out
(Development build works perfectly, we are trying to move on to shipping)
Is there anything special about the Player Start Actor? Specifically, how does it evaluate/store "unoccupied"?
What I'm trying to do is to have 1 start location per connected player, and have them always respawn at that location, but not have too many bools and references floating around. I
First try to make the random spawn can only do once for that use the node (do ou ou ou multigate) but multigate you will only use the first output like that the action of random spawn will not produce only once. @dark edge
And look for if there is a node that allows that after the random spawn that the location where the player had spawn be backup and you make him respawn to where he had spawn @dark edge
@dark edge there isnt anything special about PlayerStartActor
its just an actor so the gamemode's ChoosePlayerStart has something to iterate over
so in code
APlayerStart* FoundPlayerStart = nullptr;
UClass* PawnClass = GetDefaultPawnClassForController(Player);
APawn* PawnToFit = PawnClass ? PawnClass->GetDefaultObject<APawn>() : nullptr;
TArray<APlayerStart*> UnOccupiedStartPoints;
TArray<APlayerStart*> OccupiedStartPoints;```
it creates two arrays, UnOccupied and Occupied
then it does FVector ActorLocation = PlayerStart->GetActorLocation(); const FRotator ActorRotation = PlayerStart->GetActorRotation(); if (!World->EncroachingBlockingGeometry(PawnToFit, ActorLocation, ActorRotation)) { UnOccupiedStartPoints.Add(PlayerStart); } else if (World->FindTeleportSpot(PawnToFit, ActorLocation, ActorRotation)) { OccupiedStartPoints.Add(PlayerStart); }
then it chooses a random start from UnOccupied, if that fails, chooses one from Occupied
to ensure a spawn
and storing is done via StartSpot AActor* in the PC
Ah aight so "occupied" isn't really a claim on a spot, just checking if the pawn can actually fit there. gotcha.
I have a character with Use controller rotation yaw set to false, because I'm using the controller to free look around.
Though, this character is climbing on a tree and I need it to rotate towards the tree when i strafe left/right. To do that, I currently SetActorRotation on all clients and on server. I use an interpolation to ease the jiggering, and I'm relatively OK with the result. Though, I wonder what are my options to make it work nicely and correctly... any input?
It is said that if you make an event happen only at the server it will also happen at the client, so how to make an event only happen at the server not the client
I am setting up a match timer for my game. It should begin when all players are ready.
The server will want to run post-match logic when the timer ends, and clients will want to have the time remaining displayed in the HUD. From my current understanding of GameMode vs. GameState, this seems like something that should be stored in the GameState, is that correct?
If so, I am having trouble understanding why, as I have this working within the GameMode asset (player controllers cast to it for the time and update their hud). If GameState is the proper home, in which way will I be shooting myself in the foot by relying on GameMode for it?
@silent birch I guess u set the event to not replicate
I can only help you to do as in my game. When the waiter wants to start the game he presses a key and the stopwatch is displayed @graceful geyser
And in my game I also did that as long as the server did not press this key it (disable input) @graceful geyser
So the event will not be replicated but will run on server? @twin juniper
@silent birch I have the functionality working, I am more trying to further my understanding between when I should use GameMode vs. when I should use GameState. Theoretically the functionality could work in either, so I'm hoping to understand why it's better in one place vs. the other.
I was told that in the game mode most events are only run-on server @graceful geyser
So the gamestate will be better @graceful geyser
@silent birch if the server runs an event with no replication it will not get replicated, if a client runs the event it's not gonna happen
OK
GameMode only exists on the server, GameMode should control the Game, like the Rules, what player characters to allow, that kind of stuff
GameState should be where other players can get the state of game, like total kills in the game, current objective, that sort of stuff
@meager spade So in the case of a match timer, that controls the game (terminates the round) and informs state of the game (time remaining for clients to see), would you imagine that resides on the GameMode and communicates it to the GameState for clients to reference? I'm currently bypassing GameState and having PlayerControllers receive the update from GameMode directly.
I've been storing my timer handlers in the gamestate
unreplicated
client and server have their copies of it
I see. Am I understanding this correctly? They both have copies because GameState is both server and client (GameMode is server only). When a client casts to GameState for the time, it doesn't have to be replicated as it exists on both?
I just multicast the event the time is close enough that it doesn't matter
yeah
it's un replicated
server has the most accurate copy of it
but 50ms, hell even 500ms doesn't matter if you're counting by seconds
especially if it's only for display
considering the server is going to be doing any decisions
How can I make a client's hud update? Whenever I send a line trace to them to lose health, that works, but their hud doesnt update to reflect it
is there something I need to do to make it work?
it will work if it's done correctly
something is wrong with your HUD
because you said the replication is working
@zealous saffron So a multicasted event updates both Server and Client gamestates
Gotcha. I've read through them, this is helping to solidify my understanding. Thanks!
Hey Guys,
while Working on the Lobby i get a weird Crash. It works in Editor but the Host is crashing in the packaged game when upading the session. I'm using the Subsystem Steam.
Has someone a idea or tip how to debug this?
It's mostly Blueprint
When i import my blender skeletal mesh to ue4 it gives me errors blah blah blah. When i open the animation thing the mesh is scaled down to 0.01 of its original size and when i add sockets they are scaled 100x there original size
wtf??
Where should I put my setup stuff where i can guarantee the controller and pawn exist and pawn is possessed?
Is leveraging OnRep as much as possible good practice or am I designing myself into a corner here? It feels right but if anyone has any input on this approach it'd be greatly appreciated.
What's your alternative to OnRep?
Also, to answer your previous question, there should be something like OnPossessed.
@worthy perch In my game I have a lot of state switching and pawns that are constructed from parts. Basically, there's a ton of ways that things can get out of sync using events, so I'm starting to move everything possible to OnReps. For example, when the player wants to change from playing to construction mode, I just change and enum and run a big OnRep that swaps the ui, shuts off physics, teleports the vehicle to the base, etc. Same thing with setup and vehicle part registration, I'm using an OnRep for Array_AllParts to set up all the references and such. I need to make it be robust enough to handle late joins etc. So far it's working pretty well, just wondering if there's any weird edge cases anyone's ran into.
OnRep is ok, i think attached stuff is also always replicated to later joiners
also OnRep to switch UI seems a bit odd aswell
How else would you drive UI switching by state?
How would you identify different replicated players in a multiplayer game?
i tried it with n enum and array but now they just all become player 1
you can't really
you would never know who was Player1, etc
and that above is not reliable to find who was the first player to connect
yeah that's the problem i run into rn how would i fix that do i have to copy my fps char bp and give everyplayer it's own id to identify them that way?
but wait could i check for who connected first? and how would i do that? ^^
PlayerArray should be ordered
based on connection
also you should be using PlayerState
to hold this info
How do you guys deal with references being replicated before the actual object is?
in what context @dark edge
I have a setup like this running my driveline sim. When a part is added, it is spawned and then added to the various arrays it belongs to. The problem is that the array is being updated before the actor spawns client-side.
I could do IsValid checks on everything but that feels clunky
Thanks @meager spade
ah
i shoved my Spawned Actors into a replicated struct
and use OnRep to handle it when it comes in
wait that is still an issue
thing is its like a chicken and egg situations
Yeah it is.
i am lucky, my weapons are added to a fast array serializer
actor is spawned, but i don't care for the actor
actor will handle itself when it comes to the client, server has already attached it etc
could the parts not handle themselves
once they are replicated?
hm maybe. I could probably trigger the registration from the parts Begin Play.
yeah as that is run on client when they get the actor
god that just feels so hacky. Then i gotta make sure the parent vehicle is valid before calling registration on it
I want to make a "Steam Advanced Sessions" server invite only - with these settings I'm not able to invite someone through the steam overlay. Am I doing it wrong?
Is it possible to pass UObject derivered class to RPC and have it replicated ?
Subobject Replication
Or whatever that was called
You basically need an Actor that takes care of the replication
But then a UObject could replicate
Can't explain it (usually avoiding doing this), but you might be able to find the solution with the keywords @gleaming bobcat
I think I understand now how it works. Thanks
Subobject replication is quite slow so I have to use USTRUCT then
According to a code to make that when the life of the character are zeros that he plays an animation and then that it destroys must be done where? In the blueprint of the object that removes the life from the character?
no
from the character who has no health and is dying
@gleaming bobcat its not slow
So in the character's Blueprint?
With what Node in the beginning?
For example to make that at the beginning of the game there is a widget that is created we start with the event begin play
Can be the vent tick?
After you are dead the game opens the level repart to the menu, opening the level menu when the server will die according to not also to arrive at the customer while he is alive?
@silent birch I re-read your last sentence like 3 times and I'm still not sure exactly where you're going with it, but if you're struggling where to put logic, I recommend #blueprint or some basic player character tutorials. I also don't recommend creating widgets on event tick
If I go to the Blueprint channel, people will tell me that this is a question to ask in the multiplayer channel (my game is online)
How do you refer to a string when you write a message? @unreal pine
I usually call them happy little strings
How?
I don't understand what you're asking me
you just put a # in front of it
Thanks
After you are dead the game opens the level repart to the menu, opening the level menu when the server will die according to not also to arrive at the customer while he is alive? @unreal pine
Repeating the exact question that I said I couldn't understand isn't going to help ๐
Are you saying when the server dies, it loads the main menu?
No I did that if a player dies the main menu opens. It is said that everything that happens at the server also arrives at the customer's, right? @unreal pine
customer... are you trying to say client?
Yes
Not everything that happens on the server gets replicated to the client. Recommend looking up some youtube tutorials about replication and how it works
also exi made this sweet pdf that will help
http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
I know
Guys, I've got one outstanding issue with steam sessions. It seems to not show full session, has anyone found a work-around for this?
@silent birch if you have an event happening on the server that's not happening on the client, it's probably just not replicated properly.
But my code of when the character is that the main menu opens, I tried it but I did it in the blueprint of the ammunition and when the waiter died the main menu opened in the two players
Why?
is the main menu a level, or is it a widget?
@fluid flower what do you mean by doesn't show the full session?
@silent birch if you load a level on the server, it'll load on any client connected as well
So right now, when we playtest, we can search for session just fine. However, the search session function only returns sessions with at least 1 open slot. I need it to show all sessions, also the ones that are full. Is that possible?
@silent birch check out page 80 of that PDF I linked you
So for that I only make widget (main menu)? @unreal pine
As I understand it when looking for a session there is only one result displayed? @fluid flower
nope, it shows all the ones that are not full sessions yet
so it shows
3/4, 2/4
but as soon as its 4/4
it does not return it in the search result
This is normal because even in my game it's like that. But it's relative to the number of acceptable players in the session (max players) @fluid flower
yeah it's the default behaviour but is there a way to change it?
I'm not sure, it's better that you allow players to choose the maximum number of players himself @fluid flower
That's good?
@fluid flower
not sure what you mean
for testing purposes, I want to basically see ALL sessions
full, empty, etc ๐
In your game what is the maximum number of possible players?
it depends on the map
OK
why the person who plays can not choose himself the maximum of players? @fluid flower
because the maps are built for specific number of players
OK
@fluid flower you using advanced steam sessions? Cause if not, I highly recommend it
so it seems that it's not possible to show full sessions, by design ๐ฆ
was just now on the steamworks dev forums
Yeah I was thinking that may have been a steam thing
yeah ๐ฆ
You'd have to track it yourself and stop broadcasting the session
Oh, I misread that.
Advanced Friends Plugin (I think thats what its called) has nodes to update and add meta tags to sessions
you could look at doing that and only showing items with meta tags of "FULL"
If i would create a simple player profile system where players can give their selves a unique name (at least unique in the game session) would it be possible to identify them trough out different scenarios in the game like u cant damage urself, player spawns, scoring etc?
and how would i aproach this I would try something like getting the name and using that like n id but the thing is I don't now the specific name and if i just make something like a get player name function then it gets all the names and probably everyone gets the same name based on the first or last player
So I'm not sure if this is a good idea just the main purpose I m searching is just for identification because i need to store attachments etc that get choosen inside the game
so is there a better way to differenciate players in a multiplayer fps game where everyone uses the same replicated character bp ? It's a 4 player free for all so i need to get this info before the player spawns
Anyone here know their way around replication enough to have some insight on a race condition I'm facing?
The gist of the problem is this. I have a BUNCH of arrays of actors that I iterate over on tick. I'm spawning all the actors on the server and also setting the arrays on the server. I sometimes run into cases where the actor reference arrays are replicated before the actors themselves are.
@fossil stratus i use playerState->UniqueId for some of what you described
@dark edge Why do the clients need to be aware of the actor ref arrays?
Maybe that's not important. I had a race condition kind of like that. My solution is not optimal but it works. The problem is that it refreshes ALL clients any time ONE of the clients tells the server it needs to make sure it is synced up.
So I hope we can find a less ugly solution for your problem
I'm basically running a huge mechanical sim on both sides, server and client
and it's modular and can be edited at runtime
I might just validate all the gets and call it a day to be honest
is there a good reason not to validate them?
I mean I'd be doing a validate like 100 times a tick lol
i wonder how slow it actually is? If you try it and measure the impact i'd be curious to know
It's probably fine, just feels hacky
Wait
do you know if an interface message will fail silently if sent to an invalid reference?
Might just do that, I'm blasting messages all over the place already anyhow
Heh, the only one that's crapping its pants is the only one that's not an interface call.
See all those arrays though? Validating everything on tick would be a bastard.
haha that's quite a few arrays
I'm setting up some automated tests with 2 PIE windows and part of it is an auto-login - this is working with a single account. To streamline this testing, I'd like 2 be able to login with 2 accounts. I can get this to work with one PIE window and one standalone client window (via launch dir node), but I'd like to get it working between 2 PIE windows. Is there a way to tell the difference between 2 PIE windows, such as window title? Thanks in advance
Fixed my issue by creating a pure blueprintable c++ function that gets the PIE Id. FYI to anyone wondering how to differentiate between 2 PIE window instances.
This is how they do it in UKismetSystemLibrary::PrintString, which is pretty much what you did.
if (World->WorldType == EWorldType::PIE) {
switch(World->GetNetMode()) {
case NM_Client:
Prefix = FString::Printf(TEXT("Client %d: "), GPlayInEditorID - 1);
break;
case NM_DedicatedServer:
case NM_ListenServer:
Prefix = FString::Printf(TEXT("Server: "));
break;
case NM_Standalone:
break;
Thanks @split drum will try it out today sounds like the exact thing i was searching for^^
I'm having issues getting a montage to correctly play on a dedicated server. In the skeletal mesh I'm setting VisibilityBasedAnimTickOptions = EVisibilityBaszedAnimTickOptions::AlwaysTickPoseandRefreshBones and I can see that the server is calling Montage_Play in the anim instance. The animation drives the location of the weapon so it's throwing off collisions. Any ideas?
Eek, nevermind I figured out the issue. The value was getting reset so I had to move that line to BeginPlay. ๐
In my game I made a system of time selection at the stopwatch and it works. But it does not save the time the player has chosen but it goes back to that default (in game)
How to do that when a player goes back to the main menu that is no longer counted as a player of the session?
Should this node be used to leave a session?
Quick question about relevancy handling:
- Replicated Actor
- Calls function on BeginPlay that should only call when the Actor spawns next to the Client
How does one handle this? I have a replicated boolean that is set to true and used as a lock in the function to not call it twice.
That stops the client from calling it when coming into relevancy later.
However since the Actor takes a bit to spawn on the client, the boolean also instantly replicates when the actor spawns next to the client.
This should only lock off the function for the scenario in which the client was not relevant when the actor started and became relevant later
I think the main issue is using BeginPlay here
As it calls again when the actor gets relevant instead of calling the event by hand, but I don't really like every actor using this actor to call that event just solve the relevancy issue
As an example imagine a chest opening on beginPlay.
It should open for the client when seeing it but not when coming in later.
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
void ServerRequestDisconnect();
bool ServerRequestDisconnect_Validate() { return false; }
void ServerRequestDisconnect_Implementation() {};
how disgusting is this?
It does, but I dont feel so good
I guess what you really want is just proper return to main menu functionality right?
Since it qualifies as a network error / kick on the client-side
Yeah, exactly
Ideally I'll iterate this and have the client travel to a lobby server, rather than kicking them entirely
for now it works I guess
Not sure how the game works but yeah should just be able to open a new map and it'll leave automagically
hello where is AdvancedSessions.build.cs because when using Advanced Sessions plugin and building it told me to change something in here
Probably in that plugin folder
where is the plugin folder
@unique kelp
nvm @unique kelp i found it i think
but why is it empty
But why is it empty
This is a generated file
You should never need to look in Intermediate
Plugins are in project-folder/Plugins
Build files will be in the source folder of that plugin
Like your game
yes @bitter oriole but i think i am missing sth here
yes @bitter oriole but i think i am missing sth here
Yes, you are missing the plugin. Where did you install it ?
in my engine
i suddenly remembered
because some guy in a tutorial told me to
Move it to your project
If I have a replicated Actor placed in the level and the Client is visibly out of netculldistance, shouldn't Multicasts inside that actor not reach the client?
the entire plugins folder? @bitter oriole
The actor obviously doesn't despawn like other actors that are spawned manually cause it net loads on the client
If it's a level actor it should never despawn, so that part makes sense
Yeah, I would still love to have clients not receive multicasts of actors that aren't relevant
That seems weird
I thought epic's Chest demo was exactly showing that
An overview of the Network Features example level, example 2.1: Network Relevancy (Part 1 - Not Replicated At All).
That ?
Yeah, pretty old but that's the basics of it
Sounds a lot like "no RPC outside of relevancy" to me.
Is it a Reliable RPC ?
IIRC only Unreliable RPCs are relevant-enabled
I can try
Since Reliable means "reach the other machines at any cost"
Eh.
kay @bitter oriole i have copied the AdvancedSessions
folder
found it
found it
if i copy the AdvancedSessions plugin to my project folder can I just delete the one in Engine folder
You should
Thanks @bitter oriole good to know
(Does using "project" plugins work properly with c++ hot reload or live coding in current UE versions? In 4.19 and 4.21 I explicitly used plugins on the engine side because putting project plugins seemed to totally break the hot reload system)
With project plugins existing in your project folder, right? This will be good to know
I don't think very many people knew that installing plugins in project broke hot reload. Didn't find much info about it on the net.
In my game I made a system of time selection at the stopwatch and it works. But it does not save the time the player has chosen but it goes back to that default (in game)
How to do that when a player goes back to the main menu that is no longer counted as a player of the session?
Call DestroySession on the client that left
So basically when entering the mainmenu
I tried but it does not work @thin stratus
That's the only way to do it
The player who went back to the main menu was always counted among the players of the session @thin stratus
That removes the client from the session
Hi everyone, I'm moving session BP code to C++, and I have a log warning : LogOnlineSession: Warning: OSS: No game present to join for session (GameSession).
I'm using Null subsystem, it works fine in BP. The hosting is initiated by the GameInstance (following the wiki tutorial). Is there something basic I could be missing here?
I looked into OSSNull code and basically it means the session does not exist when registering the hosting player. Which seems kind of strange.
Here are the session settings:
SessionSettings->bIsLANMatch = true; SessionSettings->NumPublicConnections = bIs4PlayerGame ? 5 : 4; SessionSettings->bAllowJoinInProgress = true; SessionSettings->bIsDedicated = false;
and in the StartOnlineGameComplete delegate, I'm opening a new level using UGameplayStatics::OpenLevel(GetWorld(), GameLevel, true, TEXT("listen")); The warning pops after level loading.
I'm pretty sure I'm missing something very basic, I remember having this warning years ago, but even a deep search of the warning on unrealengine.com leads to nothing :/
Hmm, maybe it's because you need the question mark? ?listen
Don't know what StartOnlineGameComplete is.
It's the delegate called when the online session has started
Set with that line: OnStartSessionCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(OnStartSessionCompleteDelegate); will try what you say, thx
Yeah, alright. Just making sure.
(however, I see in the logs that the level is started in listen mode)
And you call StartSession after that?
WELL, no I think not. Just after OpenLevel?
I also used the wiki:
if (bInWasSuccessful) {
OnStartSessionCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(OnStartSessionCompleteDelegate);
// Our StartSessionComplete delegate should get called after this.
Sessions->StartSession(InSessionName);
}
Oh sorry misunderstood you
void UMyGameInstance::OnCreateSessionComplete(FName InSessionName, bool bWasSuccessful)
{
bool bError = true;
IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
if (OSS)
{
IOnlineSessionPtr Sessions = OSS->GetSessionInterface();
if (Sessions.IsValid())
{
Sessions->ClearOnCreateSessionCompleteDelegate_Handle(OnCreateSessionCompleteDelegateHandle);
if (bWasSuccessful)
{
OnStartSessionCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(OnStartSessionCompleteDelegate);
bool bSessionStarted = Sessions->StartSession(InSessionName);
bError = !bSessionStarted;
if (!bSessionStarted)
{
UE_LOG(LogTmp, Error, TEXT("Session not started."));
}
}
}
}
if (bError)
{
UE_LOG(LogTmp, Error, TEXT("Something wrong happened while trying to start an online session."));
}
}
So how do you make it no longer counted among the players who are in the session?
Thanks! Sorry had a hard time making it work x)
So yes I misunderstood you, I'm calling StartSession which will call OnStartOnlineGameComplete, which will in turn call the OpenLevel part (OnStartOnlineGameComplete is the method bound through OnStartSessionCompleteDelegate)
Not the solution?
@silent birch do you call DestroySession from the disconnecting client once it's back on your main menu?
About my problem: adding a question mark to the "listen" argument did not change anything ๐ฆ
I'm going to do it in my game break menu widget (if the player has to press the exit button of the pause menu he goes back to the main menu) @glad wharf
Everything seems right... if you're really out of ideas. I did hear that bIsLANMatch = false is best whether or not you use LAN.
thanks will try that ๐
Despite that, it does not work
bIsLanMatch = false does not solve the problem ๐ฆ Will continue to investigate, thanks for your help @worthy perch !
Sorry, you have not of solution at my problem?
Sorry Nathan I don't know
About my prob, I'm suspecting I'm doing something wrong with the session name / FName
OK
You did not understand what I mean or you do not have the solution to my problem? @glad wharf
return Sessions->CreateSession(*InUserId, GameSessionName, *SessionSettings);
Sessions->DestroySession(GameSessionName);
It's just a macro for differentiating Game and Party sessions. Very confusingly named, imo.
I'm using a SessionName defined by myself as a static const FName = TEXT("MySession"); maybe I should not?
(i don't have the solution Nathan ๐ )
Guess not, it's this:
#define GameSessionName NAME_GameSession
#define PartySessionName NAME_PartySession
#define GamePort NAME_GamePort
#define BeaconPort NAME_BeaconPort
woooow ok will change that and see. I thought it was a way to differentiate servers from different games
@glad wharf OK
Like I said... very confusingly named. And reading the function documentations that take FName SessionName still make it sound like they want a unique name.
But no, I think of them more like session types.
thanks so much for this explanation, I was way off! Currently compiling to see if it solves it...
YEAY! That was it! Thanks ๐ ๐
Please, I'm always looking for a solution to my problem for info
Hi, how do you synchronize cube (or any other object) physics over network - make the cube pushable by other clients? I have tried something and It worked perfectly over ping 0 but when I tried settings ping 100+ It was stuttering and hard to push the box. I am using the standard third person controller and cube is set to Static mesh replicate movement + replicate physics to autonomous proxies. Do I need to set something else?
replicating physics is a nightmare
most of the time its just simulated on the clients
and could you please provide more information how to do It? I can't find good resources for this topic for unreal engine
Is it possible to simulate physics on client when pushing the box? But what happens when someone else will push the box on the opposite side? I am coming from unity and I thought this is solved in unreal engine ๐ค
Sorry if I bother you but you still have no solution to my problem?
@cedar heart might be better to handle cube pushing kinematically instead of using physX physics simulation
If you can
Yes this could be better - maybe implement custom adding of force to cube on player collision and then send to all clients ๐ค
I made a system of choice of time
But after doing so, the game starts again as it is by default
@cedar heart you can give yourself some more wiggle room by messing with the physics replication settings but the biggest problem that you'll run into is the fact that your character movement is predicted but the physics movement of the cube is not.
I have replicated physics working pretty well in my project, but I don't have any prediction at all. I can get away with it because the players pawns naturally have fairly low responsiveness but for a predicted character to push around a physics object perfectly smoothly it's going to be a ton of work.
I give up after the discussions - I think better way will be adding interaction to take object into hands and then user can move the object everywhere he wants without worrying about physics sync. ๐ Anyway thanks
So me? Please
@silent birch You should ensure your questions can have answers like yes, no, or "change this line here"
It's not possible to help you debug a complex system
OK๐ข๐ข๐๐
Show what you've done, explain what you want to do, explain what happens, what should happen
OK
Do you know a stopwatch? @bitter oriole
So my game time you have a choice of 5 to 100 minutes of play @Stranger#1927
Game time is the stopwatch
@bitter oriole
You don't need to tag me, explain to everyone
OK
And then by default my timer starts at 05 and you choose for example 20 for the stopwatch, it will seem to work but in game the timer will go back to that default value that's the problem
Where do you choose the time ? In Game ? In the same Map ?
What do you mean, "the timer will go back to that default value"
The timer goes back to this default value which is the minimum of minutes (5min) it is as if it does not save our timer choice
So how do you implemented it
Basically you need to know only two things in multiplayer : RPC and replication
So how did you use them ?
I just did that when the button + (more) of my interface is clicker the minutes increases by one minutes and when it is the button (minus) of my interface which is clicker the minutes decreases by one minutes
I'm sure this problem is not online
@bitter oriole
So why are you asking in #multiplayer ? Does it work in single player ?
Hello... noob here .. struggling with some basic concepts.
Trying to do a basic 3rd person shooter and replicate it (C++)
Completely hit a wall with Character pitch replication. I know that RemoteViewPitch is out there but it's always reporting zero rotator.
@bitter oriole no
@next fable I'd use the ControlRotation
so ditch RemoteViewPitch?
@silent birch So it's not a multiplayer issue - just log the values of variables on the HUD and see what geos wrong
Hi There ! I'm Currently working on a Multiplayer Prototype and i'm having Issues with some Map after Travel. In this map i have object that are net load on client, (Replication is on point) and that need to either move or be enable disable. They are correctly so on Server and sometimes on some client but there seems to be an issues that remains. After some research i've seen that a problem could exist linked to Net Load Object because they have no parents and so the replication is not done as well as Dynamic Object and that seems to be the more obvious lead because all of my Dynamic object are well spawn and moving and Working for everyone. Does Anyone had or had seen this issues and do you know a work around ? I'm about to pass as much as object as i can in dynamic but i cannot do that for all object as some are design as Instance Modify of other BP.
I put it on a hud and it seems to walk in the level of the choice of the timers, the minutes increases well when it is necessary and decreases also when it false but even when I leave the level of the choice of the timer by going at the main menu and then I go back to the level of the timer I see that the timer has gone back to its default value @bitter oriole
@silent birch Do you save your value anywhere ? If not see what object are save between maps
As GameState and PlayerState
My timer is a variable created in the gamestate @pastel elm
OK so how make?
Most obvious here is save data, one way or another
You can also use seamless travel and store this on the player state
if it's single player only
That's what's seamless travel @bitter oriole?
Google it ๐
OK
If the timer is a player state variable will there be more problem? @bitter oriole
If it's in player state and you have seamless travel it should work like you wanted
How to travel safely? @bitter oriole
No idea what that question means
How to make a seamless travel? @bitter oriole
Google it
I saw the meaning but how to achieve it? @bitter oriole
And please don't tag me in every question - everyone here can answer
Look for a tutorial on seamless travel and try that
OK sorry
OK thanks
Why it does not work at the server? (if life is at zero the actor this destroyed)
@dark edge so is the idea to RPC the pitch to the server and then replicate to all simulated proxies?
I'm having issues with a UActorComponent that I create at runtime. It's replicated but somehow the Character value is nullptr
BaseCharacter.cpp
DOREPLIFETIME(ABaseCharacter, CombatComponent);
void ABaseCharacter::PostActorCreated()
{
Super::PostActorCreated();
if (CombatComponentClass.Get()) {
CombatComponent = NewObject<UCombatComponent>(this, CombatComponentClass.Get(), TEXT("Combat Component"));
AddInstanceComponent(CombatComponent);
CombatComponent->AttachToCharacter(this);
}
else {
UE_LOG(LogTemp, Warning, TEXT("No combat component was set on character: %s"), *GetNameSafe(this));
}
}
CombatComponent.cpp
void UCombatComponent::AttachToCharacter(ABaseCharacter* CharacterToAttachTo)
{
Character = CharacterToAttachTo;
}
But when I reach this line in the Combat Componnet, it's saying the Character is a nullptr
void UCombatComponent::BlockPressed()
{
if (GetCharacter()->GetMovementComponent()->IsFalling() || GetStatus() != ECombatStatus::None) {
return;
}
void UCombatComponent::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
PlayerInputComponent->BindAction("Attack", IE_Pressed, this, &UCombatComponent::Attack);
PlayerInputComponent->BindAction("Block", IE_Pressed, this, &UCombatComponent::BlockPressed);
PlayerInputComponent->BindAction("Block", IE_Released, this, &UCombatComponent::BlockReleased);
It's just a FORCEINLINE return Character;
Let me copy it
One sec
in CombatComponent.h
It was working previously when I used CreateDefaultSubobject and there was no BP for the Combat Component, but now that I made the switch to TSubclassOf it's broken. ๐ฆ
Should I list Character as replicated in my Combat Component?
Actually, it looks like it is creating 2 combat components
I solved my problem with the game instance. thanks anyway
one seems to be a BP version of it
If I remove the CombatComponent from being replicated in the character, I only get the BP
Well, the non BP version of it
How to do that when a player goes back to the main menu that is no longer counted as a player of the session?
I set the Character to be replicated but it's still not behaving correctly
Okay, figured it out. I need to make everything replicated, the combat component, character (in combat component), gah
@silent birch you have asked that all day now, people have given answers.
My stopwatch problem I already solved it alone as a big ๐๐ @meager spade
yes but the session one was also answered
The node destroy session does not solve this problem
In order for it to work I do when the exit button is clicker I call the node destroy session, right? @meager spade
I have a bit of code running in my subclass of ACharacter in Tick, however the RemoteViewPitch is always empty. Is there a trick to getting this value activated?
if (!IsLocallyControlled()) {
Pitch = FMath::ClampAngle(RemoteViewPitch / 255 * 360, -60.f,60.f);
}
else {
Pitch = FMath::ClampAngle(GetController()->GetControlRotation().Pitch, -60.f, 60.f);
}
not really
{
SetRemoteViewPitch(GetController()->GetControlRotation().Pitch);
}```
RemoteViewPitch skips owner aswell via DOREPLIFETIME_CONDITION( APawn, RemoteViewPitch, COND_SkipOwner );
so it should be replicated
oh
maybe the tick box
use control pitch
in the character
apart from that, i don't really know
I still do not know what to do
@meager spade ok thanks
i m running this logic on beginplay... it works fine on server but on client... i see an extra actor spawned
any idea why?
yes cause the actor is spawning on all clients again
wrap it in HasAuthority
the grenade is replicated
and when the client recieves the replicated grenade actor
it runs begin play and spawns another copy
begin play is called on clients when a replicated actor first replicates
so client will spawn a local copy, cause you havent gated it
Did you gate the begin play like I said ?
Oh wait nvm
Grenade is a component?
What component are you replicating there ?
i have a character that has a child component which is this bp class
thats spawning a grenade
i made the child component and greande both replicate
Why would you do that ?
You shouldn't replicate that component
Unless you have replicated properties in it
tried without replicating it as well
still same result
got it working... had to make the component itself replicate not the static mesh inside it
random question, lets say i have a no physics object that has its movement replicated. its a stationary object so it only teleports when it moves if that makes sense. when the object is at the same location, is its location continually being networked even when it hasnt moved? or does its position only get networked when the object gets moved (lets say from point A to point B). idk if having an object set to replicate movement when it only would move maybe once or twice every 5 or so minutes is worth doing as i dont know if the location/rotation is continually being networked/using resources when its not moving
this is information from the unreal wiki on replication, I want to think that the FTransform property of an actor also works under this rule @ocean geyser
Only the changes made to replicated properties in the server will be replicated to clients. If a client changes the value of a replicated variable locally then it will stay that way until the next time the server changes it (after which it will be replicated and overwritten on the client). In this sense you should consider a UPROPERTY that is tagged with Replicated to be owned/controlled by the server.```
@ocean geyser I'm pretty certain it only gets replicated out when updated
Hi
Sorry if I bother you but I still have this problem when a player leaves a session he is still counted among the players of the session. I created a HUD that displays the number of players in the session
hey guys I m trying to identify my players in a 4 player mp over the player state, but I'm getting a weird error where 2 players take the same enum
its also completely random and the server just gets one of them
when i'm just printing out
"get player controller-> player state-> get display name"
this is what happens
Zoom on the part on I circled, I do not see well @fossil stratus
Not the solution at my problem?
these are checking if the display name is not equal to Playerstate,..1,..2,..3
if so false this is player1 etc
the name of the player state is local and not useful for determining the order they joined in
ohh thats the problem
if you want to keep track of that you could put an extra variable in the player state that's just a replicated integer which you set in the game mode on join, or something like this
In your game there are 4 clients and 1 server? @fossil stratus
exactly @silent birch and that's the max also
does the server has its own player state? I thaugh the server just holds the game state with the player array filled with all 4 player states
the server is also a player
I'm not sure, but try to put for 5 players not just clients @fossil stratus
make sure you read this https://discordapp.com/channels/187217643009212416/221799385611239424/281042037501984769
Thanks guys will check that out
OK
hello what's the best way to do shooting in multiplayer? Raycast with lag compensation? And like for arrows with gravity that bring down it's possible to throw a arrow and the server simulate physic and to know if it hit somebody ? I suppose raycast is simpler but it's not realistic for arrows and this kind of projectiles. Do you have advise/post/tuto for that? I think I get the way but not really how to start to implement that. Thanks
Does anyone have any tutorials or resourses for multiplayer replication? I'm trying to get the advanced locomotion set to work over multiplayer (so far only server host can use the run extra speed).
@haughty star for arrows, use Projectile Movement Component
it can be affected by gravity, etc
and its replicated
Okay, thanks. But I have to handle lag and more ?
well depends
if its competitive, then sure, or do what fortnite does, and don't do any lag compensation ๐
rockets in fortnite are just spawned on the server (iirc)
so your arrow will just be spawned on server
thing is fortnite uses the clients targeting
so client sends his weapon position and direction he wants to shoot
server just spawns and sends a rocket that way
using projectile movement
yeah but if a people running quickly and you shot arrow in it, with lag during the time of server the information, and throw the arrow it won't never hit right?
that's the issue, and its hard to handle without rewind positions
positions are handle on the player character (at least on ThirdPersonCharacter, etc), to work with lag right? Is it possible to get that position and more?
to use in shooting system? @meager spade
UT4 source code is available and it has a kinda rewind prediction system, but tbh, fast flying arrows, i would be getting them working and see how they behave under lag conditions
but you won't get very far if its blueprint only
you will need to dive into c++
np to go in C++
but get your arrows firing
replicated
and debug the hits
you can simulate lag with NetPktLag in the editor
ok perfect
if it work for arrow I can use same for bullet with high speed ?
it's better than raycast ...
you can create bullet drop?
i don't really have bullet drop, i have damage drop off, but not bullet drop
ok you doesn't create bullet drop
sniper has bullet drop
how to create bullet drop with raycast?
you would need to do it based on distance
with a curve
further away the hit location is
the lower the Z location will be
and with a curve you can kinda simulate the gravity pull on the bullet
to do a curve, you're doing yourself with little raycast ?
they're is build in curve raycast?
no you would have to make the curve
Just saying, since you guys do real-ish gun stuff, bullet trajectories are actually parabolic meaning that the bullet will go up. AFAIK.
Hi Guys !
About Net Dormancy does an Awake actor can stop replicate if net load on client and maybe client was loading to fast or anything ? I have an issues with actors being not replicate after a travel on a certain map but if i travel again on another map, no problems and if i start on the sus-mention first map i don't have any issues either.
not in real life
the bullet actually rises slightly before dropping
due to the earth curve aswell
you think the bullet will go up, it's just because you're zeroting your weapon to a given distance
maybe but that's is really nothing
the major thing is the bullet drop
I have pinpoint my issues this is linked to the fact that in Seemless travel my player load faster than the server and doing so when the server finish to load he flush out theClientVisibleLevelNames array. Is there any way to ask my client to wait for the server to fully load the map before accessing it or not ?
For bullet trajectory with raycast you can just do a loop and add velocity each time