#multiplayer

1 messages ยท Page 2 of 1

quiet rapids
#

Don't use this approach. Use OnReps and check the doc first

#

Check this not the previous one

shrewd dawn
#

oh so I should set it replicated on server then multicast collisions?

shrewd dawn
#

first before I try learning the other one

fathom aspen
#

To get something working the incorrect way is a bad habit

dark edge
#

If it's a state, use repnotify. This sure sounds like state to me.

#

You would repnotify MyStaticMesh. You would multicast PlayExplosionFX

fathom aspen
#

Yes you should be able to. Travel with ?listen

#

If an OSS is implemented, such as Steam then yes

#

If not, then no. It's done by IP addresses which is bad, but good enough for fast testing

#

Yes. That's why you got IsNetRelevantFor. Override it and use that state in there

summer hemlock
fervent gorge
#

and as i can suggest, the one who gives netID - online subsystem?

fathom aspen
#

If multiple players are playing with the same remote IP address, the wrong player could take over another disconnected player on their network which is not the correct way to handle disconnects

#

But I don't see a shipping game without an OSS

fervent gorge
#

is it safer to use playerState's name?

fathom aspen
#

It's safer but still a bad habit. The only unique identifier you should be using is the NetId

#

Look at AGameMode::AddInactivePlayer for reference

#

You should be overriding that if you want a different behavior

fervent gorge
#

okay, thank you

kindred widget
#

NetID are safe because the OSS has access to identifiers that are truly unique for specific accounts. For example. NetID for a Steam user is their Steam ID number.

fervent gorge
#

๐Ÿค”

#

so working with steam - netID is not depend on IP

kindred widget
#

Not sure what Null uses. I don't know what Epic's are, but I know Steam's are your Steam account ID number. Epic likely has a similar number per account, just less visible.

fervent gorge
#

got it, thanks

clear island
#

can someone clarify something for me about multicast RPCs

#

I assumed when you call a multicast rpc, the code inside that RPC function is executed on the server aswell as all client machines

#

but the behavior I'm getting, is that the code is only being called on the server

#

it executes for all clients on the server, but not on the actual client machine

kindred widget
# clear island can someone clarify something for me about multicast RPCs

A Multicast should only ever be ran on a server version of a replicated object. And then yes it should run on every machine that object is replicated to. If you run it on the server on a non replicated object, it will only run on server. Likewise if you run it on client on either a replicated or non replicated object, it will only run on that client.

clear island
#

I was sending a multicast RPC on BeginPlay of a replicated actor

#

but none of the clients were getting it

#

I guess RPC's on BeginPlay event are a bad idea

#

probably too soon

kindred widget
#

Your RPC likely reached client before the server had a chance to replicate the object to client.

clear island
#

makes sense

#

when is the best time to send an rpc to the clients?

#

I mean I can add a timer to delay it

#

but

#

seems dirty

#

I want to send it as soon as clients are "ready" to receive it

kindred widget
#

There likely is no surefire way. If you need a sure RPC, multicast probably isn't what you're looking for. What is your usecase for it?

clear island
#

my usecase is as follows:

  • player joins server and sends his nickame (sent as an option ?NickName=etc...)
  • server receives the nickname in GameMode::PosLogin and stores it in the PlayerController
  • then the character of the player is spawned on the server during beginPlay, I was sending a multicast rpc to all players letting them know the nickname of the player that just joined
kindred widget
#

Not really. The issue is design theory. Mutlicasts are usually for one time things that server needs to dictate that aren't stateful. For the same thing that is stateful you use a replicated property. The reason for this is because you cannot promise timing to clients. One client can get the RPC up to 250ms after another client. One client might connect after the RPC, and never get it and be missing the required state.

#

I honestly don't have a lot of usecases for good multicast use. Simplified chats maybe, where you don't have to care if new joiners see the old chat.

clear island
#

I was using the beginPlay event on the server to check when new players join, but thats just too soon I guess

kindred widget
#

If you want a one time initialization of something, you can make client tell server that it's ready, and pingpong Server/Client RPCs reliably back and forth to init something. But generally speaking replication is usually the best case in a ton of scenarios.

clear island
#

I tried doing that at first but ran into other issues

#

because I was calling an RPC from a simulated proxy which unreal does not allow

kindred widget
#

For your use. That generally sounds like a single Server RPC to send the nickname. PlayerState can store the name and broadcast it both on Beginplay or OnRep of the property. Just check if it's a valid non empty name before broadcast. That'll cover pretty much all cases.

clear island
#

well the thing is, I'm not sending the nickname of the player that just joined to himself, infact, I need to send it to everyone but himself, so other players will see his name

kindred widget
#

Well, no, that would break.

clear island
#

thats why I thought about a multicast; new player joins, send his nickname to all other players

kindred widget
#

New players would see every join immediately with that. I guess you could Client RPC loop to all controllers except the one the name is for.

clear island
#

yea I want players to see when a new player joins

kindred widget
#

Would likely break for new game, but any player who joins after 2+ seconds would be seen by everyone already connected.

clear island
#

how can I do that? using c++

kindred widget
#

From GameMode?

#

Also ue4/ue5?

clear island
#

ah you mean, on the GameMode::PostLogin, store the Playercontroller on a list/map of a sort?

#

UE5

#

ah wait now that I think about it GetAllActorsOfClass function might work I guess ๐Ÿค”

kindred widget
#

Nah. Sec

clear island
#

for now delaying this multicast with a timer fixes my issue but I'm trying look for a cleaner solution, would be nice if unreal had some sort of event that could tell me when a client is "ready" (has been replicated) so I dont send RPCs too soon

kindred widget
#
for (APlayerState* PlayerState : GameState.Get()->PlayerArray)
{
    APlayerController* LoopController = PlayerState ? Cast<APlayerController>(PlayerState->GetOwner()) : nullptr;
    if (IsValid(LoopController))
    {
        LoopController->MyClientRPC();
    }
}
#

Replace APlayerController classes with your controller type that has the RPC.

#

And you can add a != check for the one you don't want to RPC

clear island
#

ahh I see GameState holds a player array

kindred widget
#

You can always access every player's Pawn, Controller or PlayerState through that. PlayerState's Owner is the associated controller, and Playerstate has a PawnPrivate property to their connected pawn.

clear island
#

I haven't gotten that far yet as to create my own GameState class, still in the early stages, but will get to it soon

kindred widget
#

You don't need to. It's default framework.

#

Just need the controller with the RPC, everything else is already in place.

clear island
#

yea I know theres a default instance of it but I will need to create one eventually too since I need to store some stuff specific to my game's state, but good to know that regardless

clear island
kindred widget
#

That I'm not sure on. I've never had a case where I had to care about that. ๐Ÿ˜„

clear island
#

I see, I'm gonna give it a try and see whats called first, this or beginPlay thanks for the help anyway ๐Ÿ‘

fathom aspen
#

If that was your question

fathom aspen
#

That's not a meaningful statement

#

Actor has been replicated to client

#

That's the one

#

BeginPlay SwitchHasAuthority Remote Pin

clear island
clear island
fathom aspen
#

Yeah pretty much BeginPlay but using that authority macro with the remote pin

clear island
#

hmm but that still will get called during beginPlay, no?

fathom aspen
#

If you have a reference to that spawned actor where it's replicated then you can have it as an OnRep

fathom aspen
clear island
#

yea I know but only the server knows the player's nicknames

#

so the server needs to send it to players

fathom aspen
#

It doesn't get called on client without it being replicated

clear island
#

yea I know but its replicated

#

and it still doesnt get called on clients

fathom aspen
clear island
#

unless I delay it with a timer instead of doing it immediately on BeginPlay

fathom aspen
#

And would be replicated

#

As I said you know an actor has replicated to a client using the two ways I already mentioned

clear island
#

I thought about that but I think replicating something that would never change (like the nickname) may not be the best thing to do

fathom aspen
#

Whatever you are describing is being something particular to your setup

clear island
#

I need to know from the server, when the client has been fully replicated

#

during BeginPlay seems to be too soon

fathom aspen
clear island
#

so I was wondering if theres another event after that

fathom aspen
#

RPCs aren't stateful

#

Also that replicates like one time

#

As long as it's not changing it won't be replicating

clear island
#

ohh I see

#

hmm maybe replicating really might be the best option

fathom aspen
clear island
#

sorry, when I say "client" I mean the player character

#

which is an Actor I believe

fathom aspen
#

Yeah that makes sense

#

Correct

#

What you're describing is a classic problem where its solution is a replicated property stored in the PlayerState

clear island
#

yea I think you're right

kindred widget
#

I have a vague memory that there is a system in place for this already.

#

Sec. Testing some stuff with an overridden character component and I'll see if I can't find it.

clear island
#

I've noticed the playercontroller has a GetName() and SetName() functions if thats what you mean, but I haven't had any success overriding those values

kindred widget
#

This was still for the introduction stuff, right?

clear island
#

what do you mean?

#

I first get the nickname on GameMode::PostLogin

kindred widget
#

@clear island Ah. I thought I remembered that right. APlayerState has a playername. The Onrep for that calls HandleWelcomeMessage(). HandleWelcomeMessage broadcasts a localized Text along with the playerstate in question. Which can be bound to things like chatboxes, or HUD class for popups, etc.

clear island
#

ahh I see, that might just be what I need then

kindred widget
#

This all basically starts at AGameModeBase InitNewPlayer, which calls ChangeName, Which calls SetPlayerName on the PlayerState. You could easily override InitNewPlayer, and copy the rest but leave that ChangeName line out until your client sends their name and call ChangeName then. I think it'll work about the same.

clear island
#

interesting, I'm gonna look into it, thanks!

grizzled stirrup
#

When using Clientside CMC movement, it seems Pawn->GetVelocity(); is incorrect on the server even though it's moving at the correct speed

#

Is there a way to retrieve the correct velocity that the client is actually at?

#

It's about 3x less than it should be on the server so it's quite a significant difference

ebon lily
#

I might do a multiplayer gamejam but I haven't done anything in mutiplayer with UE, would that be time consuming?

#

there isn't much gameplay it in

#

guess it would have to be peer to peer

fathom aspen
#

There is no p2p in Unreal. The most close configuration to that is called listen-server

#

And yes this isn't going to be a 1+1=2

#

It takes time to get your head around Unreal's networking

dark edge
#

I mean go for it

#

but it'll be 5x harder than you think

vivid dagger
#

anyone using playfab for backend have a clue on how to reduce stacks from online inventory properly? using ConsumeItem is limited to just 1 item instance so it would stack up a lot of api calls

ebon lily
vivid dagger
dark edge
clear island
#

are all PlayerStates and their Pawns() available in all clients?

ebon lily
topaz knot
#

Question: When I try and connect over the internet it doesn't work but it does work on my LAN, using Epic. I've tested it a few ways. How do I trouble shoot this? I've trying checking LAN on off on both join/create session.

dark edge
fathom aspen
#

By default: PlayerStates are always relevant, pawns are not

#

Also there are other cases where it's not

#

It's not only relevancy

clear island
#

I mean from inside a PlayerState I can do: GetPawn(), is that pawn available even for simulated proxies on the client?

fathom aspen
#

Could be it taking time to replicate PlayerState at start

dark edge
#

What are you trying to do?

fathom aspen
clear island
#

I see

#

not doing anything in specific at the moment, just trying to plan my next steps

vagrant grail
#

I need to make an inventory for my multiplayer game, how would I do that ? Should I follow any tutorial about inventories ? What should I replicate and what should I not replicate ? Any good advice about how to do it ? I need to go for a Minecraft Like inventory.

fathom aspen
#

Use this channel search. You should be seeing too many examples, tips, ideas, etc.

#

Also don't follow tuts, YT ones especially

vagrant grail
# fathom aspen Also don't follow tuts, YT ones especially

I watched alot of them and everyone of them felt weird to me and looked wrong to me the way they do it and also most of them aren't the type of inventories I'm looking for. Most of them make RPG inventories style with some slots being specific to some objects (like potions, weapons,...) and most of them didn't have a hotbar

uneven chasm
#

if i have a run on server event are all events triggered from that event downstream server only as well ?

vagrant grail
quasi tide
#

All of my inventories are just arrays really.

sinful tree
#

All a standard "slot based" inventory is, is usually a replicated array.
The multiplayer aspect of it is only just a matter of handling how the client interacts with the server's copy of the array without letting the client tell the server what is in any particular slot.
Eg. You don't let the client say "I am moving a Ultra Rare Powerful Item in slot 1 to slot 2" but instead just tell the server "Move the item that is in slot 1 to slot 2".

fathom aspen
vagrant grail
quasi tide
#

Only replicate what is needed.

fathom aspen
quasi tide
#

No reason for player B to know about Player A's inventory if they're not interacting with it.

vagrant grail
sinful tree
#

Do people need to see everyone's inventory all the time?

quasi tide
#

How is it too vague? If player B is not interacting with player A's inventory, should they still get the data sent to them?

quasi tide
#

There you go. Then it is not needed.

rotund sail
#

i mean unless they can trade, should they ever interact with one anothers inventories?

quasi tide
#

Often times, I just replicate the inventory to the owner.

sinful tree
vagrant grail
rotund sail
#

ye or you can drop-trade if you have droppable items

fathom aspen
#

You can't change replication condition at runtime anyways

vagrant grail
#

but people could throw items from their inventory to the ground like in Minecraft

#

and if another player goes on top of it he gets it

#

Should the inventory be its own actor that I add to players or I can do that directly on the BP_Character ?

sinful tree
#

Do a component. That way you can add it to other things as well.... Like storage chests.

fathom aspen
#

Though I won't change it

vagrant grail
#

Could someone give me a first step to laucnh my self because I'm stuck on what to start with. Like if I do the UI first is it a good step ?

fathom aspen
#

I would have a basic UI just for testing and focus on getting the prototype done

fathom aspen
clear island
#

and it is relevant btw (both players are right next to each other)

#

so the conclusion i reached is that GetPawn() inside a PlayerState of a simulated proxy can return null at times, even if that proxy is relevant

fathom aspen
#

Your conclusion is simply wrong

#

Send code so we see what's going on

clear island
#

ok, so on GameMode::PostLogin I'm getting my player nickname and storing it inside the PlayerController

#

then, on my Character (Actor) I'm polling during tick for when the playerState becomes available on the server

#

that is on the server, you can see I'm getting the nickanem from my playercontroller and storing it on the PlayerState Nickname variable

#

that variable is replicated

fathom aspen
#

What all this has to do with GetPawn?

#

Ah ok finally!

clear island
#

it never enters that SetNameTagText block of the code

#

keeps saying its null for some reason

#

but only for the second player

#

for the first player it works just fine

#

I'm also using a dedicated server btw, if that matters

#

so basically my process is:

  • open server
  • open game client1 and join server
  • open game client2 and join server
  • client1 sees client client2's nickname
  • client2 does not see client1 nickname
fathom aspen
#

Okay that's normal

#

You are trying to get the pawn on client which gets set when APawn::OnRep_PlayerState gets called. What if PlayerState hasn't replicated for that pawn @clear island

#

You are doing it too early so it hasn't been replicated yet

clear island
#

I thought about that but then I tried adding a 3 second delay to that last line CharPlayerState->Nickname = PlayerController->PlayerName; but the issue still happens

#

I used a timer

fathom aspen
#

You shouldn't be doing delays anyways

clear island
#

yea it was just to test

fathom aspen
#

That's not how you solve it

fathom aspen
clear island
#

what I find strange is that the PlayerState itself is not null, but the Pawn is

#

I dont understand how such a thing could be possible, PlayerState is related to the pawn itself as I understand so I dont get it

#

I'm not using OnRep_PlayerState btw

#

that poll I'm doing is during tick

#

on the server

fathom aspen
#

That's not something I would do

#

OnRep is there just for that

clear island
#

such as: when its available on the server I set the replicated "Nickname" property because its the server that has that information

fathom aspen
#

I wouldn't even have a NickName on PlayerController

#

Would have it only on PlayerState

clear island
#

the only reason I have it on PlayerController is because that is what I get in GameMode::InitNewPlayer

#

the playerState itself sometimes is null during that event

#

so I chose to store it on the PlayerController

#

and then tried to pass it on to the playerState with that poll

#

I dont think I can use OnRep_PlayerState because that is called on the client and the client doesnt have the name of the player that joined

fathom aspen
clear island
#

to give more context, what I'm trying to do is just some nametags above players' heads

fathom aspen
#

Why not PlayerController?

clear island
#

the nametag widget is part of the character

fathom aspen
#

There's where PlayerState gets spawned on server

fathom aspen
#

As easy as that

clear island
#

yea tried that too ๐Ÿ˜„

fathom aspen
#

That works

#

With eyes closed I can make it and guarantee it works like a charm

clear island
#

its the same issue though

fathom aspen
#

It's not the same issue

clear island
#

during On_RepPlayerName I have to get the pawn too

#

and at that point, its null again

fathom aspen
#

You are literally using all classes to get something really simple done

#

Don't overcomplicate

fathom aspen
clear island
#

well 2 classes atleast I need which is my character (which has the widget) and the PlayerController which has the name I received in GameMode::InitNewPlayer

#

because the widget is attached to the pawn

fathom aspen
#

You see that there is no event that guarantee you the pawn is there

#

Why are you determined you wanna make it work that way

clear island
#

actually I tried to using just the pawn first, but I had some issues too a few days ago, but tbh I dont even remember what those were, so I guess I'm going to try going that route again and see what happens

#

meh, still no luck

#

I tried this on the Pawn

#

then on the server as soon as I have the player controller:

#

this sets the replicated Nickname property which is inside the pawn

#

then on the client:

lost inlet
#

there's something triggering about On_RepNickname rather than OnRep_Nickname

#

also the playerstate is not 1:1 with the character

clear island
#

not too worried about naming at this point ๐Ÿ˜„

lost inlet
#

it is with the controller, in fact the controller owns the player state

clear island
#

hmm I see

lost inlet
#

also you can't guarantee replication order of actors

#

the character/pawn does not own the playerstate

#

you can possess different pawns during the course of a multiplayer match

candid gale
#

Putting this here, I don't think my question belonged to cpp

lost inlet
candid gale
#

So the character part is redundant I assume?

worthy knot
#

MP question : Is it better to possess a vehicle pawn or have your character control it without possessing it?

clear island
#

so I finally achieved my goal doing it all from the pawn only with the code I posted above, and I now notice where it was failing

#

this variable was null, apparently this UWidgetComponent::GetUserWidgetObject() function returns null during the first few seconds on the simulated proxies for some reason

#

the overheadwidget variable itself was not null but the userwidgetobject returned by that function was

#

need to poll for it

#

I already knew about playerstate, gamestate being null for the first few seconds but this one was new to me

quiet rapids
worthy knot
#

if i possess it i cant do any of that

quiet rapids
quiet rapids
quiet rapids
worthy knot
winged badger
#

as long as your vehicle movement component is not tightly coupled with the PlayerController

#

all you need to do is SetOwner of the vehicle to get RPCs to work

#

and push the vehicle's input component on the PC's input stack

worthy knot
winged badger
#

you don't have "No owning connection for..." warning spam in your output log

#

only problem with above approach is that engine has a bug with input masking

#

and i think it affects EnhancedInput as well as old input system

#

basically, if your first component on stack has something bound to say W, and lower priority component has Shift+W

#

higher priority IC consumes the Shift+W input and lower priority one doesn't work then

#

it is just a few lines of code to fix the engine there though

#

@worthy knot

grizzled stirrup
#

@chrome bay Just re-read your article on OnRep weapon firing counters. Just curious if you were designing a basic replicated weapon today, is it fine to do stuff like this (muzzle flash / fire anim) with unreliable Multicast RPCs rather than OnRep vars?

#

Reason being is that in general OnRep stuff seems to be stateful

#

Whereas Multicast RPCs are nicely one shot and transient

#

Or is the benefit that you don't want loads of multicast RPCs being sent for fast firing weapons, rather the latest OnRep value which will only trigger the FX once?

hoary nova
grizzled stirrup
#

I'm not sure about super costly, in what way? Bandwidth?

hoary nova
#

I always thought of rpcs as top priority messages sent across, is it really necessary to use them for stuff like visuals?

grizzled stirrup
#

That's why the Unreliable tag is there

#

For things that aren't top priority

hoary nova
#

Oh I see, I haven't used that yet. I guess I'll have to look into it

worthy knot
chrome bay
# grizzled stirrup <@150632829909336066> Just re-read your article on OnRep weapon firing counters....

The burst method is stateful by design, because third-party clients in my case need to know whether the weapon is still firing when the receive burst info. This is so they can keep ticking the firing simulation and avoid stuttering/jitter by getting multicasts and/or property updates at variable times. Whether a shot was fired at all, and whether it's still firing is packed into the same property. If you do this with a multicast, you can't guarantee that the "stop" fire event will reach them.

#

Unreliable Multicasts go down the same network path as property updates btw, so they too are prioritised, respect net update frequency etc - but the point here is the burst counter is replicating both a state and an "event".

#

Automatic/high ROF weapons for instance will keep ticking the firing sim so long as bFiring is still true, and will trigger at least one sim if the burst increments once.

#

That's not clear in the article though, I should add that

#

Also, sending unreliable's means you can potentially fill the buffer up with RPC's, instead of just a single property update. Property updates are gathered at the end of the network frame, whereas RPC's are dumped into the buffer when you call them. You could throttle other properties/RPC's by doing this

grizzled stirrup
#

Thank you very much for the explanation!

#

Makes total sense now

dim trail
#

how should multiplayer cooldowns be done? if theres a low cd on an ability, potentially there could be huge dps variance because of lag

latent heart
#

You can always have the client request to re-use the ability while it's in cooldown.

#

I believe WoW had a kind of "do this thing next" if it was used close enough to the end of the current action / cooldown wearing off.

dim trail
#

wow uses a queueing system

#

but its fairly complex

#

any client side solutions are hackable

latent heart
#

I haven't played it in 10 years Shrug

latent heart
#

One would assume so?

latent heart
#

Sounds like the components are not replicating their activated status.

#

If they were replicating their status, they'd be spinning and moving properly!

#

You might try destroying the actor and creating a new projectile, as if the bat was actually a gun that destroyed itself when it fired. But that seems overkill.

graceful flame
#

Iโ€™m doing something similar with my projectiles. I have a client side only โ€œfakeโ€ projectile that spawns and triggers sfx and vxf while waiting on the server to spawn the real projectile. This reduces the feeling of lag for the shooter, but Iโ€™m now dealing with double sound because of the multicast firing projectile effect meant for other clients is also happening for the shooter.

latent heart
#

Pass the shooter with the multicast delegate and have it ignore itself?

graceful flame
#

I managed to enable Owner No See and it works for the mesh but canโ€™t get the last part working so I donโ€™t hear the sound

#

So the shooter actor? Controller?

#

Maybe just pass the net id of the shooter?

latent heart
#

Pass the character reference

#

It will be converted to a netid automatically and converted back on the other end.

#

Or the Instigator reference, I suppose.

graceful flame
#

Ohhh what?????

#

Thatโ€™s good to know

latent heart
#

You can pass any replicated object to an rpc and it will work fine.

graceful flame
#

I always thought it would be this huge character object that would eat up a ton of bandwidth

latent heart
#

If it was replicated directly, that is. Subobjects that aren't components, probably not.

latent heart
#

...what have you been doing so far?

dark edge
#

If I text you my address, I don't actually send you my entire house. I just tell you how to find it.

graceful flame
#

Yea I understand how that compresses things but I didnโ€™t realize that was happening in the first place. Makes sense now though.

latent heart
#

If you don't know that, though, Adriel, it makes sense to think that the entire object is sent, like it is with structs.

frank phoenix
#

Is there a way to disable the client to join the dedicated server when testing in editor? Working on login system and dont want to waste time on compiling

woeful ferry
#

Is there a collective name for classes that client "owns" like PlayerState, PlayerController, APawn?

#

Need it for a function I'm writing so it's not long as hell

latent heart
#

Not really.

dark edge
#

But you're better off just launching

woeful ferry
#

shidd

dark edge
#

you can make bat files to launch a client and server

latent heart
woeful ferry
frank phoenix
#

seems that this option was removed in UE5, cant find it in editor preferences

pliant moss
#

Okay this is a bit weird. I run a function on the server to spawn an actor (with an ASC). in the same function i set a gameplay tag on the actor. Now the weird part. If i use AddReplicatedLooseGameplayTag(GameplayTag) The tag only activates on the client simulated proxy. But if i use AddLooseGameplayTag(GameplayTag) it only shows on the servers actor instance. (that does make sens since its not replicated) but why does AddReplicatedLooseGameplayTag only applies to the client and not the server?

limber gyro
#

hey guys, im having a bit of an issue with a shot registering twice on the clients and only once on the server(which is what is suposed to be happening in the clients)

#

what i am doing is basicly a raycast, and if it hits the mob i subtract HP from the mob

#

the HP variable is replicated

pliant moss
limber gyro
#

it also only does this weird behaviour the first time the mob is hit

limber gyro
fathom aspen
#

How about you post some code?

#

The related stuff

limber gyro
#

sure

#
                AProjectArenaEnemy* enemy = Cast<AProjectArenaEnemy>(results.Actor);

                if(enemy)
                { 
                    enemy->HP -= damage;
                    BulletOwner->hitNotify = true;
                }
                else//if its not an enemy or a player than its the world
                {
                    if (hitDecal)
                    {
                        FRotator rotator = FRotationMatrix::MakeFromZ(results.ImpactNormal).Rotator();
                        GetWorld()->SpawnActor<AActor>(hitDecal, results.Location, rotator);
                        UE_LOG(LogTemp, Warning, TEXT("decal spawned"));
                    }
                }    
            }```
#

so i do a raycast and it checks if the resulting actor is a anemy

#

and i just subtract the hp

#
{

    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(AProjectArenaEnemy, HP);
    

}```
#

this is just the replicated var

#

its counted twice on the first hit in the clients but its fine in the server

fathom aspen
#

What calls this stuff

#

Get me into the whole picture

limber gyro
#

the actor spawns, raycasts, then dies

#

do u want the spawn code or the whole raycast code?

fathom aspen
#

I want all the code since the moment you shoot the shot to the moment you apply that damage/health decrease

#

I want to see RPCs

#

Functions

#

Authority checks

limber gyro
#

gimme a sec let me setup a pastebin

fathom aspen
#

Provide people with the full context so they can help you. Else you're just shrugging at this server and we're too

limber gyro
#

ok so this is the character that shoots the projectile, i only copied the relevant parts

#

the whole "shoot" chain

#

this is the hitscan bullet

#

any ideas?

#

it was an authority thing like @pliant moss said

#

i had missed

latent heart
#

Little tip, directly setting things like health leave you open to refactoring code later on. You should use setters, then you can respond to events and check inputs and the like.

#

Your SetHealth function could check if it's enough for the player to die and kill them, for instance.

pliant moss
limber gyro
latent heart
#

Alrighty! ๐Ÿ™‚

limber gyro
#

from a game design perspective it feels better

pliant moss
#

Yeah, and i forgot the word for it but the server needs to correct the client if the client is "wrong". there is built in functionality for that in the Character i think (Prediction is called i think)

fathom aspen
#

Your best gamble here is literally to debug and see where it's breaking

limber gyro
#

with a gate

#

and the issues got fixed, now im just being lazy and i dont want to move/search to/for a better function

wheat magnet
#

does player remain remain alive when open new level? or it reset?

fathom aspen
#

Pawns gets destroyed and recreated upon traveling

wheat magnet
#

i have main menu game mode, where player select character before joining server. when game starts, it open new level. but i want to get variable values from old level

#

so game instance?

#

because it is multiplayer

fathom aspen
#

If I had my article done by this moment...sigh

fathom aspen
#

You've got PlayerState with a function called CopyProperties

#

You can use programming subsystems

wheat magnet
#

i have two game modes. one game mode is for main menu, and other is for gameplay

fathom aspen
wheat magnet
#

but player state is same in both game modes

#

so when i again open new level with different game mode, does player state reset?

fathom aspen
#

It doesn't have to be same. Shared variables can be in a parent PlayerState where two different PlayerStates inherit from

fathom aspen
#

Upon seamless and non seamless traveling

#

Though you have a very short period of time where you can copy properties from the old instance of the player state to the new one

#

Same goes for PlayerController. OnSwapPlayerControllers

#

So my TLDR is this

If you are seamless traveling: use CopyProperties inside PlayerState
If you are hard traveling: use GameInstance/Subsystems/SaveGames

dark edge
#

You could just have sub-levels right? Or streaming levels or whatever

#

Our game is procedural so we don't do any loading ever beyond initial startup

#

Can't you just have your pawn etc in the persistent level then swap out levels under it?

fathom aspen
#

Yeah that could work too if you got sublevels

winged badger
#

you can just not spawn the Pawn until your spawnpoints are in place too

wheat magnet
#

player is possessed but not moving

#

this is only happened when i open this map from main menu map by selecting map

#

but when i open this map manually in editor and run game, input works just fine

#

what could be problem?

#

this is how i am opening this map

#

game mode is also set correctly

fathom aspen
#

I thought this function is used to persist client-only actors as it's called on client thonk

wheat magnet
#

great i already fixed using this.

fathom aspen
#

Sometimes answers are one search away

pale hazel
#

Hi, I got a problem with Multicasts being ignored by clients after the first time

I have a multicast that's fired when a character is possessed by a controller (in the ACharacter::PossessedBy method), which happens after they spawn, the multicast is responsible for giving them the correct material, depending on their team ID (stored in playerstate)

This works fine in round one, but from round two and onwards, when new characters are spawned using the same logic, the multicast is executed on the listenserver, but not on the connected clients. So on the listen server all characters have the correct color, but on the clients they all have the same, default color

So the multicast executes normally in the first round, but after that the clients never receive it

fathom aspen
pale hazel
#

Yeah I saw this when I looked through this chat, and it seems useful for late joining, but in my case all playercontrollers are in the session when it happens, I'm not switching maps, controllers, or anything

The most confusing thing is that it consistently works the very first time I spawn characters and send the multicast. it only stops working after that.

fathom aspen
#

Even if you don't allow late joining, multicasts were not designed for this

#

Whatever you're doing is stateful and that needs replication

pale hazel
#

I suppose you're right, I'll see what I can do

fathom aspen
#

Also you are calling it early on which there is a very high possibility where it could not get executed. The first point where you can get RPCs to work reliably is PostLogin

#

Though at that point the pawn should be possessed and all, still I wouldn't take the risk

short arrow
#

Why even RPC this? Why not use an integer repnotify to determine which color to set each player?

#

Seems like exactly what you'd use a repnotify for

pale hazel
#

You're right for sure, frankly it's been written like that for a few months and always worked, which is why noone in our team touched it

Only recently these Multicast calls started behaving like this, and now here I am trying to clean all this up

short arrow
#

@pale hazel Definitely switch over to repnotify for anything that has to be called when relevancy becomes apparent

pale hazel
#

I will and see if that works out, thanks

rotund onyx
#

How am I supposed to be changing levels in multiplayer? I have a lobby and a destination map. Just using Open Level disconnects everyone. I see stuff on ServerTravel but I don't know if that is the solution and I am having trouble figuring out how to use it

latent heart
#

seamless travel

fathom aspen
#

ExecuteConsoleCommand function and Command parameter be ServerTravel <MapName>

#

Can only be called from server

rotund onyx
#

Should I do that with seamless travel or without?

fathom aspen
#

Either way all clients will follow server. Though the preferred way to travel is seamless

rotund onyx
#

do I need ?listen as part of the command?

fathom aspen
#

Nope. That only if you want to make a player host a map, so he's a listen server

rotund onyx
#

seems like clients just stay in the lobby, any idea why that could be?

fathom aspen
#

My wild guess as I don't see code: You are calling ServerTravel from client

rotund onyx
#

that is in the GameState

#

maybe I should move it somewhere else?

fathom aspen
#

Oh shit

#

You can't call server RPCs in actors not owned by client, i.e GameState

#

Read that compendium fast

rotund onyx
#

that link doesnt work

fathom aspen
fathom aspen
#

rofl

rotund onyx
#

its been down for awhile

fathom aspen
#

Multiplayer support is back

rotund onyx
#

otherwise I would be using it lol

fathom aspen
#

Always download. There has been rumors that the internet is going to be down for a while soon

#

For example I have Laura's blog downloaded for offline use

#

Just in case I wake up and not find it

rotund onyx
#

well at least I have one now

#

I was using GameState so that all players could easily see which maps were selected, so I thought I could load a map out of it seeing as it was the server

#

guess I'll move that into the gamemode

fathom aspen
#

Well if you want some shared info placeholder that isn't specific to a player that's almost GameState

#

GameMode won't let you do RPCs too

rotund onyx
#

then how am I supposed to load a map as the server, lol?

#

I just need the server to take clients with it

fathom aspen
#

Literally make sure you are on server and do that ServerTravel

#

In my Character class

#

Can be either in Character, PlayerController

#

Doesn't really matter

#

This is the correct version

#

I don't know what triggers a server travel in your case. But in my case it's a key press which is client side generally, so I RPC to server

rotund onyx
#

its just a UI for me

fathom aspen
#

Ok that's client side too

rotund onyx
#

I am confused as to why my other RPCs work though. Things like map previews do seem to update correctly for clients. I was routing those through GameState too

fathom aspen
#

You need to let client side controller which is the owner of your UMG that you clicked that UI button so it triggers an RPC inside the PlayerController which does the servertravel

fathom aspen
#

You were faked into thinking they do

rotund onyx
#

I have a multicast in the gamestate that was clearly working

fathom aspen
#

That works

rotund onyx
#

what can the gamestate do?

fathom aspen
#

Did I say it doesn't?

#

I said you can't server RPC

rotund onyx
#

ok clearly I dont understand what RPC means

#

what does it mean?

fathom aspen
fathom aspen
weak osprey
#

So sorry to interject; I have what I hope is a quick question.

I created a multiplayer VR game in JS, using websockets, and it was insane, and I never want to do that again, lol.

I'm wondering what the easiest possible way to get started making a multiplayer situation in ue5 is? (with blueprints)

Is it to just literally work through the docs?

Or, should I go the other way around and hack Lyra?

fathom aspen
quasi tide
graceful flame
#

Lyra is too complex when youโ€™re starting out imo

fathom aspen
#

I feel blessed everyone's using my copy now hype

graceful flame
#

Thereโ€™s other far more basic multiplayer templates out there

weak osprey
#

I've built 3 games in ue5

twilit radish
#

I was just about to say, did no one make a copy?

#

xD

rotund onyx
graceful flame
#

Ahh okay

weak osprey
#

but none of them are multiplayer.

rotund onyx
#

so clearly I am misinterpreting the document

quasi tide
#

Okay cool. That link is still your new bible.

weak osprey
#

word.

#

OK, and it applies to ue5 I'm assuming

twilit radish
quasi tide
#

Yes

weak osprey
#

got it

fathom aspen
#

I just don't get it

weak osprey
#

what about the idea of buying a kind of pre-set up networking system on the marketplace; is that a way to just get up and go with it?

quasi tide
#

Sure

#

Quality is up in the air obviously

weak osprey
#

is there any that people use here?

#

and feel good about

fathom aspen
quasi tide
#

Pretty sure like everyone just does their own because it's so darn easy in UE

rotund onyx
weak osprey
#

oh ok

graceful flame
#

Well multiplayer is just replicating all the actors and properties that need to be replicated across the network for all clients to see properly. The server remains the authority and can be either a player (listen server), meaning someone โ€œhosts a gameโ€ for others to connect to, OR you use a dedicated (headless) server which is just a terminal running somewhere on Amazon server or something.

weak osprey
#

that's cool to know

rotund onyx
#

not sure why you couldnt just say so lol

fathom aspen
quasi tide
#

There are some stuff that makes using the subsystems easier, yes

rotund onyx
weak osprey
#

alright, I guess I'll use the compendium and give it a shot, and if I start crying I'll come back lol

rotund onyx
#

you will cry

weak osprey
#

๐Ÿ˜ฆ

rotund onyx
#

the nature of multiplayer is such

twilit radish
#

This video is also awesome btw: https://www.youtube.com/watch?v=JOJP0CvpB8w

An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.

Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe

00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...

โ–ถ Play video
quasi tide
#

A thousand times that

#

Yes yes yes.

rotund onyx
#

the blueprints arent actually complicated, but the concepts and little rules are what kills me

twilit radish
#

I mean that's just multiplayer in a nut shell, no one who knows what they are talking about ever said it was easy haha

#

Only if we could just get rid of latency and cheaters ๐Ÿ˜”

graceful flame
#

The biggest thing to understand when it comes to multiplayer is that thereโ€™s only really one true instance of the game running and itโ€™s the server who runs the real game. All the connected clients are simulating the game world locally and simulating the movement of other playerโ€™s characters as the server sends out packets along the network.

quasi tide
twilit radish
#

๐Ÿ˜›

#

Or dedicated servers actually being affordable for small teams / games. That would also be very cool.

graceful flame
#

So when youโ€™re playing your favourite online game and thereโ€™s lag spikes which cause your character to stutter and rubberband all over the place, whatโ€™s happening is that the server and client disagree with where the current playerโ€™s location is. Since the server is the authority (to prevent cheating) it issues a movement correction teleport and the result is what players usually call lag.

stiff nebula
#

if your game is casual ive noticed that in games with a smaller playerbase they lack a cheater problem if theres a vote kick system in place

#

ive not seen a single cheater in quake live / diabotical / dirty bomb

twilit radish
#

If it's a PvP game and it gets big enough cheaters are almost always unavoidable.

graceful flame
#

or if thereโ€™s a way to farm gold and then turn around a sell gold for real money, then youโ€™ll find lots of cheaters too

stiff nebula
#

true, riots anti cheat is really great and ive still seen about 4 hackers

#

though i think all got banned

twilit radish
#

The one big game I'm aware of that is PvP and doesn't have cheats in the main concept of the game is Rocket League.

stiff nebula
#

oh yeah, cant really do many traditional cheats in that game

twilit radish
#

In the regular game modes all you can do is find exploits in theory. But this obviously isn't viable for like any other game xD

#

It just happens to be nice for RL haha

dark edge
twilit radish
#

Well yes, but I was referring to hosting them your self.

dark edge
#

Yeah that's pretty much a no go unless you got money.

rotund onyx
#

how does one set values in the PlayerState?

fathom aspen
#

Like you would set in any other class

rotund onyx
#

basically I want clients to pick a color, and I dont know the order of events to actually get that choice over to the PlayerState

#

I assume it is owned by the server

fathom aspen
#

It's not

#

It's client owned

#

It's spawned on the server though

fathom aspen
rotund onyx
#

I have a separate issue where the server is getting a duplicate UI, I dont remember how I fixed that last time

#

I thought having a function that just constructs the ui on owning client would work but it doesnt

fathom aspen
#

HUD is generally the class that constructs widgets

sinful tree
#

You need to use HasAuthority or IsServer checks.

rotund onyx
#

does it even need to be a replicated function then?

sinful tree
#

Probably not, unless you want the client to wait for data to be replicated before creating the UI.

rotund onyx
#

ah good to know

sinful tree
#

Even then, perhaps not an RPC to do it.

rotund onyx
#

if I do this

#

wouldnt the server never make its own UI?

sinful tree
#

Correct.

rotund onyx
#

so how can I just make it once for everyone?

#

I can't believe this is so hard

sinful tree
#

Well if this is player controller, you could probably do IsLocalPlayerController

#

Then only when true create the UI (if you only want it created on the local controller)

stray thunder
#

If I change game modes, do the player states stay the same?

fathom aspen
rotund onyx
fathom aspen
#

What do you mean by widget? UMG or 3d widget component?

#

Ok UMG is client only, so each player will have his own UMG widget

#

Though they can share the data and both widgets can pull from that data source

rotund onyx
#

recreate or just update it on all clients

fathom aspen
#

Yeah there should be some sort of interaction with the server. Clients can't talk to each other directly

#

Especially that local PlayerControllers don't know about each other

clear island
#

quick question about organization in code, how do you guys organize your code to account for delayed initialization of components? things like playerstate, gamestate, controller and sometimes widgets take a few seconds to fully initialize so I poll for it during tick, but once you get to a point where you have many of these variables that can have delayed initialization, things start getting quite messy,when polling for so many stuff, so I'm just curious how do you guys do it?

fathom aspen
#

PostInitializeComponents

clear island
#

does that guarantee that playerstate, controller, gamestate and stuff will all be ready at that point?

latent heart
#

Neverrrrrrrrr

fathom aspen
#

It's per actor and it guarantees that components have been initialized

fathom aspen
clear island
#

yea thats why I use poll during tick

#

but the code is growing out of control

#

with so many variables

#

so just wondering how other people do it

fathom aspen
#

If you mean guarantee that it replicated then that's another story we had last night

#

Use OnReps

#

If you mean initialized on server then you have to know the order of actors creation

clear island
#

yea for clients, I'm relying onReps to detect that

#

there's things however that are initialized but not 100% ready sometimes

#

as I discovered last night, for instance UWidgetComponents will be initialized because I'm creating it on the constructor of my actor

#

but, it wont be ready

#

not immediately atleast

fathom aspen
#

I'm not sure what ready means

clear island
#

when I do UWidgetComponent::GetUserWidgetObject()

#

that will return null for the first few seconds

#

so thats just another case where I'm polling for it during tick

#

whenever that returns something other than null, then I have a boolean that tells me bWidgetIsReady

#

its these delayed initializations I'm talking about

#

but after a while having to create a boolean for every case like that gets messy

#

it works, but its not very organized

#

I suppose theres no other way around it, not a big problem anyway

fathom aspen
#

This function is what you need

#

This what calls it

#

Like literally it's a matter of discovering the source code

#

Also you never access a pointer without checking if it's null

latent heart
#

The check and what you do on the result of that check are important, too.

#

Silently failing null checks are super bad.

clear island
#

my issue yesterday was that my nickname onrep was being called before my widget had been fully initialized (despite being created on the constructor), the widget itself was not nulltpr but when trying to get its userwidgetobejct with GetUserWidgetObject() it returned null for the first few seconds, but yea I wasn't aware of that update function, I think thats what I need, thanks

clear island
fathom aspen
#

There's a good chance that this is what you need:

#

Play around with it. See what calls what

clear island
#

hmm yea, gonna have to try, I wonder if I can call it during the constructor

#

the fact thats its not called by default makes me think I cant

fathom aspen
#

You don't call it. You should be able to bind a delegate to it so it's called when it gets executed

clear island
#

oh I see

#

gonna look into that

worn wagon
#

Anyone successfully used PlayerController->SetIgnoreMoveInput in multiplayer? When being run on the server it works for the host but not clients. I'm looking for a way to "freeze" a player in multiplayer, the only way I have found to work is by setting the movement mode on the character pawn's movement component Char->GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_None); But I'm hoping there's a different way, this doesn't feel like the "correct" way of doing it to me.

fathom aspen
#

I know no other way but this

#

Oh and StopMovementImmediately iirc

worn wagon
#

How would I reverse it?

fathom aspen
#

Yeah you're right it's only when players die. I would also probably try SetInputModeUIOnly

worn wagon
#

I guess I'll stick with movement mode

#

I just don't get why SetIgnoreMoveInput doesn't work on the clients, or what the point of the MovementState is either. I also tried MovementState.bCanWalk = false, which didn't work.

fathom aspen
#

CMC is a nightmare

fathom aspen
worn wagon
bitter swift
#

After declaring an RPC call, I noticed there are two ways of calling it. You can call the Funciton as the name is declared OR you can call the Function_Implementation().
Does calling the implementation mean that it only runs locally?

fathom aspen
#

Correct

latent heart
#

(in 280 odd files.)

clear island
#

I really need to get into the habit of using that more often

rotund onyx
#

ok I still can't get my levels to load on both client and server

#

you'd think it would be simple but somehow this is hard

fossil spoke
#

@rotund onyx Does your GameMode have bSeamlessTravel enabled?

rotund onyx
#

no

fossil spoke
#

Probably should do that

rotund onyx
#

I need different gamemodes and player controllers though

fossil spoke
#

Ok?

#

Enable it on all your GameModes...

rotund onyx
#

no I mean like I dont want the gamemode to persist because I need to use a different one

#

same for player controllers

fossil spoke
#

The GameMode wont persist if the level your moving to has a different one.

rotund onyx
#

I just need clients to not disconnect

fossil spoke
fathom aspen
fossil spoke
#

Keep in mind that SeamlessTravel does not work in the Editor.

rotund onyx
#

I'm just reading the list of persisting actors from that compendium and trying to figure out how it works

fathom aspen
fossil spoke
rotund onyx
#

ah conveniently omitted

fathom aspen
#

It persists to the transition level by default

#

Not destination

fossil spoke
#

There are a lot of nuances to Seamless Travel.

#

Its difficult to understand until you understand it lol

fathom aspen
#

Yeah it's really. I started writing a post like a month ago and I can't finish it xD

#

20min+ read time lol

languid cobalt
#

Anyone able to explain why set actor rotation through a server->multicast only works when the server executes vs when the clients execute?

#

When the above code executes for the server, it rotates for everybody. When the code executes on the clients, they only rotate locally and neither the sever or other clients can see the rotation

#

Pretty much using the base ThirdPersonCharacter. I don't recall changing any CharacterMovement settings

shell forum
rotund onyx
quiet rapids
quiet rapids
# languid cobalt

To call a server rpc from client, you must be owner of that actor.

thin stratus
thin stratus
#

That was mostly useful for Mobile

#

Where you couldn't (still can't?) upload big APK files

#

So you upload a small one and download the remaining chunks ingame.

rotund onyx
#

I would love to know if you find a way to do this. So far I have found no way that doesn't require port forwarding. You will not be able to directly replicate assets, partly because UE won't do it natively, partly because they will be much too large to simply replicate by checking a box.

quiet rapids
#

My bad.

rotund onyx
#

I do know steam lets you download and use workshop items at runtime, maybe that can be a way around the issue if you don't find a better way

#

I'm still trying to figure out my thing from earlier. I want players to pick some simple settings (just represented as strings in my project) before joining a multiplayer lobby, but I don't know how to get them loaded properly.
Someone said to store them in a config and load it after getting into the game but atm all it does is load it on everyone's playerstate and obviously I don't want that. The replication of this has gone totally over my head and I could use an example if anyone has got one

thin stratus
unique sparrow
#

Also the console have the following errors
MyStaticArray: illegal qualified name in member declaration
type cast: truncation from const int32* to int32

fossil spoke
#

@unique sparrow Use a TArray<int32> ?

unique sparrow
#

So I can use regular tarrays without changing their size right?

fossil spoke
#

Well pushmodel doesnt support array replication anyway.

fossil spoke
#

It treats it with normal replication rules

unique sparrow
#

Isn't this macro for that use case only?

fossil spoke
#

Unless its changed Im pretty sure its not supported.

#

It maybe WIP still ๐Ÿคท

#

Unless you can find an example in Engine Code i doubt its actually usable.

#

You may want to look at FastArrays

unique sparrow
#

Maybe I should try with Tarrays?

fossil spoke
#

FastArrays are similar to what you want with PushModel

unique sparrow
fossil spoke
#

Then your out of luck.

unique sparrow
#

Should have worked though๐Ÿค”

fossil spoke
#

๐Ÿคท

#

Never used it, didnt know it existed.

#

Doubtful it works.

#

Or there is something missing from the explanation of how to use it.

unique sparrow
quiet rapids
#

They should have updated the example though

unique sparrow
unique sparrow
faint eagle
#

Is there a guaranteed order of replicating player states and game state to clients and player controllers and HUDs BeginPlay events on clients?

iron crest
#

Hello, I Have A Problem, I Have An Attack Move Set Up Where Everytime You Attack Your Character Moves A Bit, Now Im NOt Sure If I Should Use Switch Has Authority Or Just Normally Replicate The Event, It iS Being Called Through The Anim Bp Btw here Is A Screenshot Of My Bp. Everytime I Test It Either Makes Both Players Move Or No One Will Move

quiet rapids
#

You might consider adding impulse for the autonomous player too in case you see lag, but you then also need to make sure that server replicated movement don't make it jitter due to lag. Anyways just doing that on server would be all fine though.

old yoke
#

Is there a way to delay/disable new connections to a dedicated server while changing map?

wooden cypress
#

How do I get a controller from a gamemode? My kill counter variable is stored inside of a controller which I need to get to display it on the HUD

latent heart
#

If it's on a client you want to get that information, it's not possible.

wooden cypress
latent heart
#

Game modes don't exist on clients.

#

You should store state information on the game state class.

#

Then you can use the game state's player array to get its players.

wooden cypress
#

Its per play kill counter though

latent heart
#

And, again, the states of players should be on their player state class.

wooden cypress
#

If its on state wouldnt it be conjoined with all other players instead of being each players individual kill counter

latent heart
#

It doesn't matter where the data is. It's the game mode that's the issue.

latent heart
wooden cypress
#

Ok, how would I get a int variable from a controller within a function

latent heart
#

You need to get a reference to the controller.

#

I believe UMG widgets have a "get owning pawn" or something.

#

Get that, get their controller and then cast it to your player controller and get the int.

wooden cypress
#

I'm getting html Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetOwningPlayerPawn_ReturnValue". Node: Cast To BP_Controller_Mouse Graph: Get Kills Function: Get Kills Blueprint: WP_HUD

quiet rapids
#

You can have a valid check

wooden cypress
#

This is within my HUD get Kills function

quiet rapids
#

Or bind?

wooden cypress
#

Its onPostLogin

latent heart
#

Is that creating a widget every tick? Nvm

quiet rapids
#

Why you sending a client rpc? Just do in player controller begin play

latent heart
# quiet rapids locally

To clarify, begin play is called on both server and client, so you need to make sure it's only called on the owning client's side (or on the server if it's a listen server's local player controller)

quiet rapids
wooden cypress
#

The kills is stored in the controller

quiet rapids
quiet rapids
quiet rapids
# wooden cypress How?

There is a variable in the hud called PlayerOwner, get it and cast it to your player controller and then you can access the kill from it.

quiet rapids
latent heart
#

It's not called on the server which is nice, that is, if you set the hudclass in the PC.

wooden cypress
#

I think this works thanks

flint star
#

Is there a way to order OnReps?
I have 2 components on the same actor
On server I set value in comp A then value in comp B
but OnReps fire on client in wrong order
value on CompB then value on CompA

fathom aspen
#

Call an RPC back when first OnRep is called

#

Then set value in Comp B

quiet rapids
quiet rapids
#

Maybe in some cases it might make sense but I can't think of it out of the box right now.

flint star
#

well it's very hard to untangle, they were not designed to be related, they just got related AFTER we needed a specific edgecase fixed

#

and I would like to avoid costly refactoring just to fix a small issue

quiet rapids
flint star
#

not together, but in the same frame

fathom aspen
#

Also you need to call an RPC for every connection

#

Which also sounds weird

quiet rapids
quiet rapids
flint star
#

I was thinking of explicitly calling multicast in the CompA, since it will arrive before the OnRep
but IDK if late join replication won't be fucked as well

latent heart
#

There's no guarantee that the updates to the values will be sent in the same frame or, indeed, anywhere near each other.

latent heart
#

It'd be fairly simple to set up a client-side state when the values are replicated. "ReadyToRecieve" "ReceivedA" "ReceivedB" or so.

#

And only trigger the functions you want when they are both done

quiet rapids
latent heart
#

Yes. That is a better solution.

quiet rapids
#

So better remove the dependency.

flint star
#

sure, but like I said they are not really dependant in all cases

#

just in 1 edgecase

#

so tying them together completely would lead to more issues

quiet rapids
silk trench
#

hi there - it might be a long shot, as the problem is with the code i have not written and don't really understand network/replication but maybe:
in NetworkPredictionServiceRegistry, when GetDataStore hits this ensure
npEnsureMsgf(ModelDef::ID > 0, TEXT("ModelDef %s has invalid ID assigned. Could be missing NP_MODEL_REGISTER."), ModelDef::GetName());
is this something simple to fix or requires the intervention of a programmer who actually wrote it/understands that?

wooden cypress
#

Why is the event AnyDamage not being triggered here when I use F?

quiet rapids
#

AnyDamage is not a virtual function that you are overridding & is called from TakeDamage itself which is known as ReceiveAnyDamage in c++.

#

If you have overridden TakeDamage, then make sure you call ReceiveAnyDamage to get it working

wooden cypress
#

The return value of Apply damage is 0

#

I cant figure out why

wooden cypress
quiet rapids
#

You use C++?

wooden cypress
#

I do not since it looks horrible

#

Scary

quiet rapids
#

Didn't saw you are calling on client. AnyDamage is only called on server

#

You need to apply damage on server

#

not on client

wooden cypress
#

I have one more ApplyDamage node but thats it

quiet rapids
wooden cypress
#

ApplyDamage only executes on server

quiet rapids
wooden cypress
#

How would I force a node to execute from the server?

quiet rapids
#

This is just a note that it should be called on server.

quiet rapids
#

call it from there

alpine flower
#

Hello, can somebody tell me what is wrong in here? Client runs "Open" but "Open" can't run "ClientOpen".

quiet rapids
#

You don't own the door so you can't send rpc

alpine flower
#

I also tried to call rpc from here to character and then open by casting to door

#

Client still can't do anything

alpine flower
#

sec

#

doing screen shots rn

#

door bp rn

quiet rapids
#

Seems right, did you try debugger or print statement? Which event is it not reaching?

alpine flower
#

i'll try to detect whats wrong with print and i'll tell you

quiet rapids
#

Just first make sure that custom event open door is called on client

#

Just add a print statement there and see if says client

alpine flower
#

fails here

quiet rapids
#

Although this shouldn't be handled by multicast. Opening door is a state and should be handled via OnReps

#

I suggest you after fixing this to work to get a better understanding of rpcs, shift the logic using RepNotify

#

Otherwise when a player gets relevant later or rejoins, He will still see the door as closed

alpine flower
#

its coop game so there are two players

#

if one leaves lobby closese

quiet rapids
#

What if you plan to extend the game? You will have to redo all stuff.

alpine flower
#

okay i get it

alpine flower
#

but when serverside calls it it goes further

#

input action calls it

#

it is

#

components too

#

only interaction comp is not

#

Can you show it somehow? I dont get what you mean

stray thunder
#

in a multiplayer game, where do you guys attach your ui/hud?

alpine flower
#

gamemdoe

fathom aspen
#

Unless that's a multicast

#

That was not what I said

#

GameState is not client owned and you can RPC

#

Multicasts

#

You are wrong

#

Yes from server on GameState

#

You can also from client iirc but it will be local

#

You can be. That doesn't make it right

#

What? Client calls a server RPC so it executes on server

alpine flower
#

So i have to make a RepNotify boolean on interact set it to open/close (as server) and when it changes call open door in bp_door?

chrome bay
#

You can only call a Server RPC on something you own, which doesn't include the GameState

fathom aspen
#

Multicast that is called on server-side GameState is executed on server and all connected clients

chrome bay
#

Multicasts can only ever be called by the Server

#

A client asking the server to call a multicast is a pretty obvious security issue too

fathom aspen
#

Yes

#

You can call multicasts

#

I didn't say that

chrome bay
#

You can never multicast from a client anyway

fathom aspen
#

You said you can't call any RPC

#

Including multicasts

#

Which is wrong

chrome bay
#

Sounds like a semantics thing really. A client cannot call RPC's on a GameState. The Server can.

fathom aspen
chrome bay
#

A client can receive multicast RPC's from the GameState however. It will not receive Client RPCs

fathom aspen
#

It's clear

chrome bay
#

What was the question again ๐Ÿ˜„

fathom aspen
#

This how it all started

fathom aspen
#

Did I say it does?

#

I wasn't talking about GameState at that pint

fathom aspen
#

You don't say complete sentences

#

That can very much misleading

#

Ok that was next sentence xD

#

You can keep going back to the chat and trying to find me wrong

twilit radish
#

I think you both are getting things a bit mixed up, relax. You both got the same spirit lol.

fathom aspen
#

Also I answer in this chat regularly. You are welcome to prove me wrong at any point

twilit radish
#

Both of you're are trying to say the same thing but are confusing each other haha

#

:/

fathom aspen
#

Yes that's the only thing you're good at trash talking. I get to block you now so I make sure I don't see lame messages in this chat

#

You literally messaged me a few days ago from another account trying to understand my history, and now you're with new account trying to brag with your skills. Not on me boy

#

Danii

#

Just for the reference:

twilit radish
#

Guys.. Just stop please. If you don't like each other fine by me and the rest I assume, you both had the same idea but both didn't seem to understand each other's intentions. But this is just really unnecessary.

latent heart
#

To be fair, you can call an rpc from anywhere on any system, it's what you call it on that matters (with respect to if it actaully runs)

#

It may run locally.

twilit radish
#

Most RPC/multicast related stuff still runs, but it gets executed locally yeah (although is likely not behaviour you want).

latent heart
#

You absolutely can, @quiet rapids

fathom aspen
#

Even multicasts can be called from client, though they will run locally. so my "iirc" was even correct

latent heart
#

A multicast one on gamestate will run quite happily, locally.

twilit radish
latent heart
#

A server one will do nothing, however, unless it's run... on the srever.

#

Yes they will.

#

The only things that are dropped entirely a single-cast RPCs called on the client to the server on an actor that isn't an autonomous proxy on that client.

#

That does not include a listen server calling a server rpc on a different client's actors.

#

Even though you might expect that to fail because "oh, not srever, we're the client at this point!!!111"

twilit radish
#

Listen Servers are weird honestly xD

#

Lets make everything a dedicated server, easy fix.

fathom aspen
#

Dedicated servers are โค๏ธ

#

Their prices though BabyRage

twilit radish
#

Make a good game, then get bought by Epic the moment you're going to go bankrupt and all problems are solved ๐Ÿ˜›

latent heart
rotund onyx
#

Hey guys I am still struggling to get my players' selected color to load when they join a server.
Currently I'm trying to get them to load their config when they join a server but it doesnt seem to work properly, because everyone only sees their chosen color on all other players.

latent heart
#

How are you 1) sending this colour 2) storing this color 3) retrieving this color

rotund onyx
#

I am trying to store it in the playerstate so it is easily accessed by everyone

low flame
#

I may have posted this in the wrong channel, would anyone know how to solve this local multiplayer spawning issue #blueprint message

rotund onyx
#

the color in config I can represent in whatever way. Currently its just a text doc with a string

latent heart
#

Save it to an ini file?

#

So how are you sending the color to hte server when you join?

rotund onyx
#

because I dont know how to do that

#

reading the file

#

its just a string

latent heart
#

Just marking the value as config should store the value and read it back automatically.

#

In BP at least, you have to do an extra step to save in c++

rotund onyx
#

honestly I havent even heard of that

latent heart
#

I'm not suire what the default config is for games.

rotund onyx
#

I'll worry about storing it later

latent heart
#

But there will definitely be a way to do it

rotund onyx
#

I know my text doc works because the color does load

latent heart
#

That's fine.

rotund onyx
#

it just loads on all players instead of just the owner

latent heart
#

So how are you sending it to the server?

rotund onyx
#

this is in the playerstate

#

LoadMPOptions just loads the file

#

ignore the timer

latent heart
#

Nothing there sends info to a server

rotund onyx
#

how should I do that?

latent heart
#

You want an "executes on server" node

#

Not "executes on owning client"

rotund onyx
#

how do I make sure only the owning client loads their file?

#

I dont want the server overriding it

latent heart
#

Use the player controller

#

the begin play, don't use a timer

#

check if it's the local controller

#

Then run an 'execute on server' node

#

The parameter being your chosen colour and whatever else you want to send.

#

On the server end, set the value for colour (and whatever else) in the player state connected to the controller and make sure the variables are set to replicate

#

Your MP options should load once, at the start of the game instance, not every time you join a server

#

You can store them on yoru game instance (where you can set them as config variables) or a user settings class somewhere

rotund onyx
#

I'll give it a shot, thanks

woeful lantern
#

Hello, do somebody know why the child actors are not replicated here? This is how I spawn them.

dark edge
latent heart
#

There should be a pop-up when joining the server, "Are you using child actor components?" If you click yes, it just bans you.

dark edge
dark edge
latent heart
#

A prefab sort of thing

dark edge
#

Modular stuff is a pain with the Actor/Component split.