#multiplayer

1 messages ยท Page 374 of 1

winged badger
#

and execute only if it is

#

(its more bandwidth friendly option, and it will also make clients calculate their own linetraces, instead of server doing it for them)

frank tinsel
#

thank you Zlo. I'll give it a try

frank tinsel
#

Worked like a charm

#

@winged badger Thank you

graceful cave
#

when i enable seamless travel in the lobby game mode, nobody loads the next map including the host

#

but when its disabled everyone loads in

#

what might cause this?

twin juniper
#

Is there a way to add input delay to a InputAction?

#

So that if I am calling an RPC on a input action the player cant just spam

mild hull
#

you could ignore that input until the result of the RPC comes back

pallid mesa
#

you want to... just ignore the input completely

#

or make the input delayed?

#

because if your objective is to prevent spamming

#

you can make something like

twin juniper
#

Yeah

#

I did a test with an auto clicker on my server spamming E at a rate of 10 every milisecond

#

and the server

#

just took a shit

#

lol

pallid mesa
#

I have a ton of those

#

let me send you an example

#
if(LastTimeAttack + 0.5f <= GetWorld()->GetTimeSeconds()){
    Attack();
    LastTimeAttack = GetWorld()->GetTimeSeconds();
}
#

that .5f is my "anti retarded input" barrier

#

xD

twin juniper
#

Lol

#

So you are just cachine the last time, you hit that input

#

and seeing its been more than .5 seconds

#

lel

pallid mesa
#

ye xD

twin juniper
#

seems simple enough

pallid mesa
#

.5 could be a variable

twin juniper
#

would be useful though

mild hull
#

you could also count and send them as one rpc, if they is any need

twin juniper
#

if this could be done globally

#

to ALL inputs

#

Instead of having to constantly check

pallid mesa
#

you can... make your own input system

#

xD

twin juniper
#

yea

pallid mesa
#

I... made mine

twin juniper
#

unreal could add a little thing

#

to enter a number

#

lel

#

if 0, no delay

pallid mesa
#

then you treat that array as you want

#

but for your problem xD I would only do that check in those inputs that are abused

twin juniper
#

oh

pallid mesa
#

/ functions or so

twin juniper
#

InputKey() is called

#

before the input

#

goes through

#

and im assuming if it returns false, it doesnt go through

#

lol

pallid mesa
#

welp check the parent in the viewport client class

#

there is not a real way to extend the raw input functionality without editing the engine directly

twin juniper
#

Lol

#

that description tho

#

check a key

#

lel

pallid mesa
#

hahahahha

#

dude go to VS

twin juniper
#

๐Ÿ˜„

pallid mesa
#

don't look at the docs

#

you can...

#

certainly override the behaviour of what happens every-time

#

the input stack gets refreshed on the controller

#

and maybe, just maybe, you will be able to add manual latency there by erasing the stack content every x seconds or so

twin juniper
#

ive got an idea

#

@pallid mesa also though

#

you know your solution would be client sided

#

im assuming righht?

#

so someone could just reeset

#

LastAttack

#

lol

#

or change that value

pallid mesa
#

well this solution comes from a SP game, and I use it for a cooldown system

#

but yes, you are right, it is totally client side

twin juniper
#

though what i can say is that its better than what i currently have

pallid mesa
#

on the function that is getting rpc'ed you can do this same check but server side

twin juniper
#

which is noithing lel

#

i would rather have a client sided solution for now

#

than have nothing

#

lel

pallid mesa
#

but you got a big point there

#

never trust the client ๐Ÿ‘

twin juniper
#

xD

#

though...

#

couldnt u just

#

replicate "TimeSinceLastInput"

#

and also

#

the idea is to

#

"not" use the server for this i feel

#

as much as possible

#

we want a client sided check first

#

then server sided check

#

before proceeding with the rest of the server rpc's

#

in my opinion this would be the best solution

#

What do you think? lol

pallid mesa
#

aye you can combine both solutions, for sure.

twin juniper
#

Basically... Do the check on the client first, if it passes, try it on the server, if it passes on the server, proceed with the rest of the code we need to do.

pallid mesa
#

also don't be afraid of input stashing as long as the function is not very taxing ๐Ÿ‘

twin juniper
#

what do u mean?

#

"stashing"

pallid mesa
#

user input can never be fast enough to saturate a network on a lightweight function

#

it depends also the situation

#

and the game and so on...

twin juniper
#

i mean

#

it can

#

if ur like

#

using an auto clicker lol

#

Spam 10 inputs per 1 milisecond

#

But that requires the user to use an external script

#

lol

#

its "unnatural" input

pallid mesa
#

sure, yeah seeing it that way xD

#
void yoquese::StartFire()
{
    if (GetOwnerRole() < ROLE_Authority)
    {
        ServerStartFire();
    }

    const float GameTime = GetWorld()->GetTimeSeconds();
    
    // If its full auto we don't need to worry about buffered shooting ~ if we hold we want to fire - vorixo
    if (!bWantsToFire && ((GameTime >= LastFireTime + WeaponConfig.TimeBetweenShots) || WeaponConfig.FireMode == EWeaponFireMode::FullAuto))
    {
            ....
         }
}
``` In my shootergame extension as you can see I do this aswell
#

ServerStartFire() would call StartFire()

#

so this polling gets done on the server aswell..

#

as the common SG networking architecture

twin juniper
#

yea

#

ive seen that be done though

#

on stuff that doesnt even need it

#

lol

pallid mesa
#

ikr

twin juniper
#

shooter game is weird imo

#

lol

pallid mesa
#

yeah you can check my comment about buffered shooting xD

#

shootergame is just what it says it is

#

a shooter game with multiplayer support

#

the networking architecture isn't bad

#

actually they use networking culling

#

something I've never seen implemented in any Epic Games game

#

but in this template, you can notice it by looking through translucent objects

twin juniper
#

what do u mean?

#

the r.PauseNetworkReplication thing?

pallid mesa
#

they stop the relevancy of the player based on the view frustum of said one

#

check the template, you'll see what I'm talking about

twin juniper
#

yeah

#

thats what i was talking about

#

i tried implementing it

#

but i dont think it is necessary lol

#

100% of the time

#

like i just commented it out in my code lol

pallid mesa
#

well it creates situations that under certain geometry you would be compromising the gameplay

#

because your clients will stop seeing the other players

#

so your level design needs to be done accordingly and so on

twin juniper
#

mhm

#

yea

pallid mesa
#

so just brings more problems than anything

twin juniper
#

thats what had with me

#

lel

pallid mesa
#

but pretty good though

twin juniper
#

also

#

i think all it does

#

is disable the mesh

#

GetMesh()->SetHiddenInGame(bShouldPause);

#

is what it calls i think

#

in their example

pallid mesa
#

I cannot comment on that, didn't check that very closely

twin juniper
#

lol

#

i dont think it does anymore

#

than that

pallid mesa
#

idk, tomorrow I'll check to be sure ๐Ÿ‘

#

but yeah, afaik Epic doesn't use it that much

#

not sure fortnite though but if they use it, it has to be very well done

#

because I never noticed similar issues to the ones I had with SG

twin juniper
#

yea

#

i mean fortnite is their most successful game as of yet isnt it?

#

Am i wrong? lol

pallid mesa
#

yes, well GoW was pretty bumped up back in the days

#

but speaking about recent ones FNT is the top notch

zenith wyvern
#

i want to store character data 'on log out', so im using EndPlay, but by then the pawn is gone and i cant get the transform

pallid mesa
#

anyways o/

zenith wyvern
#

whats the right place to do this?

twin juniper
#

@zenith wyvern do it in unpossess

#

in the Player controller

#

you can override Possess() and UnPossess()

#

and do not call Super::UnPossess()

#

until after

#

u do whaty u need to do

frank tinsel
#

Question: updating location of physics actors already spawned in world. What's the proper way of handling so they update properly for everyone. Right now, my physics actors in properly updated when they spawn in, but if a player bumps them, out of sync

twin juniper
#

dont use physics

#

3rd person ive heard now who has had trouble replicating physics lel

frank tinsel
#

I've seen it done but there was no proper explanation how

glad sedge
#

Accessing the engine directly maybe?

frank tinsel
#

It was through blueprints

winged badger
#

Repliate movement set to true?

twin juniper
#

@twin juniper you mentioned before that a hacker could just override the clientside input cooldown and spam the input command, but how can they do this? Can they reverse engineer the machine code and set the timeout variable to 0 constantly? Also if they can do this, what is stopping them duplicating the same packet that is sent with an RPC and sending 5000 fake RPCs a second?

bitter oriole
#

Nothing is

#

They can do that too

mild hull
#

you can force anti cheat tool and you can ignore IPs before they reach the actual server

bitter oriole
#

What does that even mean ? People can just connect to your game and then start sending fake packets with the game suspended with a debugger

#

The really simple version of things is : nothing that happens on a PC client is safe

#

On a console, some things are safe, some aren't

thin stratus
#

That's why you have the Server far away and double check

#

If the cooldown is really already over on server side

#

CheatEngine allows you to easily search for values in your memory

#

If they search for the cooldown multiple times right after hitting it, they will probably find a location in the memory that shows that often

#

If they change that value then they can easily bypass local limitation

twin juniper
#

@bitter oriole so in that case it isnโ€™t even worth having a replicated variable on the clientside check before allowing an RPC to be sent as they can just send as many as they want anyway?

bitter oriole
#

Yeah, it's useless on the client side

#

Safety checks on the client are generally useless

twin juniper
#

Itโ€™s crazy that even this kind of stuff can be cheated, literally anything on the client is unsafe. If game streaming latencies go down to acceptable values in the future, I wouldnโ€™t be surprised if many competitive games wonโ€™t be allowed on the client machine and instead you rent a streamed instance

bitter oriole
#

Well, PCs allow for entire control of everything

#

That's kind of the selling point

#

Though even consoles can see cheating - mostly by having stuff on the wire between the console and the network

#

And you don't really need streaming, you need more stuff on the server rather than the client. That's how many games have acceptable levels of cheating

twin juniper
#

MP games would be a hell of a lot easier to dev if the client could be trusted

#

Also sucks to see so many players blame cheaters when they die even though it could have been just a good player

#

But yeah you are right that is the reason pcs are so popular

bitter oriole
#

That's why most MP games do server authority + tight verifications + anti-cheat on client + account bans

#

No single effective measure, but a combination

twin juniper
#

Would love to see some examples of verifications like on Server_Validate functions

#

Almost all of the ShooterGame ones are just return true

mild hull
#

they only blame cheaters for everything because than they dont have to live with the fact that they suck :D

bitter oriole
#

Validation logic depends on your game, basically put in assertions that can't possibly be wrong in legitimate cases

#

What's harder is defining what's legitimate

twin juniper
#

Yeah like if you check the frequency of keys being pressed, it could be an aimbot doing 10 things at once or a caffeinated player getting pumped up

#

Hard to tell which

#

False bans would suck

bitter oriole
#

Or it could be lag, and all packets incoming at once

twin juniper
#

Yeah!!

bitter oriole
#

_Validate doesn't ban though, it kicks

#

Banning is up to your licensing, matchmaking system

twin juniper
#

So if it returns false you are kicked to the menu?

#

Will try it out thanks!

bitter oriole
#

Yes

twin juniper
#

For a typical multiplayer shooter game, would you recommend using GameMode/GameState or GameModeBase / GameStateBase? I'd like to use the leaner option but not sure if I'm missing out on essential features (saw posts a while back saying some things weren't working when using GameModeBase)

bitter oriole
#

I use GameModeBase myself, since I don't have any concept of "match" or stuff like that

#

GameMode is probably best for something like a MP shooter

twin juniper
#

Perfect thank you

#

I mean it would be always possible to extend GMbase and copy across any functions, but probably better to just stick with GM because my game is very match based

#

Would you say GameModeBase was more made to reduce the bloat for non multiplayer / unusual multiplayer games and GameMode suits the more typical setup many games use?

bitter oriole
#

Looks like that, yeah

twin juniper
#

how to replicate random integer

#

i know that i have to do that on server and then replicate to clients

#

but how

#

ok nvm

brittle sinew
#

It's best to pass it as a parameter in that situation (if you need it in an event)โ€”you have no guarantee the variable replication will happen before the multicast is called

#

If you don't need it in an event immediately, just replicate it like any other variable.

twin juniper
#

i have a trigger with print string of what room type the room is and it shows on both screens, from both players the same value (the one that server sees)

#

is that good?

brittle sinew
#

Right now it's like that, but there's no guarantee it'll stay like that.

#

Especially over the Internet, you need to make sure your systems are robust enough to handle ping, packet loss, etc.

#

Variable replication isn't instant, and you can't treat it like it is, or things will start to go south.

lilac lotus
#

I'm super rookie when it comes to multiplayer / Replication so I would appreciate if someone could help me out with a problem.
I'm trying to make a C++ OnRep variable functionality.
This is my Header


private:
    UFUNCTION()
    virtual void OnRep_WorldMesh();
    UPROPERTY(ReplicatedUsing = OnRep_WorldMesh)
    class UStaticMesh* WorldMesh;```
And this is my cpp
```void ASubClassWorldPlaced::OnRep_WorldMesh()
{
    StaticMesh->SetStaticMesh(WorldMesh);
}
void ASubClassWorldPlaced::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    // Tell the engine to call OnRep Functions each time a variable changes
    DOREPLIFETIME(ASubClassWorldPlaced, WorldMesh);
}```
Am I doing something wrong? The OnRep_WorldMesh() function never triggers
ripe raptor
#

if I set a variable on both client and server, the client will have its variable until the server one replicates, at which point it will replace it with that one, yes?

brittle sinew
#

Correct

#

@lilac lotus how are you setting the variable?

lilac lotus
#

@brittle sinew Like this // Check if item has a world mesh if (InventoryItem.WorldMesh) { // Set Specified World Mesh WorldMesh = InventoryItem.WorldMesh; } else { WorldMesh = (UStaticMesh*)StaticMesh; // Set to Null Mesh } I have checked and it goes into the correct statement ๐Ÿ˜ช

gleaming bobcat
#

Can I set Owning Client as authority of rotation somehow ? So the server will not override my rotation ?

ripe raptor
#

Thanks @brittle sinew

brittle sinew
#

And what context is this in @lilac lotus? It needs to be at runtime (I don't think things like PostInitProperties or things like that work), and it needs to be on the server

lilac lotus
#

I'm spawning it at runtime with auto PlacedActor = Cast<ASubClassWorldPlaced>(UGameplayStatics::BeginDeferredActorSpawnFromClass(GetOwner(), WorldPlacedReference, RandomizeDropLocation(), ESpawnActorCollisionHandlingMethod::AlwaysSpawn)); , It's for a Drop Item Function. (It has the finishspawningActor as well). It reads everything loud and clear, it just doesn't set the mesh at this moment. I'm making the On_rep function to Server, Reliable, WithValidation atm and hoping that makes it work : )

brittle sinew
#

Making the OnRep function a server RPC...?

#

That doesn't really make sense; OnReps are intended to be called on clients.

lilac lotus
#

Hehe, yeah total Multiplayer scrub. I appreciate you point that out, would have learned through trial and error otherwise

frank tinsel
#

Question again. I'll try to clear it up a bit.
My goal is to have items on the ground be synced in location across server/client. As of right now, when they initially spawn in the world or dynamically spawn from players dropped, everything appears to be nice and synced. However, if they are in any other way interacted with once in the world(i.e player running into them), they can get horribly desynced. I have seen both blueprints and c++ solutions but not real information. Does anyone have an idea of counter advice?

#

or counter advice*

cinder brook
#

@frank tinsel sounds like replication problems.

frank tinsel
#

the players can pick up the items, but the item location is not replicating if the player runs into the item

#

it will move on both sides

#

but it won't be synced

gleaming bobcat
#

Anybody knows where CharacterMovementComponent replicates (correcting) owning client rotation which was set only on Owning Client ?

slim holly
#

๐Ÿค” I don't think it corrects rotation at all

gleaming bobcat
#

Well. If I will remove replication of movement component then the owning client is not overrided at all and it works

#

but once I will use movement replication then it's usually overidded

slim holly
#

I honestly don't really know, I've always used custom actor rotation logic

#

without issues

brittle sinew
#

Look at UCharacterMovementComponent::ServerMove

#

That's just what I saw quickly looking through the source

gleaming bobcat
#

I assume that

#

is CharacterMovementComponent is it ?

slim holly
#

no no, movementcomponent has it's own thing

gleaming bobcat
#

Ah damn

#

and where is sitting ?

slim holly
#

CharacterMovementComponent?

#

it is character class is it?

gleaming bobcat
#

I have character class yes

#

If I will just call on Role==ROLE_AutonomusProxy SetActorRotation it's usually overrided back to server pos

#

server rot

slim holly
#

is it using controller rotation?

#

or orienting to movement

gleaming bobcat
slim holly
#

orient to movement uses velocity as direction, so it might differ from client and server

#

since client gets velocity overrides

gleaming bobcat
#

But I m just standing not walking press a button which set the direction

#

There should be no velocity

#

I mean rotation not direction

slim holly
#

well, I can say there's always velocity for sure, just very tiny bits of it

#

I just don't know what is the sleep value for it

#

I recommend doing custom logic, even if it's a simple one

gleaming bobcat
#

Ok so for the test I will set bOrientRotationToMovement to false just for the test

#

one sec

#

Hmm it's still same

#

Sometimes it works sometimes not

#

So am I right that CharacterMovementComponent overrides it ?

#

@brittle sinew I check it several times I did not find any client side call

gleaming bobcat
#

But this is called on server

brittle sinew
#

No?

gleaming bobcat
#

I mean from Client To Server

brittle sinew
#

Correct.

#

But this part is called on the client

gleaming bobcat
#

But I have opposite problem

#

my Owning client is corrected by server

#

in terms of rotation

#

So basically I need to set new rotation on player side straight. Don't wait for any server delays. But server corrects me mostly before he will get know that this rotation is What I want

#

It;s maybe similar to teleport. You want to teleport player somewhere straight on client side (owner) but server will fix the location straight

#

for your client (cheat protection and so)

#

Then it should be implemented same like DoJump what Epic already made on ACharacter

#

and movementcomponent where you have to use some free slot

#

But In case of rotation I just need to find the place where the character rotation is overwritten by server

#

And I have no success so far

#

and if the place where it's happening is virtual method then I can change the behavior that Owning client is Authority of rotation

#

because nothing in my game could change my character rotation. Just me (the player)

twin juniper
#

In ShooterGame, when a pawn gets killed, he calls a function on the gamemode that does nothing but call functions on the killer and victim player states. I had thought this kind of thing was meant to be done on the GameState rather than the GameMode. Does it not really matter?

#

(or casting directly to the killer playerstate from the pawn that was killed as he has the info from the damage event)

gleaming bobcat
#

Just bear in mind that GameMode lives only on Server side. The GameStat on Server and Clients

twin juniper
#

For sure, it's just that I thought the GM was more of a static class handling the rules and major match events like starting or finishing, and the GameState was responsible for the second to second things like monitoring and setting global score, keeping time, etc

gleaming bobcat
#

Basically the GM is ruler and GS is basically the state of the game

#

But your issue. is it implemented by Epic ? If yes then it's correct :0

twin juniper
#

That's what I thought, but they have timer logic and playerstate score logic being set in the GM

#

I guess it's correct then ๐Ÿ˜„

gleaming bobcat
#

Epic is correct ๐Ÿ˜‰

#

But time is rule

#

score is basically rule as well

#

I mean that reach some score means end of the game

#

sou this should be definitely handled by GM

twin juniper
#

That is true I just always thought the GS tracked that, and only notified the GM when it needed to

gleaming bobcat
#

GameState should be like a bridge for sharing the info

twin juniper
#

It seems it's all done in the GM leaving the GS barely anything to do

gleaming bobcat
#

something like progress of the game

twin juniper
#

Like I had a simple game where the first to 50 kills won, so I had the GS check after each kill if it hit the limit, but only when it did, then I told the GM to do something

#

Gotta just remove the static nature of the GM in my mind now and see it more like the Gamestate

#

But the actual doing force and less the tracking force

#

Also I just noticed that all of the properties in ShooterGame's header file are formatted with UPROPERTY(config)

#

This means the GM doesn't have its own blueprint in editor, and is tweaked via an .ini file

#

Is there any benefit to doing this vs creating a blueprint for the GM?

gleaming bobcat
#

Well. You know you can extend you custom GM by a lot of things which can be then modified in BP by designers

#

this is somthing what you can't do via ini

twin juniper
#

I'm not worried about that as I'll be keeping all logic in the cpp, but I like BP for tweaking defaults

#

As long as there is no overhead for having a BP, I'll go with it

gleaming bobcat
#

You should not folow this patern

twin juniper
#

How come?

gleaming bobcat
#

You can have logic in CPP that's fine. But you should open the variables to be modified outside your CPP via BP settings

#

even for you it's very easy to change somthing without compiling the code

severe widget
#

If you mean config vs BP, that's not really a good question IMO

twin juniper
#

That's why I like BP defaults

#

You can quickly edit

severe widget
#

Also a config file doesn't require a recompile

twin juniper
#

Without closing the editor

severe widget
#

You can even have the config load on command

twin juniper
#

Yeah but you have to reopen the editor every time

severe widget
#

But

#

No

#

But

#

You should do both BP and config IMO

gleaming bobcat
#

thats correct

#

both

twin juniper
#

That makes sense! I'll probably stick to just BP

#

Just because I'll be tweaking the children GM properties in editor until right, but maybe a text version would be nice to have too)

#

As long as there is no extra overhead. ShooterGame just has no BP GM at all, so you can't tweak without changing the .ini

severe widget
#

Yeah so mark it config

gleaming bobcat
#

this is not the best way

severe widget
#

then you can change it later on without having to repackage

gleaming bobcat
#

what about if you want to change the game time

severe widget
#

you don't have to do one or the other @gleaming bobcat

gleaming bobcat
#

or win score cap

twin juniper
#

Oh that is pretty cool (the package thing)

severe widget
#

you can literally have both

twin juniper
#

I can easily change that in BP @gleaming bobcat

#

They are just EditDefaultsOnly properties

#

That's the point of the child BP

severe widget
#

EditWhatever, BlueprintWhatever, Config

#

is valid

gleaming bobcat
#

I agree there is not only one way

severe widget
#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

#

w/e

gleaming bobcat
#

But I will prefer BP way but it's up to you

twin juniper
#

Thanks for clearing it up! Just was wondering why ShooterGame took that approach, and it's probably because Epic were most comfortable changing ini values

#

I do prefer the BP way ๐Ÿ˜„

gleaming bobcat
#

maybe the text file is much more easy to Diff ๐Ÿ˜ƒ form the version system point of view ๐Ÿ˜ƒ

twin juniper
#

Potentially but there aren't really that many defaults, only about 6! It's definitley a good idea to make text versions of BP defaults now that I think of it

#

Considering it's possible for BP children to get reset

gleaming bobcat
#

I think this is completely up to you I don't see atm any adv/disadv over each other

#

But from the consistence point of view imho the BP is the way in my project ๐Ÿ˜ƒ

#

How many ppl are working on your game ? ๐Ÿ˜ƒ

twin juniper
#

Just me ๐Ÿ˜ƒ

gleaming bobcat
#

wow ๐Ÿ˜ƒ

twin juniper
#

So I don't need designers or anyone else to know what is going on

gleaming bobcat
#

๐Ÿ‘๐Ÿฟ

twin juniper
#

Just need easy tweaks

#

And BP is easiest to tweak defaults fast

gleaming bobcat
#

Agree

#

In my project. the core and logic is in cpp and the high level things are made on BP level. Which means designers can change the behavior but not a logic

twin juniper
#

That makes good sense

#

So would they use any nodes at all or just stick with being able to edit defaults?

#

Or do you let them play with cpp logic nodes you have made?

gleaming bobcat
#

You should make High level functions (methods) visible in BP

#

then they can for example create struction of questlines

#

and easily can change which quest is needed before this quest and so on

#

I mean the parameters should be always visible in BP harcoded values are always bad

twin juniper
#

Nice that makes sense

#

And yeah I never use hardcoded values

#

great to be able to change things at a higher level

gleaming bobcat
#

๐Ÿ‘๐Ÿฟ

#

Also UMG is another thing

#

What I understood it;s faster to use BP for handle the clicks

#

rollovers etc

#

faster then have some dynamic_binds

#

in this case you can have logic in CPP but you will just make visible function called "Resume Game"

#

but the clicks itself will be handled in BP

#

something like this

#

All the fucntions are cpp visible in BP

#

So power in UE I see in combination of C++ + BP

twin juniper
#

@gleaming bobcat extremely interesting! I was actually recently wondering about UI as usually the widget is created in the editor first, instead of the usual cpp being exposed to BP after

#

So you donโ€™t actually bind anything here and instead just write the logic in cpp and call the logic you write from BP?

gleaming bobcat
#

exatcly

#

it's also completely transparent to designers (or not programmers in general)

twin juniper
#

Very cool! How exactly do you create the base cpp class for this?

#

Do you create a BP widget that derives from a Cpp class and not the standard widget?

gleaming bobcat
#

UUserWidget is my base class

#

And then you will crate BP based on your own class

#

with all the function visible in BP

twin juniper
#

Perfect that has gotten rid of any doubts I had about cpp / BP widgets thanks so much!

gleaming bobcat
#

np. Just bear in mind : Completely avoid BP implementation is not the ideal even if you are pure programmer which loves C++ (like me)

#

same from the opposite way. Doing everything in BP is horrible

twin juniper
#

I can especially see that with the UMG editor because itโ€™s all completely visual and heavily using the BP interface to position things

#

I mean yeah itโ€™s possible to do the full UI in cpp like ShooterGame but that seems like a massive hassle compared to UmG

#

Gotta play to the strengths of the tools!

gleaming bobcat
#

I was doing that manually in HUD it's jut pointless ๐Ÿ˜ƒ to much work with no sense

#

doing graphics in code I mean it;s pointless

#

i like UMG ๐Ÿ˜ƒ Have a nice day . I m going to bed

twin juniper
#

For sure I agree! Goodnight and thank you again!

livid ruin
#

Hey guys we're having an issue where we want to create a unique name for each player and display it as text over their head. We made our name creation system in a unique playerstate and we were trying to cast to that playerstate then set text as the playernametag variable. But for some reason we cannot cast to the playerstate because we aren't sure what object to use.

vague dust
#

How much RAM would you allocate for a linux dedicated server VM using a sample project?

ripe raptor
#

3

vague dust
#

the frickin binary is like 800MB lol

ripe raptor
#

4

#

(I'm kidding)

vague dust
#

is it bloated because its compiled from Windows for linux? Windows dedicated server is like 300MB

harsh lodge
#

Have anyone come across integer overflow error in html5

frank tinsel
#

Clarification question

#

What kind of replication is best for handling this kind of scenario

#

If a player wants to pick up an item, I mean

#

or Alternate question: why does this break my client players ability to pick up items when Run On Server is selected

vague dust
#

how can i debug network connection issue? 4.18.3 - dedicated server running on linux - client joining from windows - disconnects immediately

[2018.02.20-06.23.45:556][306]LogNet: Login request: /Game/Maps/entryMap userId: Invalid [2018.02.20-06.23.45:589][307]LogNet: Client netspeed is 10000 [2018.02.20-06.23.45:656][309]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp. [2018.02.20-06.23.45:656][309]LogNet: UChannel::CleanUp: ChIndex == 0. Closing connection. [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: <MY IP>:60720, Name: IpConnection_36, Driver: GameNetDriver IpNetDriver_0, IsServer: YES, PC: NULL, Owner: NULL [2018.02.20-06.23.45:656][309]LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: <MY IP>:60720, Name: IpConnection_36, Driver: GameNetDriver I

shadow torrent
#

Hey guys, anyone here had a problem with demorec on 4.18? ๐Ÿค”

winged badger
#

@frank tinsel when you are on server execution, you can get only one game instance - servers, as they are not shared

#

in that blueprint you replicate an event to server, then grab server game instance, and i imagine no matter which player picks up the item the host gets it in the inventory

#

using an inventory component, with variable-based replication would be my approach

#

having just the ServerRPC called to handle the pickup on Server, then replicating variables rather then functions to get the client in sync

zenith yarrow
#

I am using NetMulticast function in gamestate, which executes on the server but not the clients, shouldn't the same code be executed on the clients?

thin stratus
#

@twin juniper You can reference widgets in you cpp class

#

I don't know if someone told you that yet

#

It's pinned to the #umg channel

#

E.g.
UPROPERTY(BlueprintReadWrite, meta=(BindWidget))
UTextBlock* MyTextBlock;

#

If your child widget has a TextBlock with name MyTextBlock, it'll be accessible in cpp

#

In case you want to easily access the designer of your umg widget in cpp

#

@zenith yarrow depends on when you execute it

zenith yarrow
#

@thin stratus I execute the rpc in HandleMatchHasStarted()

thin stratus
#

And that is called when?

#

Cause if that already calls with only the server connected, the clients won't ever get the multicast

zenith yarrow
#

@thin stratus ok tested the RPC in the DefaultTimer() function , which is called every few seconds, and it worked there... I had assumed the HandleMatchHasStarted() was called when everyone was connected to the map... I'll create a custom event that marks the start of a match and fire the RPC then...

Thanks for helping me out.

thin stratus
#

You can hit delayed start in gamemode

#

And override ReadyToStartMatch

twin juniper
#

@thin stratus is this as well as creating the base UUserWidget class in cpp?

thin stratus
#

That is the same

#

In your UUserWidget c++ class, you define what I wrote

#

And in the UMG BP child class, you create a widget with the same type and name in the designer

#

And it will get referenced via the C++ variable

#

So if you have a TextBlock (Title) in your UMG Widget and the C++ parent has the BindWidget variable UTextBlock* Title, you can modify it in c++

#

@twin juniper

twin juniper
#

Got it thank you @thin stratus !

Yesterday someone mentioned that itโ€™s actually faster to use the on clicked / hovered events from BP, so would you recommend just exposing cpp functions to use in BP for those events and do any binding directly in C++ as outlined above?

thin stratus
#

Tbh, you don't have to use c++ at all if you don't need any non-BP stuff

#

It really depends on what you are doing

twin juniper
#

I just mean in terms of speed, someone said itโ€™s actually faster performance wise to use the BP hooks for on pressed / hovered etc

thin stratus
#

There shouldn't be a difference

#

It at all BPs are slowed

#

He probably meant that setting it up i nBP is faster

#

As it's just a button press

#

Compared to defining a function and binding it

twin juniper
#

Ok cool! Thanks! Iโ€™ll probably make all the functions in c++ and then use the BP hooks for clarity as its very visual

#

For most menu stuff performance doesnโ€™t matter anyway because itโ€™s not gameplay

gleaming bobcat
#

Actually not. The Epic said somewhere that is faster or better to handle it via BP

thin stratus
#

In the future, please use #umg though

twin juniper
#

Will do!

thin stratus
#

Workflow wise It's probably nicer via BP

#

I don't see how it should be faster Performance wise though

dense citrus
#

who knows , how to replicate a local savegame to all

#

i save my costumization inside a savegame , one material instance and one skeleton mesh and want that other Players can see my Layout , right now server can see what the players have chosen but the clients can see only own layout applyed on all players

thin stratus
#

Does someone know how to reset the LastSavedActor for Spawnpoints?

pallid mesa
#

Setting it to nullptr would help?

thin stratus
#

Yeah but I doubt that's possible in BPs

pallid mesa
#

Mnh, for spawnpoints I usually override their behav on BP's and do my own, found ir quiet limiting =\

#

Managing those vars myself

thin stratus
#

Most of it works totally well, just for respawning it's annoying

#

Cause I want to spawn them randomly

#

Not to the same spawn point again

#

So I guess I use my own respawn function /shrug

pallid mesa
#

Yeah, it's not that bad! But imho there is lack of variables exposed to BP's to operate better :(

graceful cave
#

im still having the issue where clients get weird replication related bugs if my framerate is too high as the host

#

capping my framerate lower fixes the issue

#

[OnlineSubsystem]
NetServerMaxTickRate=50

#

is in my engine ini but it didnt seem to help

#

there are no RPCs being called on any tick

pallid mesa
#

I believe 30 is the default value ```
[/Script/OnlineSubsystemUtils.IpNetDriver]
NetServerMaxTickRate=30

dense citrus
#

@thin stratus I can send you soon a sceen with random spawn system if you like

thin stratus
#

Na I have that already, don't worry

dense citrus
#

๐Ÿ˜‰ ok

thin stratus
#

Is "ChoosePlayerStart" called before or after SwapPlayerControllers?

#

Cause it's def called before PostLogin

winged badger
#

its called from HandlePlayerStart i believe

#

when the pawns are already possessed

thin stratus
#

Pawns aren't spawned on my end before ready to start is true

#

And that happens post postlogin

#

In PostLogin I assigned a value to the Controller

#

In ChosePlayerStart I use that value

#

And it's not changed

#

So I believe it calls quite early then

#

But doesn'T matter much as I only use that for Editor testing

#

Actual game using seamlesstravel

winged badger
#

if you override ChoosePlayerStart

#

you will break the "PlayFromHere" in editor btw

#

unless you make a separate check and return w/e the Parent function would return if its in PIE

dull tapir
#

So, starting to get the whole multiplayer stuff I think, though I've come across some replication issues. I want to spawn a camera actor for each player that joins and then set the view target of each player to their own spawned camera. I use the Post Login event to spawn the camera on the server and then I set a reference to that camera as a variable in the PlayerController (though I've also tried PlayerState). The variable is set to replicate and so are the actors, however whenever I test this the variable is successfully set on the server, but on the clients it's just "none", so that when I try to set view target it doesn't work as it doesn't have an input. Anyone know why the variable is not replicating to the clients?

winged badger
#

not sure, but alternate approach: on BeginPlay of the PlayerController, if the PC is the LocalController, spawn the camera actor

#

no extra cameras on the server that way

twin juniper
#

Is ULocalPlayer relevant only for splitscreen or is it used in dedicated server settings too?

#

There's some logic in Shotoergame for setting up nicknames, controller IDs and loading persistent user data in a ULocalPlayer class

#

Not sure if that is splitscreen only or not

dull tapir
#

@winged badger Tried running it on begin play, same result. ๐Ÿค”

winged badger
#

replication is not involved the way i described

#

you only spawn a camera actor locally for each player

dull tapir
#

Right, but I thought a server has to spawn actors and clients can't?

winged badger
#

they can, but those actors can't leave their local scope in any way

#

which for a player camera, just might not matter

dull tapir
#

Oh yeah just read up about it again. Hmmm...

#

Well in my case it may not matter, but let's say I wanted a spectator that can see what the player is seeing, in that case I'd need access to the camera on the server side, so it's not ideal even if it would work.

winged badger
#

true, but the approach holding a reference in the PC wouldn't work either there

dull tapir
#

Surely there must be a way to fix this replication? I just don't understand how it can be on the server but not on the clients when it's set to replicate.

#

Yeah maybe, though I originally had the reference variable in a player state

#

just moved it over to PC for testing

#

been going at this for about 5 hours lol

winged badger
#

replicate it with RepNotify

#

print some text in OnRep

#

see if the replication actually happens

dull tapir
#

Apparently so?

chrome bay
#

@twin juniper LocalPlayers are just that, local ๐Ÿ˜ƒ

#

And you do indeed have one for each local player, so in split-screen ,you'd have two.

twin juniper
#

Is it still fine to be used even if there'll never be split screen?

#

Thanks! @chrome bay

magic helm
#

When is there gonna be split screen in the same VR headset?! kappa

twin juniper
#

Just regarding something like this in ShooterGame ``` GEngine->GetAllLocalPlayerControllers(PlayerList);

    for (auto It = PlayerList.CreateIterator(); It; ++It)
    {
        APlayerController* PC = *It;
        if (!PC || !PC->Player || !PC->PlayerInput)
        {
            continue;
        }

        // Update key bindings for the current user only
        UShooterLocalPlayer* LocalPlayer = Cast<UShooterLocalPlayer>(PC->Player);
        if(!LocalPlayer || LocalPlayer->GetPersistentUser() != this)
        {
            continue;
        } ```
#

I'm not sure if this is to set up keybindings for each local user and is unnecessary or if it is for the sole local player playing online and is necessary

chrome bay
#

Yeah you can use them, they always exist for the local player!

#

Not on the server though of course, unless it's a listen server

twin juniper
#

Ok cool thanks!

twin juniper
#

Client doesnt see a newly added component if using Add Static Mesh Component

#

oh now works

hidden thorn
#

is there a way to get the max amount of players a server can have?

#

I used this: SessionSettings->NumPublicConnections

#

But everytime a player joins 1 is deducted from that variable

jolly siren
#

1 shouldn't be decremented from NumPublicConnections. NumOpenPublicConnections keeps track of how many are open.

hidden thorn
#

Yes my bad, I didn't know there were two of them, I was using OpenPublic... I didn't even realize

#

Thank you

jolly siren
#

no problem

hidden thorn
#

when making an array that holds a list of all the players connected is there a reason to use APlayerController rather than A<ProjectName>Character ??

jolly siren
#

Characters normally don't persist death

#

There is already an array of all PlayerStates in the game. Why not use that?

twin juniper
#

In ShooterGame when loading and saving data, it seems to treat the game as though there are multiple local players ``` TArray<APlayerController*> PlayerList;
GEngine->GetAllLocalPlayerControllers(PlayerList);

for (auto It = PlayerList.CreateIterator(); It; ++It) ``` which I believe is to do with the fact that they support splitscreen. If I am certain that I won't have more than one local player per machine (i.e. a typical setup for modern online multiplayer games) do you think I can instead write this as  ``` APlayerController* LocalController;

GEngine->GetFirstLocalPlayerController(); ``` ?

#

And even better if not using GEngine as you seem to have to include the huge Engine.h for that to be recognised...

chrome bay
#

yeah you can safely do that

#

Or get local players from the game instance

twin juniper
#

Oh getting it from the game instance could be way nicer, thank you very much!

hidden thorn
#

@jolly siren Oh I didn't know there was one

twin juniper
#

Just trying to get my head around what kind of local they are referring to here, since this isn't called on the server, would it also possibly be safe to call GetWorld()->GetFirstPlayerController(), or would that still potentially return the first player connected to a sever, and not the local machine player?

jolly siren
#

@hidden thorn yeah GameState->PlayerArray

#

john, yeah they are talking about splitscreen

twin juniper
#

Ok cool thanks, so I can basically replace any for loops and iterators for local players with a single first local player reference!

jolly siren
#

yep

hidden thorn
#

Is there a benefit over using GameState->PlayerArray? I was following a doc by by Cedric_eXi and he uses PostLogin(APlayerController* NewPlayer) and then PlayersConnected.Add(NewPlayer) etc

#

I did similar thing but in my case PlayersConnected is in GameState rather than GameMode

thin stratus
#

PlayerArray is of PlayerState

#

@hidden thorn

#

PostLogin is a default event by gamemode that calls when a player is fully accepted

#

It gives you a ref to its playercontroller

#

That's different to the PlayerArray that gets filled with PlayerState references

#

And the one in GameMode is server only

#

While PlayerArray is somewhat replicated

#

Well at least gets filled on each client

hidden thorn
#

Is there a reason to have a server only player list??

#

And yeah I get the difference between PostLogin and PlayerArray

thin stratus
#

Well there is no reason to have that list on clients

#

The playercontrollers in there are only replicated for local clients

#

A client doesn't have a ref to other playercontrollers

lilac lotus
#

Is there a special way of handling OnRep in C++ if the variable is of type USkeletalMesh ? Feels like I've looked everywhere I can for the answer.
The event that changes the variable fires & the setup looks good but no changes visually.. ๐Ÿ˜ช

brittle sinew
#

You're wanting the OnRep event to fire on the client, correct?

#

I believe BP and C++ have a discrepancy when it comes to OnRepsโ€”IIRC, in BP OnReps are automatically executed on the server, while in C++ they're not

lilac lotus
#

Yeah I read that, not sure it fires on either server or client though

#

I'm currently checking references & pointers even though I don't see that being the problem

limber venture
#

hey guys, i am trying to connect to my dedicated server and my client disconnects immediately. This seems to be the error

[2018.02.20-22.37.38:683][138]LogNet: Warning: Travel Failure: [PackageMissing]: [2018.02.20-22.37.38:683][138]LogNet: TravelFailure: PackageMissing, Reason for Failure: ''

#

prob should have pastebin that, sry

#

that is client

hidden thorn
#

if I have the players list as APlayerController is there a way to get the A<Project>Character so I can access variables from that file?

brittle sinew
#

Yes, that's the function of casting.

#

You can't cast a whole array at once, however; you need to cast each element individually, either when you use it or sometime before that.

hidden thorn
#

I know that what I am asking is how would I go about getting the Character since the list stores the Controller and they are 2 different objects.

brittle sinew
#

AController::GetPawn()

#

Sorry, I had originally glanced over it and thought you were simply trying to cast the controller to your custom type.

limber venture
#

can you set higher verbosity of logging for the packaged builds?

limber venture
#

apparently you can in the defaultengine.ini config

[Core.Log] LogNet=verbose LogOnline=verbose

and then repackage your project

#

hopefully will find out what this bullshit fucking error means LogNet: TravelFailure: PackageMissing, Reason for Failure: ''

#

Reason For Failure: '' thats some windows shit right there

#

Windows is more like Unknown Error: 'Error Unknown'

hidden thorn
#

@brittle sinew Thank You

ripe raptor
#

It seems that Steam marks sessions as InProgress straight away when you create the session?

#

Nevermind, my bad

analog hatch
#

Hi everyone.

We are having problems replicating AimOffsets. It works on the Server (you can even see the aimoffset of the clients into the server) but the clients can't see any AimOffsets that are not their own's. Anyone had a simmilar experience? Or know how to fix it?

Thanks awesome people.

ripe raptor
#

Do Steam presence sessions actually have to be in progress for them to advertise?

#

I am getting 0 search results even though there is one presence session that's in the "Pending" state

#

Actually, I can see the session only if "bAllowJoinInProgress" is true, even though the session is Pending, not InProgress

cyan bane
#

Every so often when i update a replicated variable on my server, my client receives it twice. I am using ForceNetUpdate() directly after I update the variable. Is that normal?

sly basin
#

@analog hatch I had a similar problem a while back. I ended up setting the variables that control the offsets locally and then setting them again in a loop that repeated 30 times a second as replicated, skip owner and it cleared it up. I'm no expert, not sure if that's a good way to do it but maybe this gets you looking in the right place.

hidden thorn
#

Out of nowhere I can't find servers anymore.
I am not sure why this is happening, is there anything I should be looking out for?
The way I tested is I right click the project Launch Game and start 2 instances.
https://i.imgur.com/rrjh8p9.png

gaunt kestrel
#

In Multiplayer I want fairly large map sizes, if I use level streaming in multiplayer and only load the tile any players are on, and the nearest tiles to them, would that but a good solution?

The only thing I could think of is it might be hard on the network streaming in and out levels a lot

thin stratus
#

You can load levels on clients when enabling Client-Streaming

#

And then let clients load the surrounding tiles

#

Depends on the view distance I guess

#

And how big a tile is

gaunt kestrel
#

I think there its about 2ish km?

Client-Streaming? Loading them only on client side?

thin stratus
#

Yeah by default, it's Server-Streaming

#

So Server loads one and everyone loads it

#

Client would allow you to only load an specific client + server

gaunt kestrel
#

Oh okay, so Client 1 enters that zone and loads it, the server loads it, but client 2 on the other side of the map doesnt load it

thin stratus
#

Yeah

next falcon
#

can i set a widget in the world only see for one guy who is standing right next to it ?

hidden thorn
#

Well you can check the distance between you and the widget and depending on that show it or hide it.

#

Or you can spawn the widget locally

next falcon
#

jeah but if i stand next to it and set visibility everybody will see it too

hidden thorn
#

Is the widget set to replicate? also are you telling the server to set it to visible?

next falcon
#

the widget is not replicated and its owning client

#

and triggerd by collision overlap

hidden thorn
#

So any client that overlaps it makes the widget visible?

next falcon
#

jeah

#

visible to all players even the guys who are not near

hidden thorn
#

When you overlap do you tell the server to make the widget visible?

#

Cause if not I don't see why it would be visible to everyone if the client makes it visible locally

next falcon
#

i think the overlap is a multicast...

thin stratus
#

In the Widget Actor

#

Get the Overlapping Actor

#

Check if it's locally controlled

#

Or, if you only have Clients (no listen Server)

#

Just so "SwitchHasAuthority"

#

And on Remote exec

#

Get the Owner of the overlapping actor

#

That should be the PlayerController, if the overlapping actor is the Character

#

Check if that is valid

#

If yes, you have the local client

next falcon
#

nice thanks

hidden thorn
#

@thin stratus have you got any ideas why I have that issues (a few posts above)

#

I've been looking around for an hour or so but can't seem to get why that is happening

thin stratus
#

Is that Subsystem NULL?

hidden thorn
#

This

#
// Get OnlineSubsystem we want to work with
    IOnlineSubsystem* const OnlineSub = IOnlineSubsystem::Get();
#

If yes, well it does pass the if statement.

#

And it worked last night and nothing has been changed since then

thin stratus
#

No I mean

#

What Subsystem are you using

hidden thorn
#

I am not familiar with what Subsystem means in this context

#

Not sure if it helps or not but I followed your "How_To_Use_Sessions_In_C++" wiki

#

Looking online I think I am using the UEs SubSytem which is set to null in DefaultEngine.ini

jolly siren
twin juniper
#

anyone mind looking at my network profile

#

and telling me what i should be looking at

#

to optimize for performance

#

not sure what to look at D:

candid fox
#

Hello, anyone knows how to restart level using Steam hosted sessions without kicking players?

jolly siren
#

@twin juniper What is ClientUpdateAllSlots?

#

@candid fox dedicated or listen server?

#

You can use RestartGame or do a ServerTravel to the same map

twin juniper
#

@jolly siren literally just updates the inventory slots

#

passing an array of structs from the server to the client

#

to update the icons

#

and such

#

sometimes... it doesnt always get updated correctly

#

so i call that whenever u open the inventory

jolly siren
#

Where are the icons stored? Why would you need to pass them over the network?

twin juniper
#

sec

#

Actually, my mistake

#

it sends the "Inventory" which is an array of S_Item structs

#

with 4 things:
item id, item count, item index, and the inventory component

#

@jolly siren However, we use the item ID to lookup the stuff for the "item slot/icon"

#

and it looks it up from a DataTable

jolly siren
#

Yeah passing ID and locally looking it up is the correct way to go. The avg size of that rpc seems quite large tho

twin juniper
#

It loops through all the inventory structs

#

and passes it to "Update Inventory Slot"

#

which just sets the widget stuff lol

#

@jolly siren if u dont mind, how were u looking at that though

#

i thought these two parts were the problem

jolly siren
#

just looking at the all rpcs tab

#

but yeah you have a couple spikes in there

twin juniper
#

any clue what that is caused by

#

O_o

#

Or how I could find out?

#

because at that spike, there is literally NO RPCs being called

#

however, there is a large number of rerplicated actors...

#

so im not sure haha

hidden thorn
#

@jolly siren About the Online Subsystem I looked through that and mine is set to NULL -> DefaultPlatformService = NULL

thin stratus
#

@hidden thorn Well subsystem null is fine

#

That shouldn't cause any errors

hidden thorn
#

Ahh, could the firewall block anything?

twin juniper
#

The NullSubsystem is literally just there

#

to give u basics lol

#

its actually really nice

hidden thorn
#

Or have you had this before and I should maybe look out for something blocking it such as anti-virus or idk

candid fox
#

@jolly siren Thanks for tip. When i do ServerTravel Players stay connected but game state will be None. How do i start new match from there? Tried Start Play.

#

Also Listen.

vital steeple
#

if i get playerstate owner, it should return the controller right?

#

yes, it does, just tested ๐Ÿ˜ƒ

thin stratus
#

@vital steeple Yes, but only on Server and LocalClient

#

(Can't say that often enough :D)

#

@Ardivaba#1465 That shouldn't happen. If your GameState is NONE, then you have some other issues :/
When are you trying to access it?

#

@hazy sableowman#9463 SubsystemNULL is basically LAN Sessions and IP Connection.

#

Even the LAN Sessions are IP Connections as searching for matches is a simply broadcast through your LAN

#

So technically, if you local PC doesn't block any internal IPs, it should find the sessions

hidden thorn
#

That must be the issue because I went to uni and tested the exact same project and it works.

jolly siren
#

Does anyone know if it is safe to update session settings such as gamemode, map, etc. after players are connected? At the end of the match players vote on the next map/gamemode and I would like to update the session settings so new joiners can see what map/gamemode it is actually on.

hidden thorn
#

How could I check if my local ip is being blocked

#

But I dont have "VirtualBox NetWork Adapter" installed or listed anywhere

jolly siren
#

that would only be listed if you are using a vm with virtualbox

hidden thorn
#

Anything else that could be blocking my local ip?

#

I turned off my antivirus, firewall and nothing

twin juniper
#

how to replicate add static mesh component?

vital steeple
#

@thin stratus sweet! im running it from server anyway (a spawn queue that cycles through an array of playerstates, gets controllers, and spawns a character for that controller to possess)

#

works great ๐Ÿ˜ƒ

winged badger
#

@twin juniper you add the component normally, then you do SetReplicates to true (bReplicates = true from c++) for that component

twin juniper
#

But if I don't want it at start?

winged badger
#

that is fine

twin juniper
#

Because there's a bunch of same blueprint actors

winged badger
#

works either way

twin juniper
#

Ok

#

But if I need to change the mesh?

winged badger
#

StaticMesh pointer is replicated, so you should just need to set a new one

twin juniper
#

Is there anyway to optimize replication of large numbers of actors

#

Like, I have about 30+ NPC actors, and even though I've done what I think is more than enough to optimize, it still lags my server.

#

It literally enables and disables all tick, set rreplication on and off, enables/disables all collision, all ticks on components, as well as registes/unregisters navigation invokers on ALL npc's

#

yet the optimization is still not enough

#

am i missing something else?

#

_<

manic pine
#

brain is turned off too?

twin juniper
#

It literally disables tick on all components

#

from what i can tell

#

I'll DM you a snippet

#

of the code i made

manic pine
#

what about the bot controllers?

twin juniper
#

So I call SetHibernate(true) when we our collider enters the area, and call SetHibernate(false) when we exit..etc

manic pine
#

the other way around i hope

twin juniper
#

yeah

#

xD

manic pine
#

right, but the performance problem is constant? not just when enter/leaving the area?

#

is the performance worse when youre in the area?

twin juniper
#

yeah

#

well

#

if no player is in the area

#

it just despawns the npc's

#

and performance improves lol

winged badger
#

you sure its the network and not AI controller with PTSD?

manic pine
#

hibernate seems to destroy the ai controllers

#

in fact, it doesnt even recreate ai controllers when turning off hibernation

winged badger
#

if its the network, and i don't think 30 actors can overload it, even with under 1Mbps connection

#

state based replication is usually the cheapest

#

replicating a single enum (1 byte) that holds the current state with RepNotify, then doing what you need on clients with OnRep functions

manic pine
#

im a bit confused too, what exactly is the hibernation function for if you just destroy the actors when leaving the area?

#

is it just a test to see if turning hibernation on while player is there improves performance?

#

anyone have any experience with lag compensated projectiles(not hitscan)? bigger ones, e.g. rockets rather than bullets
i want the shooter to actually hit what/where he's aiming at, so i figure fake projectile on shooter, then server does a movecomp.tick of shooterping/2 to sync up to shooter's fake projectile
however, i also want other people able to both shoot down(with hitscan) and dodge those projectiles, so when non-shooters receive the projectile they should tick another nonshooterping/2 for their replicated version, so they can see the actual server version...
but, the dodging of or shooting at those projectiles is gonna take another nonshooterping/2 to actually reach the server, which means they'd need to do yet another tick so their view of the projectile is actually ahead of the server, so in total it adds up to shooterping/2 + nonshooterping ms worth of prediction, which at 100 ping for both clients totals at 150ms... a projectile velocity of 3,000 means the spawn location as seen by the nonshooter would be offset by 3000*0.15= 4.5meters, which would have a nasty gameplay impact up close

twin juniper
#

@manic pine thats commented out

#

the destruction i mean

#

@manic pine you destroy the actors when youn leave the "biome"

#

not when u leave the NPC location

manic pine
#

ah right, so hibernate when in biome but not immediate area of npcs

twin juniper
#

yeah

#

so if u leave biome, ALL npcs in that biome despawn lel

#

but it keeps a "FVector" of the location

#

so if a player comes within1 5000 sq units of the locationo

#

it spawns a random npc

#

@manic pine

manic pine
#

right, have you confirmed that your hibernation function actually runs? if its really setting updatefrequency to 0.01(once every 100 seconds), then replication shouldnt be causing an issue

#

also make sure its not running continuously ^___^

twin juniper
#

@manic pine it is being called

#
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 0
HibernationModeChanged: 1
HibernationModeChanged: 1
HibernationModeChanged: 1
HibernationModeChanged: 1```
#

0 = no hibernation, 1 = hibernation

#

and its changing when i enter/leave

manic pine
#

ah okay, well thats good.. but then whats causing the performance problems

#

whats the profiler saying?

#

if the profiler doesnt give you anything useful, might be worth it to put some prints inside tick/tickcomponent functions just to see if anything's running, since something obviously is

hidden thorn
#

Any reason why I am getting this error?
This works fine on the server but when a new player joins this is what happens.

Access violation - code c0000005 (first/second chance not available)

Urpgprojectgamestate.cpp:39]
//Line 39
if(Cast<ARPGProjectCharacter>(connectedPlayers[i]->GetPawn()->) != nullptr)
#

In GameMode I have this

#
void ARPGProjectGameMode::PostLogin(APlayerController* NewPlayer)
{
    Super::PostLogin(NewPlayer);

    ARPGProjectGameState* GameState = GetWorld()->GetGameState<ARPGProjectGameState>();

    if (GameState != nullptr)
        GameState->AddConnectedPlayer(NewPlayer);
}
brittle sinew
#

Looks like you have an errant arrow operator on the end, I'll just assume that's a copy mistake ;)

hidden thorn
#

Yes that is

brittle sinew
#

That said, you should check if the array element is valid before trying to call a function on it

#

You're looking at a classic nullptr access violation there

manic pine
#

connectedplayers could be null yeah

#

eh sorry

#

0 elements

hidden thorn
#

But technically what you see there should work

manic pine
#

or it could be a null member

hidden thorn
#

also the array is not empty as I have the i displayed at the beginning and it returns 0 and 1

manic pine
#

could be null pointers inside the array

hidden thorn
#

I will look into it now

manic pine
#

connectedPlayers[i] dereferences the array, the next -> dereferences the array element

#

first will fail if index is out of bounds, second will fail if null(or invalid) pointer

#

@twin juniper any luck?

hidden thorn
#

Ok so what I am getting is this

#
for (int i = 0; i < connectedPlayers.Num(); i++)
{
    if(connectedPlayers[i] != nullptr)
            GEngine->AddOnScreenDebugMessage(i, 0.01f, FColor::Green, FString::FromInt(i) + " - " + connectedPlayers[i]->GetName());
        
}
#

Top Left - Server other two clients. So the controller on the previous clients/server becomes null but it does recognize that there are more players

twin juniper
#

@manic pine no lel

#

the -messaging parameter on my server

#

isnt working

#

so i cant run profiler on server anymore

manic pine
#

ouch, well you could still try printing in the ticks to confirm that nothing's actually running

#

@hidden thorn are you trying to access other player's playercontrollers from a client?

hidden thorn
#

Yea

manic pine
#

ah

#

yeah, thats not legal

hidden thorn
#

I assume if they are in a list it would be a problem as they can't edit but read them

manic pine
#

playercontrollers replicate only to the player who owns it

#

other players playercontrollers dont spawn on a client at all, they dont exist period

hidden thorn
#

ahh

manic pine
#

youre looking for other players' representation on your client

#

thats usually done with the APlayerState class(and sublcasses)

#

listenserver and dedicated server has access to all playercontrollers, clients have access only to their own(as well as any split-screen controllers), but everyone has access to all the playerstates

hidden thorn
#

can you get the player state from the controller?

#

I am just trying to wrap my head around it

manic pine
#

yes, the PlayerController is actually what creates the PlayerState

#

it does so on the server, then the playerstate is replicated to everyone

#

you can also find the playerstates in AGameState

#

which is another object all players have access to

hidden thorn
#

What sort of info you would store in the PlayerState?

manic pine
#

anything that other players might need to know about that player that's not stored on his actual character/pawn

#

by default, you can find e.g. the player's name and score there

hidden thorn
#

So like on the actual character you would store health, armor, kills, deaths, team etc. and on the state name, id, etc

manic pine
#

health and armor sure, but what happens to kills/deaths(and team?) when character dies?

#

they're gone

#

much more fitting they stay on the playerstate, assuming you dont want to reset them on death

hidden thorn
#

when the character dies do you have to reset them or do variables reset by themselves ? or is that more like a logical thing to do on the character

manic pine
#

well, UE doesnt really have a concept of 'death' per se

#

there's Destroy, which removes the actor from the game entirely

twin juniper
#

if u spawn a replicated actor in a multicast function

#

we will get multiples right?

#

lel

manic pine
#

multicast, when used on a server, is called by the server itself as well as on all the clients that have a replciated version of the object the multicast is called on

twin juniper
#

but

#

that would mean

#

u would get 1, replicated to the clients, and then another on the client

#

so two on the client

#

1 on the server

manic pine
#

right

twin juniper
#

heh

manic pine
#

and only 1 of the two spawned on the client would have a net connection and thus be replicated

#

other would be dummy actor that the client has Authority over

twin juniper
#

mhm

twin juniper
#

lel

#

my npcs are setup to "run away" when a player gets them below a certain hp

#

but instead, if no player is lofgged in

#

it cant complete the eqs query

manic pine
#

oh my... and 28ms for that?

#

insanity

#

how big is the grid

twin juniper
#

@manic pine actually the grid isnt the long part

#

if un look

#

its the "Trace"

#

thats taking 5.71 ms

#

the grid itself is the first one,

#

its also taking a bit though

#

2.27 ms

manic pine
#

hmm, are you sure that entire environment query thing is meant for huge open worlds like yours?

#

i think its for tiny indoors areas

twin juniper
#

i mean

#

how else would u make something

#

run away lel

manic pine
#

pick a random direction

#

^_______^

#

away from the scary thing, obviously

analog hatch
#

@sly basin Hey thanks we'll have a look at your method. cheers!

winged badger
#

you could make them run away only if the player is close enough for it to matter @twin juniper

#

that would solve the no player around issue as well, they could just wait then

#

checking VectorLengthSquared is relatively cheap, much cheaper then traces

twin juniper
#

@winged badger yeah

agile crane
#

Hey, I have one question that I really need help with Unreal engine 4.
I want to make a deathmatch (not team deathmatch) where everyone kill each other, and they all use the same character, I tried doing that but everytime I shoot or someone shoot we damage ourself, like the bullet is colliding our own character, and is there a way to do that it can collide only on other person than ourself? So like we could kill each other.

Please thanks.

worn nymph
#

you need to set the damage instigator at time off firing and also if you are using traces add the controller to a list of ignored objects array

agile crane
#

I don't really get it, all I'm doing is cast to my own character and do health damage inside my bullet, but when I shoot I get damaged myself

winged badger
#

inflicting damage logic does not belong inside a bullet

agile crane
#

Also line trace doesn't work for me, when I do a line trace and try to add damage to enemy or AI's it doesn't work.

#

Anyone know why?

#

Oh wait, I think I find a way to do it, thanks for the help ๐Ÿ˜„

twin juniper
#

Hi. Can anybody help me? I'm trying to make a main menu with chat and friends list in a multiplayer game (session based), but I'm not sure about what I should use. I think I have to make a new network layer, but I don't know if I should use TCP/IP or if there is a better way to do a bidirectional connection in real time (without TCP sockets). It's there a better way to do it without TCP sockets? (Sorry for the bad english)

hidden thorn
#

I have a variable like health that is replicated over the network and it works sort of. The server is not getting the clients health updated but the client can see the servers value being update. While the clients health is not updated between each other.

#

Do I need to add that in a function with UFUNCTION(Server, Reliable) or a NetMultiCast?

gleaming bobcat
#

Server is Updating Clients not in opposite way

#

Health is something what should be replicated without messages

hidden thorn
#

I know but this is just for testing

gleaming bobcat
#

Its up you you how you want to replicate

#

to all clients

#

but you can be also more specific

#

when you will use DOREPLIFETIME_CONDITION

hidden thorn
#

Is this the right way of calling it?

#
UPROPERTY(Replicated)
float Health;

//.h
UFUNCTION(Server, Reliable, WithValidation)
void UpdateHealth();
void UpdateHealth_Implementation();
bool UpdateHealth_Validate();

//.cpp
void ARPGProjectCharacter::UpdateHealth_Implementation()
{
    Health += 0.01f;
}

bool ARPGProjectCharacter::UpdateHealth_Validate()
{
    return true;
}
#

I just tested it and I am getting the right values displayed for each player

gleaming bobcat
#

Looks correct!

hidden thorn
#

So when would you use NetMultiCast what sort of sittuation?

gleaming bobcat
#

Multicas should be called from server

#

basically something like Client ---> Hey I m doing something ---> Server will do it and ----> tell other clients about what are you doing

manic pine
#

multicast is nice for e.g. telling all clients to play a particular visual effect

#

or maybe turning the visibility of an object on/off

#

the multicast effect can usually be simulated with a replicated property with repnotify too, though without arguments obviously

gleaming bobcat
#

Basically you need distinguish between what you want to replicate really often via replicated value or one shot messages like Multicasts

manic pine
#

careful with unreliable multicasts though, unlike reliable ones they can end up waiting a long time before being sent

gleaming bobcat
#

I am not sure how it works with unreliable in UE but low priority things like VFX should not be never reliable

manic pine
#

unreliable for everything else is sent instantly

#

its just unreliable multicast that's slow

#

its a design decision, though i cant remember the exact reason

gleaming bobcat
#

that's fine. It's not important how fast the other player will see my PFX

manic pine
#

i believe it waits until the next netupdate

gleaming bobcat
#

if there is tons of PFX overlapping each other

manic pine
#

yeah, but depending on how youre using it, you could end up with surprising results... e.g. an explosion effect following 1 second after it should

gleaming bobcat
#

so unreliable means it will be delivered but it has low priority ? or it's a chance that it will be not deliverd ?

manic pine
#

unreliable in and of itself just means it wont resend it, ever

#

reliable will wait for response from client that it received it

#

otherwise resend after x amount of time

gleaming bobcat
#

Well it's easy to set all to reliable but it's definitelly not good idea

manic pine
#

the fact that unreliable multicast is slow is because they intentionally put it in queue until next netupdate, which is potentially minnetupdaterate

gleaming bobcat
#

So It should be based on your priorities

manic pine
#

yah definitely

gleaming bobcat
#

For example if I put new gun to my hand

#

it's definitelly low priority

manic pine
#

yeah, though it would arguably need to be reliable

#

then again, you'd do that with replicated var anyway, whcih is always reliable

gleaming bobcat
#

but what I have in my hands don't need to be replicated all the time

manic pine
#

its not, server only reps vars when they change on server

gleaming bobcat
#

it's something not much changed frequently

#

ah I see really ?

#

he is replicating only changes ?

manic pine
#

hmmmmm

#

actually dont quote me on that, ive never actually tested it

#

i kinda assumed

#

there are several systems in the works though, like dynamic net frequency

gleaming bobcat
#

If it's replication only changes that's is fucking poverfull

#

But still I don't think so :0

manic pine
#

yeah, i kinda assume the engine makes a VarOldValue, then on netupdate it checks if Var != VarOldValue, replicate

gleaming bobcat
#

Do you have any experience with root motion via network ?

#

There is some support for that in CharacterComponent does it works nicely ?

#

I mean CharacterMovementComponent

manic pine
#

never tested it to be honest, but its all over the place, including servermove/replicatemovetoserver

#

so i'd assume it works given how much work is put into it

#

its even in clientsmoothing

gleaming bobcat
#

well root motion looks always better then not root motion

#

the question is how it's replicated according to this

#

It's very sad

#

On client side it looks horrible

#

I mean on other client sides. I think the main problem is that there can't be any movement prediction

manic pine
#

hmm so it interpolates between t and t-1, instead of extrapolating from t to t+1 as usual

gleaming bobcat
#

I will test it tomorrow but there are some animation which does not have linear movement speed

#

and in this case it's not easy to use non root animations

manic pine
#

i guess it could work fine for a lot of games

#

though not fast paced shooters

gleaming bobcat
#

you know something like asia style animation you will jump then the movement is slowed down in the air and then you will land very fast and then the movement is almost stoped before the hit and then it's very fast again etc

manic pine
#

ah yeah

gleaming bobcat
#

and in this case doing some manual movement to match the animation it's quiet shitty :0

manic pine
#

must be hard working it into the gameplay either way no?

gleaming bobcat
#

๐Ÿ˜ƒ

manic pine
#

its a very cool effect though