#multiplayer

1 messages ยท Page 501 of 1

meager spade
#

@grizzled stirrup repping a struct property is better than a rpc

#

as only changed values get repped, not the entire strue

#

struct*

#

RPC will send the entire struct

viscid bronze
#

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?

thin stratus
#

Is this called by a serverRPC of sorts?

viscid bronze
#

it's in the player controller

thin stratus
#

It's not? :P

#

The image above is the character

#

Is the code called by a serverRPC?

viscid bronze
#

no, i don't think it is its directly copied over from the player controller i developed in a single player environment

thin stratus
#

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

viscid bronze
#

ah so that's why
thx I'll go look it up

thin stratus
#

Check out the pinned compendium of this channel

#

4th link from the top

#

@viscid bronze

worthy perch
#

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).

viscid bronze
#

@thin stratus alright sure thing

dark edge
#

@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

viscid bronze
#

@dark edge i disable ground friction before launch

#

and use stop character movement to stop him

normal spindle
#

hello : D

#

is there a way to replicate ragdoll location?

thin stratus
#

@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.

viscid bronze
#

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

faint dock
#

if you do this logic in the player character you dont need to do all that

#

@viscid bronze

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

faint dock
#

then you dont need to use get player character you are already in it

viscid bronze
#

ok the Get Velocity doesnt give complier error when without Get Player Character
but Get Camera Rotation needs Get Player Camera Manager

#

@faint dock

faint dock
#

just get the camera from the component list top left

viscid bronze
faint dock
#

you dont need getworldrotation

#

just get forward vector form the camera

viscid bronze
#

oh, okay cool

silent birch
#

In my game because of the random spawn, when a player joins a session he appears in the void in the sky

#

Why?

dark edge
#

@silent birch what do you mean by random spawn?

silent birch
#

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

silent birch
#

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

dark edge
#

@silent birch you need to override the Get Default Pawn Class for Controller function in GameMode.

silent birch
#

I know but how to replace it? @dark edge

thin stratus
#

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

silent birch
#

Which replacement button? @thin stratus

thin stratus
silent birch
#

In the game mode?

thin stratus
#

:P Just try to check for yourself

silent birch
#

OK

#

So I do not need to create a function for random Spawn? @thin stratus

dark edge
#

Are you trying to spawn a random pawn or spawn it at a random location?

silent birch
#

Spawn it at a random location and It already works but my problem is something else @dark edge

meager spade
#

remove default pawn from the GameMode if you are spawning your own pawns

#

and not using the default pawn class

grizzled stirrup
#

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

thin stratus
#

Try to find the named session first

#

Like

#

in the actual sessions array

grizzled stirrup
#

I tried GetNamedSession(NAME_GAMESSION);

thin stratus
#

And?

grizzled stirrup
#

It still crashes

silent birch
#

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

grizzled stirrup
#

I did it in an if check though

thin stratus
#

@grizzled stirrup And the crash says?

grizzled stirrup
#

It made it past the if check

meager spade
#

do you have a player already on the level ?

#

i have seen that before

grizzled stirrup
#

if (GetNamedSession(GameSessionName))
{
    // Session interface nullptr checks here etc.
    ....

    SessionInterface->StartSession() etc crashes here
}
silent birch
#

Yes @meager spade yes

meager spade
#

delete it

#

you don't need it

#

one will be created automatically

silent birch
#

I answered wrong. there is not a player on the level @meager spade

meager spade
#

:/

#

well screenshots of what is happening

#

also your spawn point choosing code

silent birch
#

OK

#

Wait

thin stratus
#

@grizzled stirrup callstack, crashlog, etc.?

grizzled stirrup
#

I'll get it now

#

That would be the correct way to check if a session is valid though right?

worthy perch
#

What does GetNamedSessions return when it can't find anything?

grizzled stirrup
#

Yeah I may need to move it out of the if check

#

And have it return something then check if that is null

thin stratus
#

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

grizzled stirrup
#

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

thin stratus
#

If it does go through the if check, check what that pointer returns

#

attach it to vs and breakpoint

grizzled stirrup
#
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

worthy perch
#

I don't quite understand what GetNamedSession does -- when would you want to use it?

grizzled stirrup
#

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

thin stratus
#

GetNamedSession does not return true

#

It returns a pointer ot the session

#

AHA

#

EDITED, i see

grizzled stirrup
#

Sorry I meant my GetIsSessionValid() function returns true ๐Ÿ˜„

thin stratus
#

@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

worthy perch
#

Oh, alright. That makes sense. I misunderstood its context.

thin stratus
#

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

grizzled stirrup
#

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

thin stratus
#

You don't have to package for that

grizzled stirrup
#

Will do!

thin stratus
#

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

grizzled stirrup
#

I set the join in progress bool to false and update the session in the same call

thin stratus
#

I have a PIE check but not for that

grizzled stirrup
#

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!

silent birch
#

Sorry for the picture

glad wharf
#

can't you do a print screen? Kind of difficult to read what you sent ๐Ÿค”

thin stratus
#

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

silent birch
#

0 is at minimum

thin stratus
#

And 0 -1 is? :P

#

Instead of Length, use "LastIndex"

#

And then remove the -1

meager spade
#

also you need to kind of reserve the spawn point

silent birch
#

Why last inex @thin stratus?

meager spade
#

if you have 5 spawn and 5 players connect, 2 can end up on the same point

thin stratus
#

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?

silent birch
#

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

thin stratus
#

I said remove the -1

silent birch
#

OK @meager spade

meager spade
#

do you know the answer to eXi's question?

#

@silent birch

silent birch
#

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

meager spade
#

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

silent birch
#

In my game there are too many points of appearance (uncountable)

meager spade
#

it doesnt matter, just listen and follow

#

what would be the Length?

#

@silent birch

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

meager spade
#

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?

silent birch
#

OK

#

6?

meager spade
#

why would it be 6?

#

5 items in the array

#

would be 5

thin stratus
#

I would love to have that array to throw some euros into

meager spade
#

๐Ÿ˜„

silent birch
#

Because I was told that in a computer table the value starts not 0 not 1

meager spade
#

so length is 5, @silent birch

#

5 items == 5 length

#

you are doing 0 - 5, but 5 is not a valid index

thin stratus
#

@silent birch The "Starts at 0" is correct, but you have to shift the end index too

silent birch
#

OK

thin stratus
#

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

silent birch
#

OK

meager spade
#

do you understand now @silent birch ?

silent birch
#

Yes

thin stratus
#

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

meager spade
#

this is what you should be doing @silent birch h

silent birch
#

So if I use the last index I do not do -1?

thin stratus
#

Correct

meager spade
#

also like i said above, you would want to reserve spawn points once they are used

#

as they could be picked again

silent birch
#

OK

meager spade
#

i did mine by shuffling the array, and just going sequential ๐Ÿ˜„

#

it works for testing, for now

silent birch
#

I have to use the get all actor of class? for appearance points

meager spade
#

@thin stratus you ever used PrimaryDataAssets?

thin stratus
#

That's just DataAssets exposed to BPs, right?

meager spade
#

no its an asset which is not loaded until manually loaded

#

contains a bunch of soft pointers

thin stratus
#

We are doing that somewhere in an internal project

#

I didn't touch them myself

meager spade
#

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

silent birch
#

I have to use the get all actor of class? for appearance points

meager spade
#

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

thin stratus
#

@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?

silent birch
#

Thanks I try

#

Does this solve my problem with the appearance of two actors?

meager spade
#

how do we know?

#

its your game

#

test it

silent birch
#

OK

#

It did not solve. the designated character in the game mode always appears

meager spade
#

you need to disable the spawning of the default pawn

silent birch
#

Where?

#

Is it possible to get the appearance points on which the character appeared? @meager spade

meager spade
#

what is appeareance points?

silent birch
#

Target points (in my game)

#

So?

meager spade
#

you mean Spawn Points?

silent birch
#

Yes

#

So?

thin stratus
#

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

silent birch
#

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

thin stratus
#

That's a different problem though

#

First you have to make sure that your character only spawns once for each player

silent birch
#

It only appears once

#

Then?

silent birch
#

Not the solution?

silent birch
#

Hi adriel

dark edge
#

@silent birch Start from the beginning. What EXACTLY are you trying to do?

silent birch
#

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

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.

silent birch
#

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

dark edge
#

You need to call Possess for everyone.

silent birch
#

Yes I did it @dark edge

#

But it does not work @dark edge

dark edge
#

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.

silent birch
#

I don't understand

dark edge
#

Show a screenshot of where you are calling possess

silent birch
#

That's the screenshot

dark edge
#

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

silent birch
#

OK

#

So?

dark edge
#

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.

silent birch
#

How make? @dark edge

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

meager spade
#

i am sure there is documentation on this all over the forums

#

its very common and basic

silent birch
#

Then?

#

So I'm doing my code in the game mode?

meager spade
#

i am sure GameMode has Choose Player Start function

#

you don't need to do any possessing or anything

silent birch
#

In game there is no player start @meager spade

meager spade
#

there is

silent birch
#

There is?

meager spade
#

if you are using the same character

#

just use this to provide a start point

#

and delete your other stuff

silent birch
#

Get all actor of class (for the target points)? @meager spade

meager spade
#

target points?

silent birch
#

Yes

#

So? @meager spade

meager spade
#

i don't understand what you are going on about

#

what is Target Points?

silent birch
#

In my game did not put any player start in my game but I have it is replaced by target points @meager spade

meager spade
#

do you have default pawn set?

#

ok

#

well use "Target Points" then

silent birch
#

No default character but random appearance @meager spade

hoary lark
silent birch
silent birch
#

Apparently it worked but the client seems to be spawn almost in the same place

viscid bronze
#

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

silent birch
#

@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

viscid bronze
#

kay looking switch has authority up in documentation

silent birch
#

I don't understand @viscid bronze

#

What do you say in your last sentence? @viscid bronze

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

silent birch
#

Host client is server?

vocal flint
#

Is it possible to do multiplayer if your developing from a mac

viscid bronze
#

@silent birch no its running on a dedicated server with 2 clients

silent birch
#

OK

#

I don't know anything about on the dedicated server

#

Sorry @viscid bronze

viscid bronze
#

@silent birch its alright ill ask elsewhere

dark edge
#

@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.

vocal flint
#

from what ive seen visual studio is used for multiplayer on windows and its just not the same on mac

viscid bronze
#

isnt there a visual studio equivalant on mac

meager spade
#

@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?

silent birch
#

No it's good it already worked @meager spade

meager spade
#

it's not good tho @silent birch, you really should specify what actor to spawn at.

viscid bronze
#

@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

meager spade
#

yeah but you are also using GetPlayerCharacter0

#

which is very bad practice for multiplayer unless you understand what is happening

silent birch
#

I have a lot of knowledge to make a game like my game @meager spade

viscid bronze
#

@meager spade yes i kinda have an idea of why that's not suitable but is there a replacement

meager spade
#

well what is OtherActor going to be on that node?

#

the player who overlapped it

#

cast that to the player

viscid bronze
#

um how do i do that
i already cast to ThirdPersonBlueprint

peak star
#

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

worthy perch
#

That can take all day to compile.
It's like an hour on a mediocre computer.

dark edge
#

It took me 24 hours to compile one time, but I was compiling it on a $10 month digitalocean cloud server LOL

viscid bronze
#

what are you guys talking about i just ran it game and ticked "run dedicated server" under the play button

dark edge
#

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

viscid bronze
#

i see. i still have no idea but im new so i will probably get to that like years later

dark edge
#

@viscid bronze if you knew just focus on learning how the engine works.

viscid bronze
#

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

dark edge
#

Make it replicated and change it on the server.

viscid bronze
#

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

thin stratus
#

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)

viscid bronze
#

idk iif it is replicated but i can see it on both clients
also nice book

thin stratus
#

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

viscid bronze
#

replicates in replication is unchecked

thin stratus
#

But it's placed in the level?

viscid bronze
#

yes it is

#

and both clients can see

thin stratus
#

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

viscid bronze
#

ok sure i will try to implement this

meager spade
#

also networking a single player built game is a pain ๐Ÿ˜„

thin stratus
#

Yeah never build SP first

#

xD

meager spade
#

cause you would have used many "bad" practices that work fine for single player, but will break/fail/do something undefined in Multiplayer

vivid fjord
#

yeah, theres quite alot you can get away with in a singleplayer game that will quickly bring your MP game to its knees

viscid bronze
#

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

thin stratus
#

First of all

#

Second of all, this is a multiplayer game

#

You have to mark stuff like that boolean as replicated

viscid bronze
#

aight noted i will go do that now

meager spade
#

also for simplicity sake, just run this on the server

viscid bronze
#

@meager spade how do i do that to a blueprint

meager spade
#

HasAuthority

viscid bronze
meager spade
#

i would be checking if the other actor is authority

viscid bronze
#

ohh so thats what that function was

meager spade
#

remove the other one

#

what i shown you will be fine

viscid bronze
#

good now i got this
i dont think any of them have authority tho, the blueprint is not working now

meager spade
#

there is always an authority

#

you say its not working

#

but have you placed break points

viscid bronze
#

what's that

meager spade
#

worth reading

viscid bronze
#

yes i did some breakpoints and this

yes it has authority but its still not running the rest of the blueprint hold on

meager spade
#

print string aint break points

viscid bronze
#

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

meager spade
#

where is it not changing

#

on the client?

viscid bronze
#

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:

meager spade
#

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

viscid bronze
#

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

meager spade
#

so

#

mark the bool as replicated

#

when the server sets it the client will set it

viscid bronze
#

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

dark edge
#

@viscid bronze what triggers the weapon switch?

viscid bronze
#

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

dark edge
#

@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

peak star
#

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

sonic ice
#

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.

twin juniper
#

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?

peak star
#

@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.

dark edge
#

@sonic ice can you confirm that all of that logic is running on server only?

sonic ice
#

@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.

valid cliff
#

hmm

#

I think when the client presses F, the server's IsPressed stays false, so the top part never runs

dark edge
#

@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

sonic ice
#

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?

#

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 ๐Ÿ™‚

vocal ridge
#

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)

dark edge
#

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

silent birch
#

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

meager spade
#

@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

winged badger
#

and storing is done via StartSpot AActor* in the PC

dark edge
#

Ah aight so "occupied" isn't really a claim on a spot, just checking if the pawn can actually fit there. gotcha.

ember needle
#

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?

silent birch
#

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

graceful geyser
#

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?

twin juniper
#

@silent birch I guess u set the event to not replicate

silent birch
#

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

graceful geyser
#

@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.

silent birch
#

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

twin juniper
#

@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

silent birch
#

OK

meager spade
#

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

graceful geyser
#

@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.

zealous saffron
#

I've been storing my timer handlers in the gamestate

#

unreplicated

#

client and server have their copies of it

graceful geyser
#

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?

zealous saffron
#

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

pseudo iris
#

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?

zealous saffron
#

it will work if it's done correctly

#

something is wrong with your HUD

#

because you said the replication is working

graceful geyser
#

@zealous saffron So a multicasted event updates both Server and Client gamestates

zealous saffron
#

yes

#

check the RPC docs

graceful geyser
#

Gotcha. I've read through them, this is helping to solidify my understanding. Thanks!

abstract iris
#

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

twin juniper
#

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??

thin stratus
#

wrong channel?

#

@twin juniper

dark edge
#

Where should I put my setup stuff where i can guarantee the controller and pawn exist and pawn is possessed?

dark edge
#

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.

worthy perch
#

What's your alternative to OnRep?
Also, to answer your previous question, there should be something like OnPossessed.

dark edge
#

@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.

meager spade
#

OnRep is ok, i think attached stuff is also always replicated to later joiners

#

also OnRep to switch UI seems a bit odd aswell

dark edge
#

How else would you drive UI switching by state?

fossil stratus
#

How would you identify different replicated players in a multiplayer game?

meager spade
#

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

fossil stratus
#

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? ^^

meager spade
#

PlayerArray should be ordered

#

based on connection

#

also you should be using PlayerState

#

to hold this info

dark edge
#

How do you guys deal with references being replicated before the actual object is?

meager spade
#

in what context @dark edge

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

fossil stratus
#

Thanks @meager spade

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

dark edge
#

Yeah it is.

meager spade
#

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?

dark edge
#

hm maybe. I could probably trigger the registration from the parts Begin Play.

meager spade
#

yeah as that is run on client when they get the actor

dark edge
#

god that just feels so hacky. Then i gotta make sure the parent vehicle is valid before calling registration on it

unreal pine
#

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?

gleaming bobcat
#

Is it possible to pass UObject derivered class to RPC and have it replicated ?

thin stratus
#

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

gleaming bobcat
#

I think I understand now how it works. Thanks

#

Subobject replication is quite slow so I have to use USTRUCT then

silent birch
#

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?

meager spade
#

no

#

from the character who has no health and is dying

#

@gleaming bobcat its not slow

silent birch
#

But must be done in which Blueprint? @meager spade

#

I don't understand

meager spade
#

the character who has died

#

why would you do it in any other blueprint?

silent birch
#

So in the character's Blueprint?

meager spade
#

of course

#

why would the weapon handle the character dying?

#

or whatever

silent birch
#

With what Node in the beginning?

meager spade
#

what do you mean what node?

#

you have to make the code

#

its not built in

silent birch
#

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?

unreal pine
#

@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

silent birch
#

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

unreal pine
#

I usually call them happy little strings

silent birch
#

How?

unreal pine
#

I don't understand what you're asking me

silent birch
#

How to mention a channel

unreal pine
#

you just put a # in front of it

silent birch
#

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

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?

silent birch
#

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

unreal pine
#

customer... are you trying to say client?

silent birch
#

Yes

unreal pine
#

Not everything that happens on the server gets replicated to the client. Recommend looking up some youtube tutorials about replication and how it works

silent birch
#

I know

unreal pine
#

I mean

#

do you?

fluid flower
#

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?

unreal pine
#

@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.

silent birch
#

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?

unreal pine
#

is the main menu a level, or is it a widget?

silent birch
#

I don't understand @fluid flower

#

Is a Level @unreal pine

unreal pine
#

@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

fluid flower
#

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?

unreal pine
#

@silent birch check out page 80 of that PDF I linked you

silent birch
#

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

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

silent birch
#

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

fluid flower
#

yeah it's the default behaviour but is there a way to change it?

silent birch
#

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

fluid flower
#

not sure what you mean

#

for testing purposes, I want to basically see ALL sessions

#

full, empty, etc ๐Ÿ™‚

silent birch
#

In your game what is the maximum number of possible players?

fluid flower
#

it depends on the map

silent birch
#

OK

fluid flower
#

sometimes 4, some maps 10 etc

#

small maps = 4, big maps 10

silent birch
#

why the person who plays can not choose himself the maximum of players? @fluid flower

fluid flower
#

because the maps are built for specific number of players

silent birch
#

OK

unreal pine
#

@fluid flower you using advanced steam sessions? Cause if not, I highly recommend it

fluid flower
#

so it seems that it's not possible to show full sessions, by design ๐Ÿ˜ฆ

#

was just now on the steamworks dev forums

unreal pine
#

Yeah I was thinking that may have been a steam thing

fluid flower
#

yeah ๐Ÿ˜ฆ

silver lotus
#

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"

fossil stratus
#

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

dark edge
#

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.

split drum
#

@fossil stratus i use playerState->UniqueId for some of what you described

peak star
#

@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

dark edge
#

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

split drum
#

is there a good reason not to validate them?

dark edge
#

I mean I'd be doing a validate like 100 times a tick lol

split drum
#

i wonder how slow it actually is? If you try it and measure the impact i'd be curious to know

dark edge
#

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.

split drum
#

haha that's quite a few arrays

mighty rover
#

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

mighty rover
#

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.

worthy perch
#

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;
fossil stratus
#

Thanks @split drum will try it out today sounds like the exact thing i was searching for^^

flint rose
#

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. ๐Ÿ™‚

silent birch
#

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?

thin stratus
#

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.

unique kelp
#
         UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
        void ServerRequestDisconnect();
        bool ServerRequestDisconnect_Validate() { return false; }
        void ServerRequestDisconnect_Implementation() {};
#

how disgusting is this?

chrome bay
#

lmao

#

if it works...

unique kelp
#

It does, but I dont feel so good

chrome bay
#

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

unique kelp
#

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

chrome bay
#

Not sure how the game works but yeah should just be able to open a new map and it'll leave automagically

viscid bronze
#

hello where is AdvancedSessions.build.cs because when using Advanced Sessions plugin and building it told me to change something in here

unique kelp
#

Probably in that plugin folder

viscid bronze
#

where is the plugin folder

#

@unique kelp

#

nvm @unique kelp i found it i think

bitter oriole
#

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

viscid bronze
bitter oriole
#

Yes, you are missing the plugin. Where did you install it ?

viscid bronze
#

in my engine
i suddenly remembered
because some guy in a tutorial told me to

bitter oriole
#

Move it to your project

thin stratus
#

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?

viscid bronze
#

the entire plugins folder? @bitter oriole

bitter oriole
#

The plugin

#

@thin stratus My guess would be that no, they shouldn't

thin stratus
#

Hmpf, but they do

#

My guess was also that they shouldn't

bitter oriole
#

Unless net cull is for replication specifically

#

Which would kind of make sense

thin stratus
#

The actor obviously doesn't despawn like other actors that are spawned manually cause it net loads on the client

bitter oriole
#

If it's a level actor it should never despawn, so that part makes sense

thin stratus
#

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

bitter oriole
#

That ?

thin stratus
#

Yeah, pretty old but that's the basics of it

bitter oriole
#

Sounds a lot like "no RPC outside of relevancy" to me.

#

Is it a Reliable RPC ?

#

IIRC only Unreliable RPCs are relevant-enabled

thin stratus
#

I can try

bitter oriole
#

Since Reliable means "reach the other machines at any cost"

thin stratus
#

You are right, it stops if unreliable

#

Thanks, that answers my question

bitter oriole
#

Eh.

viscid bronze
#

kay @bitter oriole i have copied the AdvancedSessions

#

folder

#

if i copy the AdvancedSessions plugin to my project folder can I just delete the one in Engine folder

bitter oriole
#

You should

viscid bronze
#

Thanks @bitter oriole good to know

hoary lark
#

(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)

chrome bay
#

Live Coding works fine for me

#

Hot Reload never does

hoary lark
#

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.

silent birch
#

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?

thin stratus
#

Call DestroySession on the client that left

#

So basically when entering the mainmenu

silent birch
#

I tried but it does not work @thin stratus

thin stratus
#

That's the only way to do it

silent birch
#

The player who went back to the main menu was always counted among the players of the session @thin stratus

thin stratus
#

That removes the client from the session

glad wharf
#

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 :/

worthy perch
#

Hmm, maybe it's because you need the question mark? ?listen
Don't know what StartOnlineGameComplete is.

glad wharf
#

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

worthy perch
#

Yeah, alright. Just making sure.

glad wharf
#

(however, I see in the logs that the level is started in listen mode)

worthy perch
#

And you call StartSession after that?

glad wharf
#

WELL, no I think not. Just after OpenLevel?

worthy perch
#

I also used the wiki:

if (bInWasSuccessful) {
        OnStartSessionCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(OnStartSessionCompleteDelegate);
        // Our StartSessionComplete delegate should get called after this.
        Sessions->StartSession(InSessionName);
    }
glad wharf
#

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."));
    }
}
silent birch
#

So how do you make it no longer counted among the players who are in the session?

glad wharf
#

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)

silent birch
#

Not the solution?

glad wharf
#

@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 ๐Ÿ˜ฆ

silent birch
#

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

worthy perch
#

Everything seems right... if you're really out of ideas. I did hear that bIsLANMatch = false is best whether or not you use LAN.

glad wharf
#

thanks will try that ๐Ÿ™‚

silent birch
#

Despite that, it does not work

glad wharf
#

bIsLanMatch = false does not solve the problem ๐Ÿ˜ฆ Will continue to investigate, thanks for your help @worthy perch !

silent birch
#

Sorry, you have not of solution at my problem?

glad wharf
#

Sorry Nathan I don't know

#

About my prob, I'm suspecting I'm doing something wrong with the session name / FName

silent birch
#

OK

#

You did not understand what I mean or you do not have the solution to my problem? @glad wharf

worthy perch
#

return Sessions->CreateSession(*InUserId, GameSessionName, *SessionSettings);
Sessions->DestroySession(GameSessionName);
It's just a macro for differentiating Game and Party sessions. Very confusingly named, imo.

glad wharf
#

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 ๐Ÿ™‚ )

worthy perch
#

Guess not, it's this:

#define GameSessionName NAME_GameSession
#define PartySessionName NAME_PartySession
#define GamePort NAME_GamePort
#define BeaconPort NAME_BeaconPort
glad wharf
#

woooow ok will change that and see. I thought it was a way to differentiate servers from different games

silent birch
#

@glad wharf OK

worthy perch
#

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.

glad wharf
#

thanks so much for this explanation, I was way off! Currently compiling to see if it solves it...

#

YEAY! That was it! Thanks ๐Ÿ˜„ ๐Ÿ˜„

silent birch
#

Please, I'm always looking for a solution to my problem for info

cedar heart
#

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?

meager spade
#

replicating physics is a nightmare

#

most of the time its just simulated on the clients

cedar heart
#

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 ๐Ÿค”

silent birch
#

Sorry if I bother you but you still have no solution to my problem?

peak star
#

@cedar heart might be better to handle cube pushing kinematically instead of using physX physics simulation

#

If you can

cedar heart
#

Yes this could be better - maybe implement custom adding of force to cube on player collision and then send to all clients ๐Ÿค”

silent birch
#

I made a system of choice of time

#

But after doing so, the game starts again as it is by default

dark edge
#

@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.

cedar heart
#

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

silent birch
#

So me? Please

bitter oriole
#

@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

silent birch
#

OK๐Ÿ˜ข๐Ÿ˜ข๐Ÿ˜๐Ÿ˜‘

bitter oriole
#

Show what you've done, explain what you want to do, explain what happens, what should happen

silent birch
#

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

bitter oriole
#

You don't need to tag me, explain to everyone

silent birch
#

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

pastel elm
#

Where do you choose the time ? In Game ? In the same Map ?

bitter oriole
#

What do you mean, "the timer will go back to that default value"

silent birch
#

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

bitter oriole
#

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 ?

silent birch
#

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

bitter oriole
#

So why are you asking in #multiplayer ? Does it work in single player ?

next fable
#

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.

silent birch
#

@bitter oriole no

dark edge
#

@next fable I'd use the ControlRotation

next fable
#

so ditch RemoteViewPitch?

bitter oriole
#

@silent birch So it's not a multiplayer issue - just log the values of variables on the HUD and see what geos wrong

pastel elm
#

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.

silent birch
#

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

pastel elm
#

@silent birch Do you save your value anywhere ? If not see what object are save between maps

#

As GameState and PlayerState

silent birch
#

My timer is a variable created in the gamestate @pastel elm

bitter oriole
#

Sounds like you need save data here.

#

Level changes reset your game

silent birch
#

OK so how make?

bitter oriole
#

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

silent birch
#

That's what's seamless travel @bitter oriole?

bitter oriole
#

Google it ๐Ÿ™‚

silent birch
#

OK

#

If the timer is a player state variable will there be more problem? @bitter oriole

bitter oriole
#

If it's in player state and you have seamless travel it should work like you wanted

silent birch
#

How to travel safely? @bitter oriole

bitter oriole
#

No idea what that question means

silent birch
#

How to make a seamless travel? @bitter oriole

bitter oriole
#

Google it

silent birch
#

I saw the meaning but how to achieve it? @bitter oriole

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

silent birch
#

OK sorry

#

OK thanks

#

Why it does not work at the server? (if life is at zero the actor this destroyed)

next fable
#

@dark edge so is the idea to RPC the pitch to the server and then replicate to all simulated proxies?

flint rose
#

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);
meager spade
#

where is GetCharacter()

#

i don't see it

flint rose
#

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?

silent birch
#

I solved my problem with the game instance. thanks anyway

meager spade
#

one seems to be a BP version of it

flint rose
#

If I remove the CombatComponent from being replicated in the character, I only get the BP

#

Well, the non BP version of it

silent birch
#

How to do that when a player goes back to the main menu that is no longer counted as a player of the session?

flint rose
#

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

meager spade
#

@silent birch you have asked that all day now, people have given answers.

silent birch
#

My stopwatch problem I already solved it alone as a big ๐Ÿ‘๐Ÿ˜ @meager spade

meager spade
#

yes but the session one was also answered

silent birch
#

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

next fable
#

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);
}
meager spade
#

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

silent birch
#

I still do not know what to do

next fable
#

@meager spade ok thanks

gray scroll
#

i m running this logic on beginplay... it works fine on server but on client... i see an extra actor spawned

#

any idea why?

meager spade
#

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

gray scroll
#

@meager spade

#

still 2 grenades coming

#

grenade is set to replicate

meager spade
#

Did you gate the begin play like I said ?

#

Oh wait nvm

#

Grenade is a component?

#

What component are you replicating there ?

gray scroll
#

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

meager spade
#

Why would you do that ?

#

You shouldn't replicate that component

#

Unless you have replicated properties in it

gray scroll
#

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

ocean geyser
#

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

harsh lintel
#

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.```
dark edge
#

@ocean geyser I'm pretty certain it only gets replicated out when updated

silent birch
#

Hi

silent birch
#

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

fossil stratus
#

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

#

when i'm just printing out
"get player controller-> player state-> get display name"
this is what happens

silent birch
#

Not the solution at my problem?

fossil stratus
#

if so false this is player1 etc

fleet raven
#

the name of the player state is local and not useful for determining the order they joined in

fossil stratus
#

ohh thats the problem

fleet raven
#

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

silent birch
#

In your game there are 4 clients and 1 server? @fossil stratus

fossil stratus
#

exactly @silent birch and that's the max also

silent birch
#

So why did not you do up to 5 but only 4? @fossil stratus

fossil stratus
#

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

fleet raven
#

the server is also a player

silent birch
#

I'm not sure, but try to put for 5 players not just clients @fossil stratus

fleet raven
silent birch
#

That's true the server is also a player @fossil stratus

#

Please help me

fossil stratus
#

Thanks guys will check that out

silent birch
#

OK

haughty star
#

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

twin juniper
#

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).

meager spade
#

@haughty star for arrows, use Projectile Movement Component

#

it can be affected by gravity, etc

#

and its replicated

haughty star
#

Okay, thanks. But I have to handle lag and more ?

meager spade
#

well depends

#

if its competitive, then sure, or do what fortnite does, and don't do any lag compensation ๐Ÿ˜„

haughty star
#

How do fortnite?

#

If there is a easy way that's cool

meager spade
#

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

haughty star
#

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?

meager spade
#

that's the issue, and its hard to handle without rewind positions

haughty star
#

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

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++

haughty star
#

np to go in C++

meager spade
#

but get your arrows firing

#

replicated

#

and debug the hits

#

you can simulate lag with NetPktLag in the editor

haughty star
#

ok perfect

#

if it work for arrow I can use same for bullet with high speed ?

#

it's better than raycast ...

meager spade
#

i use raycast for fast firing weapons

#

projectile for sniper/rockets

haughty star
#

you can create bullet drop?

meager spade
#

i don't really have bullet drop, i have damage drop off, but not bullet drop

haughty star
#

ok you doesn't create bullet drop

meager spade
#

sniper has bullet drop

haughty star
#

how to create bullet drop with raycast?

meager spade
#

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

haughty star
#

to do a curve, you're doing yourself with little raycast ?

#

they're is build in curve raycast?

meager spade
#

no you would have to make the curve

haughty star
#

okok cool

#

thanks @meager spade I will try some code and try to improve it

worthy perch
#

Just saying, since you guys do real-ish gun stuff, bullet trajectories are actually parabolic meaning that the bullet will go up. AFAIK.

pastel elm
#

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.

haughty star
#

@worthy perch no, the bullet always will go down

#

down****

meager spade
#

not in real life

#

the bullet actually rises slightly before dropping

#

due to the earth curve aswell

haughty star
#

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

pastel elm
#

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 ?

chrome bay
#

For bullet trajectory with raycast you can just do a loop and add velocity each time