#multiplayer
1 messages ยท Page 650 of 1
you have your notify set in your montage correct?
or w/e anim asset you're using
just adjust it there
have it trigger when you want it to
I actually don't use montage atm.
It's all done with via the animationBP with his states
Every time i've tried to work with montage's it felt really wrong to me, but yeah. It's probably better, maybe i just need more time with it
how has it felt wrong?
The Slot system inside of the AnimationBP and that i need a reference to the Montage in C++ code
it's not so bad once you get used to it
you just need to set the slot in your anim bp before the final anim
Hi, I'm trying to replicate an event to all players, and I'm wondering how to go about it. Essentially it's treasure that appears in a random location in level that all players can see, and a HUD notification saying it appeared. Also, where would I place the code for it? Game mode? Player controller?
Depends on how you're spawning it.
Assuming the server is spawning it, then you can spawn it from your game mode, and then fire an event off on all player states, via the array of player states in the gamestate, to drive your HUD notification
@fading birch thanks. I'll dig into it.
Is there some way to detect the current vs late replication in a RepNotify or do you have to do both RPC and RepNotify to do something akin to the explodey barrel?
I would use a RepNotify on GameState for that. Spawn the actor, then set some data on Gamestate like bTreasureExists or whatever.
Current vs Late?
theres actually an example of that problem in the learn tab of the ue4 launcher
where player joins late and an already opened chest plays its opening vfx
i think their solution was vfx and stuff on an rpc and stateful stuff on the rep notify
@half jewel You're right about that solution. I think they have that setup in the replication map on the Content Examples project
Everything that should happen in the moment of opening the chest should be an RPC. Everything that longterm defines the state should be an OnRep
I usually do this as a struct with info such as When was it opened. That way you can set the animation to the last frame if it's been a while since the chest opened
Yeah what I mean is, is there any way to leverage RepNotify in such a way so you don't need to do the separate RPC?
I guess if you somehow keep track if when it was opened via a timestamp
So that longer ago opening doesn't trigger the rpc stuff
It's definitely sometimes better to use more than just a boolean to represent the state
is there a way if test a multiplayer game with a dedicated server , how it handles more clients , like 10 clients for example ,with out having people testing it ,?
I guess some unit tests or so but nothing build in
Usually you test with real players i guess
Anyone noticing how slow Player State variables are updating/replicating on the client compared to the server instance for multiplayer?
hey, could someone help me on how to make teams? I need to make a sort of a CTF game mode and i've been researching and found literally nothing on the internet for that sort of game mode, i knew about some stuff like "player state" and "game state" but have no idea on how to implement teams or the flag for the classes if i use them
NetUpdateRate
there an easy way to cast to player state from game instance? or the other way round can't find what links them
What is "to travel"?
In the guide I'm reading already starts talking about the different types, seamless and not seamless. Bit it never defines what it actually is.
can anybody help?
That's not what the word cast means. Anyway, the GameState already has an array of all PlayerStates.
anybody?
Hello I am expanding on my team select project ( https://forums.unrealengine.com/showthread.php?140512-Team-Select-in-Blue-Prints-for-Multiplayer ) for a community based example CTF project for others to look at and hopefully learn some stuff. If anyone has any other thoughts of things I should look to include let me know. Laundry list: Gamep...
@plucky prairie i kind of just want to know how it works like how would i make teams? or how would i end the game when somebody pickups the flag?
Begging doesn't help but start with making an enum that contains all the teams.
Yeah i got that, but like where exactly would store the variable? @dark edge
On PlayerState and also on the pawn. You could also use tags if you need projectiles and other things to have teams.
The more involved way of doing this is to make a new ChildClass of an Info Actor and call it TeamState.
Add all the info into that that you need, an array of Controllers and PlayerStates, etc.
And have a pointer on the PlayerState to the Team they are in
The less involved way is the Enum I guess
Then you would store a lot of data in the PlayerState and GameState
i thought i should've had an array of controllers for the team
Yeah though both is better
Or maybe even only PlayerState
Cause if you want to list the Players of a Specific team to a clien,t they won't have any entries in the controller array, despite maybe their own
how would i get the list of players for a specific team for a leaderboard for example @thin stratus
Would looping through the player list array from the game state and then getting the enum variable from the player state there be fine?
Yeah if the enum variable is replicate
Last time I implemented teams I made that TeamState
And have all info in the TeamState
i see im going to go the easy route with the enum thanks a lot
thanks a lot i figured a lot of stuff out and i think i can make the teams now
Heelo guys
i have some issue here in my game
the issue is the client not travel to the same map
how can i fix this
rocks random spawn
your rocks are being created locally and not replciated
client made his own rocks compared to server
either spawn the rocks server only and mark them replicated
or use some determintstic random using a seed, so client generates the same rocks
anybody some tips or resources for standing on moving plattforms/ships/vehicles in multiplayer?
I fixed it
the issue was rocks not replciated and it was spawning in client and server
thank you
i need some help
im taring to run montage on other player from player using trace and is working on server to client and is not working on client to server
using this events and exec target is other player
is not working idk what i need to do
is not working idk what i need to do
interact
ok i got some stupid idea and is working
someone can explain me why my approach was not working i confused ๐ค
anyone know why it might be that when i start a client in the editor, and listen server is started for me - the listen server doesnt load config files (that im using for various required info)?
Can you check in your previous approach whether you are getting animation montage correctly without being null to all clients.
Hello everyone.I am using Default online subsystem.When my player creates a session he will go to thirdPersonExampleMap.When another person finds a session it is visible but when he joins that session he is also going to Third PersonExampleMap but there is no host in that map.He is the only one in that map.Plz help me.Thank you
When calling ServerTravel, by default all player controllers are persisted, but what about any possessed pawns? Will they be unpossessed and destroyed by default, or should I tell all my controllers to unpossess first before any map transition?
Player states, the game mode, the game state, and the game session are held when traveling. They are handed over to the new level upon arriving.
pawns are not.
player controllers are destroyed and a new one, matching the levels game mode player controller class, is created and the client is assigned that controller. Then the default pawn for the gamemode is spawned and possessed by the controller.
๐ That's what I was expecting. I think the issue I was experiencing came from testing in single-process PIE--I guess the clients got stuck and didn't reload the map, so it looked like they kept their possessed pawns. After switching to multiple processes, map transitions look like they're working fine, but loads of other things are broken ๐ My fault for having the wrong configuration for testing up to now.
Is it safe/practical to test anything in single-process PIE? The documentation says it may have "issues" but doesn't really give examples. Apart from server travel not working correctly, everything is much more stable in single-process mode, which makes me think it's just hiding a bunch of real issues.
You should always test actual builds.
Or at least Standalone.
it's also not true that GameStates survive the ServerTravel
@fading birch
It's in the actor travel list.
But only one way
Killing it
Or why it's transfered.
Ah
Thanks for the clarification
I thought it may transfer some attributes like the playerstate does
@thin stratus actually doesn't server travel work in PIE? I swear it does. Testing in standalone and packaged builds is a good idea too. But if you're testing travel stuff, pie should be fine providing server travel works in PIE
seamless doesnt
Hrm that's odd
Yeah it's Epic :P
It'll give you a warning or error in your log even 
I'm still kinda confused what kind of server will be run when i start with this settings.
Is that also just a listen server in the background or is that a dedicated server ?
"The editor will act as a Client. A server will be started for you behind the scenes to connect to." isn't very clear to me ๐
Alrighty
The Server code will react like a DedicatedServer though
react like a DedicatedServer
Does that basically just mean that there aren't any things which will render and similar ?
And some more, yes
Alrighty ^^
Does UE offer a way to run animations on dedicated server's ?
I've just read a post from siliex that Riot is doing that for valorant (for accurate hit detection) and i feel like it would make my life much easier :S
You should be able to play them on the Server just fine
Yeah, it does work just fine on the listen server, but with the case from above(Or when literally using a dedicated server) it wont be played
How is your MeshComponent set in terms of Visibility Tick?
Do you mean this setting here on my skeletal mesh ?
You sir just saved me from a lot of pain, thanks ๐
Does it help?
Yeah, now it runs with the case from above.
Can't really test it on an actual dedicated server though since i don't have a source build
Alright
Is replicating an existing actor without custom properties an expensive operation bandwidth/server side? My main concern is when actor start and stops replicating for specific connection frequently, so it spawns and despawns on client.
Starting and Stopping frequently is almost certainly not a good idea
Dormancy has the same problem just without the cost of actor spawning. But if you change between awake/dormant often, each time it's opening a new channel - which means sending all properties again, even ones marked as Cond_Initial
was wondering if i could get any help - im getting accessed none blueprint error for the player state ref that is here -
It's a replicated actor so you can't garauntee it exists when you try to use it
Should use a validated get
i've got this in the blueprint and on the event tick print string the server side its firing as true - its just the client player when they join the server is returning as false
so its just the client player player state not being set
PlayerState Actor needs to replicate separately from the reference to PlayerState
only after it does do you get a valid PS
replicating an Actor reference doesn't automatically replicate the Actor itself, its just the Actors NetGUID
ok i think i managed to fix it - the blueprint actor that is tracking all of this information itself wasnt set to replicated in its own class defaults
because i just set that to replicated and tested it again and they are both firing as true in the same server
just make sure you test frequently with packet loss and latency
Editor is rarely a good test environment for multiplayer stuff
also, GameMode or GameState are supposed to track that stuff
not a separate Actor
one thing you really don't want is Actors that you really don't need replicating
so i just tested it out to see what would happen if i complete the race on the server with both players there and i got a single blueprint error of accessed none inside this function
before i was getting a bunch from the event tick but now only the one
you still need to pull the is valid from PlayerStateRed
and return false if its not valid
it won't be every time either
so um - im debugging to see whats going on - added an is valid into that function and both are valid and firing through the branch
but theres something else thats being a problem
inside the function im comparing checkpoints passed versus the max checkpoints target - on the server the max checkpoints target is being set fine - but on the client side that x is returning 0
even though the total checkpoints debugs value is correct and the max laps debug value is correct the multiplication is returning 0 as the value and not setting the max checkpoints target correctly on the client player
Where are you checking the result?
what do you mean by checking the result?
You are saying the Client value is 0
yeah i just debugged went into the blueprint and just hovered my mouse over all the variables
and checked it in debug on the client and server versions - the server versions were all set correctly the client for some reason reading 0
Since you aren't using OnReps, can you just put a PrintString on Tick and print it there
not sure why controller is holding the checkpoints, that seems like player states job
the player state holds the checkpoints passed just the overall max checkpoints in the race that the controller holds
it works when both players are in their own lobbies but when they join the same lobby only the server is being set correctly
Max checkpoints sounds like a GameState property
replaced the max checkpoints target variable and put it in the player state - did this the values set were correct on both print strings but for some reason i got the accessed none on that player state ref
Hey, looking to have my player walk to a location after interacting with the object before triggering an animation.
Tried using "Simple Move To Location/Actor", which does replicate, but is extremely jittery. It also doesn't really have much in the way of output (knowing when it's finished, for example).
Is there a 'best practice' for this sort of thing? Essentially, player mouses over an object (first person), hits "F", and I want them to automatically walk over to the object's 'Destination' transform variable. Interaction/Trigger is all there, I just need help on the approach to getting the player walking to the provided Destination transform
If you're using ACharacter which I'm assuming you are, there's plenty of pathfinding nodes that should be pretty smooth. SimpleMoveTo is pretty crap I think tho, not even sure if it goes through the CMC
I did try the AIMove To nodes, but I'm guessing I need to pass over possession to an AIController for these to work? I can seemingly 'find' paths, but not actually use them, but perhaps this is a knowledge gap I need to look into.
Ahh, yeah, setting up an AIController during movement seems to be the answer. Just have to handle the repossession after it's finished (and stop losing the view target on AIController possession)
If i want to fire a gun in a multiplayer game, do i play the gunfire sound locally and run the actual raycasting and detection on the server (+checking if he is allowed to fire), and also ask the server to multicast the fire sound but exclude the one that fired? or is that not the correct way?
so been trying to fix the issue i had earlier - decided to move the race complete check function and just have it as a custom event in the game state that runs on a timer - but noticed something else thats really weird
the checkpoints passed variable reads the same for both server and client even though they are not and in the array of the players checkpoints thats sorted for the leaderboard its correct?
Has anyone here had success getting sword trail particle effects to work well for clients with low framerate? Running into issues with fast melee animations where the trail looks funky because there arent enough frames to draw it properly
Why would networking handle your particle updates? Networking should play animations, animations should be played client side, particle should likely be attached to the weapon. So the only thing affected by network lag in everything is when the animation starts playing for the current state.
When a player makes a sound that should be heard by everyone, do you just multicast playing the sound effect, or : play it locally , multicast it and ignore the multicast on the player that fired the gun, for less latency?
@kindred widget fair enough, I worded the question poorly I guess, removed the part about lag
Not sure if there are better ways, but UE4's default prototype uses an int variable to handle that. You just set a replicated variable on the server, and make it replicate to all except owner. On replication, play effects for that gun like muzzle flash or sound. Owner can play their same thing locally at the same time of the RPC to update server.
oh okay so they do the low latency way
Is there a way to only to make a replicated variable only replicate to the owning client? So if server changes it, only 1 client gets that info. For example, i dont need other players to know how much ammo i have, so if it gets changed on the server, only i need that info
@granite nest https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/Properties/Conditions/
Detailed information about how to conditionally replicate Actor properties.
Scroll halfway down here.
This is more C++, but blueprint replication conditions should have most of these settings if you're using that.
ty, i forgot about those conditions. im using c++
Hi, everyone. So I got this little problem I recently started messing with multiplayer in unreal and managed to set up a direct IP input game and wanted to ship it to a few of my friends for testing but I have a problem if someone types something else other then an IP the game crashes any thoughts on how to restrict my editable text so it doesnt allow for the console to do "open (something else other then an IP)".
You could make it 4 separate text fields that each accept only a number and later add dots between them
You cant specify that a text field should match a pattern
If you only want 1 input field, you could also validate the string before passing it to the console with a ipv4 parsing function
I found an alternate way while I was messing with the blueprint and I think I found a pretty fool proof solution (might not be the best and maybe it will still crash the game but in my attempts at trying to crash it I failed at doing it.)
i guess it will only crash at "0." for example
nice ๐ฎ
I have an array of integers im replicating and this is quite heavy when initializing using init function on TArray as it calls OnRep n times. So I was looking at this pre-replication condition to change it to off during init. Does anyone know if when enabled it sends all the data? So basically after init to true and then send
for some reason, all of my rpc inside game state are not working anymore, there are like server events and client events, which used to work now they dont ? can some help me understand ?
@granite nest Basically you only network "the gun just fired", not the effects that might make that event up. So on each machine you'd go
"THE GUN JUST FIRED" ->
- Play sound
- Play particle
- Play animation
like this for a reload for example? Basically: the player character calls client reload. client reload calls server reload and plays some sounds/animations locally. Then the server actually changes the ammo and calls a multicast reload for all the other clients to play the sounds/animations
That goes for many things.
"THAT DUDE JUST DIED" ok spew blood, play "ugh" sound, ragdoll
"THE SCORE JUST UPDATED"
ok play sound, update UI, etc
That's the basic gist of multicast events and RepNotifies
You should be networking the minimum state and events of the game so the experience can be constructed correctly on each machine
okay i have a pretty good understanding now i think
So my implementation above should be correct
Yes that's the simplest, if laggy, approach. Once things get really fast paced you start looking at prediction but that's a much more complex topic.
predicting when he is going to fire and then fire ๐
but thanks, now i know that i'm not being silly having 4 functions for each networked action
Prediction in this context would be updating the local ammo count on reload before the server does it, and rectifying things if the server disagrees.
I still can't figure out an optimal way of replicating inventory. I started with fast tarray rep of structs (uint8 itemID, int32 quantity)
This works well, small footprint, but is not flexible at all. For example gun in inventory has some bullets in it, but this info doesn't have anywhere to go in the current struct. Any ideas/pointers how to replicate inventory of items that serialise to different structs?
I currently am working on a inventory system too. I've found that using structs as a base definition of a item the best solution as I can link it against one or multiple datatables. Then I started creating the storage component to make it multiplayer compatible and I quickly found out that I was walking against the same issues as you do. In my struct I had for example a stacksize. But in datatables they are always 1 (stacksize) for me as it should be modular and expandable. So I decided to make a second struct which is what you are doing with the quantity and id basically but ID is for me a whole struct with a FGuid inside. As Im not working with ammo I cant really help with that. But what you could potentially do is if for example a mag is a inventory item itself you can potentially nest that inside. So you would get struct Item (Weapon) -> Slots (Scope, Mag, Stock (Array of Item structs or Map for fast lookup)) -> Magazine Slot (Index of struct) -> new Item Struct (Ammo Type) -> Stacksize 30 (integer) (full mag or something)
so i want my game to check if a server is full and then go to next server and so on, my idea is that i can have many dedicated server running on different ports and game check thru them and join the one who is not full. how to do this? or is this a bad way to go about it?
Do you have a list of those servers?
What if all are full?
This sounds a bit like something that a backend should solve and not the game. But that's not so straightforward
I was actually curious about something similar too. What if I have 2 players and the server has only 1 slot open in the session. They try to join at the same time. What ends up happening?
I imagine they would both join and I just kick the last person to join.
They both join and the second one gets auto kicked
UT solves this with Beacons iirc
Ah interesting.
is there a way to scan for what dedicated server are up running by default in ue4?
8am
Are these user hosted servers or what are your plans
Most of the time if you're not using a online subsystem, you'll need to create your own system for your backend. Or use an existing one like playfab or aws gamelift.
Even a custom one would cost a bit. Cloud servers are stupidly expensive
Ehh
It's a bit inbetween imo
There isn't really a good channel for this kind of convo
Let's see what they answer
i host them , not users
i found a plugin caller multiplayer server browser master server listing, it runs a program that the dedicated server send their info to, and client can the see a list of server and connect to them. I think this will solve it for me.
that...sounds like a waste of money tbh
are you hosting on a specific platform/store?
ie Steam, Epic Games Store
well atm i just host myself, but goal later on is steam or epicstore
I would use the Steam Online Subsystem then
and utilize find sessions
your servers can create a session upon starting up and Find Sessions will show you a list of servers that are up that match the query parameters
@thin stratus wrote a nice guide for general OSS use in #online-subsystems
thanks . sounds great. I will look into it .
Hosting yourself is all fun and games but is a ton of more work once you realize that it doesn't stop with some simple server browser.
Steam takes a cut but also gives a lot in return. Or take the adventure of using eos which hands you this stuff sort of for free
If a character is spawned on the server, visible for each client and the server, and the character spawns an actor locally in begin play. Every client and server will then have this actor. Now if i call a server function inside the actor class on a client, will the server be able to run that? Or does it not know which actor that is on the server
Wanting to re-create something like this but not sure where to start I have already got a dedicated server up and running :https://www.youtube.com/watch?v=wRvVpMk3obM
Testing multiple game instances communication via the Message Bus
Message Bus is something else
no rpc work only for replicated actor spawned from the server, and for client to server rpc the client need ownership
@granite nest That actor spawned by the character has no networking capability. You cannot network anything that is not directly spawned by the server and replicated. The only way to affect that actor, is to route things through the Character and make each machine affect their own copy.
Hmm i need some help with my ammo not replication
i have 2 ammo variables. The MaxAmmo is assigned via blueprint
inside the beginplay of the weapon, the ammo is initialized on the server
both variables are replicated
Lets say the MaxAmmo is 4, then the client says i have 0/4 ammo, while the server says 4/4
So the maxammo is replicated, but the other one is not
init ammo is defined like this
okay i changed the replication condition and now it works so the server is the owner
Yeah, multiple things you should reconsider @granite nest
- MaxAmmo is set via Blueprint, so it doesn't need to replicate.
- You are limiting the InitAmmo call already to Authority, not need for it to be a ServerRPC. This just allows clients to change it, which is bad.
- If COND_OwnerOnly fails to replicate for the Client, then the Client is not the Owner of the Weapon, which you should usually make sure of by setting the Owner param on the SpawnActor Paramaters.
Purely theoretical, is it possible to replicate an actor of the same BP between two different levels?
Or will that probably require a workaround or twenty
A Server can theoretically only have one active Level
Not sure what your plans are yet
Are first person cameras usually replicated? When i want to fire on the server i need the player camera directon, so i guess?
It was a virtual production idea, to have the same single camera move simultaneously through different spaces
Though I guess you can have one main level and each client can load in a diferent sublevel
Yes and no. You can get the BaseAimDirection I think
Lets say i want to increase the maxwalkspeed of a movementcomponent. Should i a) just tick the replicates checkbox and then call the server to change the maxwalkspeed. b) tick the replicates checkbox, call server to change maxwalkspeed + locally instantly change the maxwalk speed (it will cause less delay before sprinting starts, but wont it result in jittering effect because the server will not allow the higher speed before it is received by the server?) or c) dont tick the replicates box and change a custom variable "walkspeed" on the server, which each client will then apply to the movemet comp OnRepNotifyWalkSpeed, or d) again the same as c but also change it locally
my intuition would be to do d because it does not replicate all the variables from the movement component and still (maybe?) leads to the same movement
Since the client has to predict the max walk speed, you should change it on the client and also ask the server to change it.
Ideally though, you would do that in lockstep with the movement simulation.
And of course Server needs to make sure the client isn't cheating by doing so
And that will not result in jittering? (because the client changes it before it is received by the server and the server will not allow the higher speed)
It shouldn't do. The client isn't receiving movement from the server, the client is simulating then tells the Server what it did
And the server either agrees or disagrees. For it to agree, the movement speed has to be the same
Usually the speeds are fixed, and instead you send flags to denote which speed to use, i.e. whether you are sprinting or not etc.
Otherwise you could get RPC ordering issues where the two calls arrive at different times
@granite nest To Correctlyโข implement a multiplayer Sprint function, you have to go into C++
i am using c++
@granite nest I haven't implemented it in my project yet but I'm pretty certain you need to do something along the lines of this.
https://youtu.be/RtQRMcupJs0
Many of you have requested a way to leave me a tip so I've created a PayPal and a Patreon.
PayPal: https://paypal.me/reidschannel?locale.x=en_US Patreon: https://www.patreon.com/reidschannel
Discord: https://discord.gg/PdvudWx
You asked for it so here it is! This is my Networked Character Movement Tutorial complete with a full download to the pr...
Hi, wondering if someone can help? Im doing a first person game where the player has to press E to interact with things which then draws a line trace.. the line trace is ran on the PlayerCharacterBP and is set to Run On Server in a custom event however its only doing it in a straight line and doesn't take into account if the player is looking up or down, does anyone know how to get around this? Its only started doing it since making it replicate, before that it worked where ever the player looked
You will have to show what nodes/variable you use for the trace
Also it only doesn't work for the client, the server can look where ever and it works
Can you try using the BaseAimRotation for the direction instead?
Ive never actually used that node before lol where would in go in place of?
The forward vector
So i would put the BaseAimRotation into the Multiply node instead of the ForwardVector?
Yeah you need to turn the rotation into a vector first
Should also be called getforwardvector on the rotator
Like this?
Although thats making the line trace just go off the left if im looking straight from when i spawn and if i turn it still goes to the same place regardless of where im facing
oh wait.. i never plugged it into end lol
Yeah thats working now thanks mate!
Hey could you elaborate on how i would implement teams with a info actor?
please?
hello all
Maybe someone can help me:
I have a simple spectatormode with set view target with blend.
I used Paw Control Rotation for my Camera Spring arm (camera is not relevant for multiplayer in my case). My problem now is that the spectator has input controls disabled. Is there a simple way that the spectator can move the camera also localy?
if i understand correctly, viewtarget is only the image and possess the overwriting of the controller?
Has anyone had problems with a Reinstall breaking Session joining?
No.
Keeps freezing server on my pc and kicking client after timeout
My partner has tried the project and it works fine
has to do with the editor somehow
have reinstalled several times now, if anyone has had a similar problem and knows a fix, Id appreciate it
Don't try to test sessions in editor
its standalone
If standalone don't work that's pretty borked
yeah tell me about it
What's the crash log?
I can.
You can try the packaged version?
Something about a function thats clearly working and a reference that its clearly getting.
I will try the packaged version
as I said, partner has gotten zip today and it works fine, no errors
You doing anything weird like hot reload?
Try nuking the disposable folders like intermediate and saved
It's weird that it would behave differently on different computers
Seriously
prob
something weird nobody understands
are you working on a bugged engine version?
4.26
unreal is a buggy mess not going to lie
sometimes it can be for sure
epic should really fix alot of those bugs
It's not really that easy most times.
Change one thing, and suddenly half an industry can't update to the newest engine version. People hate you. Don't change things, let people solve them themselves, people hate you. Better just to leave it alone.
btw does epic own unreal engine? or did epic make unreal engine?
bruh, there's no way it'd work on someone else's pc
it 1000% does
I'm actually surprised it does
Delete the unnecessary folders and hash both project folders lol
are you using a vpn by the way? or are your firewall settings broken/
nope
ok that's suuuupperr weird
yup
You need to start by confirming that you 1000% both have identical projects
Also a quick question for anybody: is listen servers safe? will my ip get leaked or something like that?
i hope not
dude. I zipped it, he opened it, it worked. Theres not much more I can say
Did you delete intermediate and saved?
Anything you can do in form of debugging?
after
Depends on your session subsystem but probably safe enough.
You reinstalled the engine version?
What are you testing, standalone?
Id rather not rely on packaging every time I want to test it, tbh
@analog plinth On both boxes, open the uproject file in text editor and check that they're exactly the same
Welll
You kinda have to cause PIE/Standalone is different from Packaged
But of course only every day once or so
im just using the basic create sessions and join session nodes from unreal, will it be safe?
Standalone ran the game fully replicating before reinstall
have you verified the instalation?
If you aren't using steam or another backend you'll be lan only with sessions
What about advanced sessions?
advanced sessions is what you want
that isn't lan
That has nothing to do with lan or not
it doesn't have to be
no
AdvancedSessions exposes more C++ code
yes
You still need a Subsystem that can do online sessions
like?
eos or steam subsystem
look it up in plugins
Or Platform depending
^
Is there a tutorial on how you can implement steam subsystem
several
Probably
if there is please send a link
Google is your friend
okay
Also Sessio nrelated stuff is for #online-subsystems actually
@analog plinth Did you reinstall the Engine and left your project on your PC?
yes
have you cleared the binaries, intermediate, saved folders?
have
What does the crashlog say
something that doesnt ring true
Have a copy paste/Image?
its about a reference coming back null. which isnt possible. because it has the reference
Im reinstalling engine, dont have log in front of me
Did you attach VS when it crashes?
Would probably help
And make sure to use DebugGameEditor and not DevEditor
In case it still persist after the reinstall
Sounds like a race condition to me. The reference might come back null initially but then later be set
Uhm, say i have an Enemy class which has an variable marked as ReplicatedUsing.
The OnRep will not be called if the instance is already destroyed, or ?
Alright, also wondering if it would or would not get called if the Enemy instances is marked as PendingKill
You usually want to add some extra time before destroying
You "deactivate" the actor, hide it, turn off collision, and destroy it 5 sec later
can make it go invisible
Or you can have a look at "TearOff"
then destroy it
But that needs some c++
Luckly i'm writing most things in C++ ๐
Yeah then have a look at TearOff
Should call TornOff on the Client
Will cut off replication and allow the client to handle life time afterwards
@vague fractal
Alrighty
i have this animation sequence that plays on another player's weapon when he fires. Everything works except for the sound cue, which is not being played. Is there a reason for that?
Also are those always played in 2D? because then it would already not make sense to play it like that when another player fires
Oh i can specify a bone name lemme try that
nope still not doing anything
The player that shoots sees the animation, the particle effect and the sound
but other people only see the animation and particle effect
also changing the sound for a different cue or montage is not working
@granite nest show the event that is triggering the sound
This is called when someone fires
from the multicast reload that the server sends
PlayAnimation plays the reload animation
which includes the play sound notify
as shown in my first screenshot
Maybe i should change the play sound notify to a custom notify that calls a multicast which plays the sound.
but then it gets complicated
@granite nest are particles triggered by a notify?
yes they work
So the problem is in the notify. Is the parameter for what sound to play replicating fine?
The sound to play is just set inside the animation sequence
if that is what you mean
im not really telling to play a specific sound, just to play a specific animation
Do you hear the sound when previewing the animation?
Do you hear it when just placing the animation looped into the scene?
You can also try to make your own AnimNotifyBp
And play the sound in there
To try and see if that works
a) yes, it is also heard by the player shooting, just not by others. b) yes then it works perfectly !
i'll try this
lol i added a play fire sound notify event
implemented it
and it does not even get fired (not printing hello nor playing sound)
I am using advanced sessions plugin and whenever a client joins a listen server, it can't move or do any actions that require input. The pawn is just standing there playing the idle animation. Anybody know why this could be??
Im getting this crash when trying to join a session anyone know why
Try it standalone
I've had an issue with components on an actor. I expected the child scene components to move when I update their relative location on the server and that would be visible on the client, however that doesn't happen.
I can solve this by manually updating on tick or something like that but I'd rather make sure this expected behavior. The components are set to replicate.
Nvm it's not actually running on the server and it's an issue of my own replication of server client
So okay, then here's my confusion. I call the function on the server to adjust the position of the users weapon depending on their controller type/settings. This gives them better offset for aiming.
Now the server calls an event set to run on owning client, that checks what settings the client has, then calls a run on server event. The run on server event gets dropped....since i see the event triggered on the owning client, print statement shows it hit, however the run on server event it calls gets dropped
I'm guessing ownership isn't inherited? Pawn owns the gun, controller own the pawn, controller does not inherit ownership of the gun?
I set the weapons owner from the pawn to the pawns owner, everything works, but I don't feel that's right.
a quick question, How does an event dispatcher works when it's replication set to RepNotify?
I understand RepNotify trigger on variable changes, but in event dispatcher i'm not changing anything, i'm calling an event
Uh
I wouldn't expect a dispatcher to replicate at all
Maybe BP will call the event if you bind/unbind from it, though, and that'd be sorta neat
i see... yeah, but I can't make it work, just thought maybe i didn't understand it well.
and it only calling it on server not clients
BP notifies are a little different - they'll fire when the value changes regardless of where it is but then also when a new value replicates over the network
Effectively calling your OnRep on the server
and on client if it sets the value locally ๐
i see... I'm trying it on Game State, I believe everyone have GameState on their side, so i'm not sure what i'm missing
way to "replicate" an event dispatcher call
is basically, put a byte variable with RepNotify
from OnRep, call the dispatcher
and just increment it on server when you want it called
it doesn't matter what the value in it is, just that it changed
oh... so it should have a variable in order to trigger, ok, let me try that
yeah, it works, I set event dispatch replication to none and rely on variable RepNotify
which means setting event dispatcher to RepNotify doesn't make sense, is there any purpose for event dispatcher to have replication?
nah just a fluke and it doesn't seem to do much of anything
yeah, thanks guys for the help ๐๐ฝ
hello.How can i get quantity players in blurprint?
GameState->PlayerArray->Length
So, I assume if a Client locally changes a repolicated Array and the Array doesn't further change on the Server, the Client would keep their local change, right?
yeah for sure
If you have multiple client windows open, and shoot in one window, do you guys hear the shooting also in the other client's windows? or do you only hear the sound from windows that you are focused on
Ay ppls how do you use DOREPLIFETIME_CONDITION with a custom condition? I'm tryina set my property to only rep if another variable is set to a certain value OnRep like so but I can't figure out how you're supposed to use SetCustomIsActive and there's not a whole lot of usage in the engine to look at:
void ACItemBase::OnRep_ItemState()
{
if(ItemState == ItemStates::Carried)
{
SetCustomIsActiveOverride(Bla bla bla);
}
}
@vivid prawn That's just an oversight on Epic's part. They likely just don't check in the UI what the Property is. Dispatchers are a property just like a boolean or integer and can be marked Replicated, etc. But Dispatchers don't have anything to do with networking. They won't actually do anything outside of the local machine.
@fossil veldtNot sure I understand? If you want the client itself to override onreps, just take in the old value, and if the other property == something, set the value back locally. Otherwise you usually mark it as a replication condition on the server.
Nono, I want to set a separate variable to rep or not based on the value of ItemState
yeah, Thanks for clarifying that ๐๐ฝ
@fossil veldt Can't you just specify that in the DOREPLIFETIME_ACTIVE_OVERRIDE ?
DOREPLIFETIME_ACTIVE_OVERRIDE(AMyClass, ReplicatedVar, ReplicatedVar = EMyReplicatedVarType::ValueName);
Er. No, that won't work. Sec.
I think that is what I gotta do:
void ACItemBase::OnRep_ItemState()
{
DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(ACItemBase, CarryingPlayer, ItemState == ItemStates::Carried);
}
Wouldn't you want to call that on the server though?
yeah, i'l probs do a switch on authority
1>C:\UE\Projects\Hydroneer\Source\Hydroneer\Core\Items\CItemBase.cpp(77): error C2065: 'ChangedPropertyTracker': undeclared identifier Getting this but I think i'm probs missing an include
DOREPLIFETIME_ACTIVE_OVERRIDE Damn. And it thought there is only
DOREPLIFETIME and DOREPLIFETIME_CONDITION :blobsweat:
ah I seeeeeeee
Is it possible to grab the property tracker from somewhere?
It's available in void ACItemBase::PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker)
yeah wait I don't even need to do this OnRep, I can just do it on PreRep anyway
Hey guys is there a tutorial or something that can help me how you can send data to a session from lets say a main menu? ( what I mean is that I want to require players to set a username in the main menu before joining a server and when the player joins a server it will have that username variable with his name in game)
hey! I'm using the default VOIP system in Unreal and for some reasons when I server travel using seamless travel the engine just crashes, I checked the crash report and it seems it fails when FScene is being destoyed or the Audio Thread crashes. Is there a way to fix it ?
@red salmon beacons would help solve that. But that's more of a #online-subsystems question
Is it true that you need to make a custom character movement component for multiplayer?
well the default one works in multiplayer but it might not be suited for you
Depends on what you're trying to do.
Lets say you just want your sprint to work correctly
Then yes you'll have to do some c++
this guy in this video: https://www.youtube.com/watch?v=RtQRMcupJs0&t=404s, says that you really need a custom movement component
Many of you have requested a way to leave me a tip so I've created a PayPal and a Patreon.
PayPal: https://paypal.me/reidschannel?locale.x=en_US Patreon: https://www.patreon.com/reidschannel
Discord: https://discord.gg/PdvudWx
You asked for it so here it is! This is my Networked Character Movement Tutorial complete with a full download to the pr...
why use a custom one for something as simple as sprint ?
you just need to change your movement speed on server and inform the clients so interpolation/extrapolation don't do strange teleport things
he shows that this is the bad way to do it, which causes bugs when your ping is a bit higher than zero
which just sets the movement speed locally and tells the server to change it
I never got any issues with the character movement component ๐คทโโ๏ธ
but yeah this code is not safe
Can you quickly explain why not?
because the client is sending the speed it wants to the server, you can change it in Cheat Engine or other cheating programs and hack your speed
a better way would simply tell the server to start sprinting and you manage the speed server-side
But you would also change the speed locally for less lag right
yeah
you can use RepNotifies or Multicasts to inform the clients that the speed of a player has changed so they can update theirs locally
But lets say you have 500 ping. You start sprinting, the server does not know you started to sprint for 500 ms and you will teleport all over the place because the server does not agree
if you change directly your local speed yes, but if you only do it once the server processed your message and sended a message to every client it will not (but you will still have some sync issues with that much ping tho, like extreme input lags)
uhu, So apparantly, the guy in the video added some things to a custom character movement component and then you will not have the bugs from my previous message
i'll rewatch it to fully understand
The main reason why you should implement Sprinting into the CMC directly is because otherwise you get corrections at start/end of your Sprint
Which feels shite for players with higher pings
But i dont understand why you dont get that correction if you implement it into the CMC
Also the suggestion to use an OnRep OR a Multicast is bad.
Multicast is pretty wrong here
The CMC works like this:
The Client tells the Server that it wants to move. It sends a Timestamp with that request, as well as some additional info, like it's movement inputs, if it wants to jump, crouch, etc.
It also sends the Server the final Location after the Move.
The Server will then perform the same movement. If the location is different it will correct the Client.
If you change the WalkSpeed of the CMC on the Client and then via ServerRPC also on the Server, then there are a few frames where the Client moves with the new WalkSpeed, tells the Server what location it reached and the Server, not having the WalkSpeed variable changed yet, will perform the move and end up on a different location, resulting in a correction for the Client
Because the ServerRPC for the WalkSpeed change will not happen at the same time as the ServerMove RPC.
And that goes for all sorts of Input Driven movement
E.g. Rolling, Dashing, and what not
And on top of that comes the moves that the Client actually saves. When the Server corrects the client, the Client might already be a lot further with its actual movement. The Client keeps track of its last few moves, discards verything older than the correction and then replays the ones that are newer, so you aren't literally teleported back.
And these also need to know that you were infact sprinting, so that also has to be setup correctly.
Networked Movement is not easy, and while it looks working on 0 ping or low ping situations, if you have a higher standard multiplayer game with fast movement etc, then you have to use the CMC.
Why is it that I cant just spawn instanced foliage meshes on the server and they not show up for clients like a regular actor..tf
So you are saying there is a delay when you change the movement speed directly and send that info to the server to change the speed, but isn't there the same delay when you tell the CMC that you want to move?
wait i think i understand
Yes there is the same delay, but the Server performs the correction based on that RPC's result.
If you perform a second RPC that the Server doesn't know about, then things start breaking.
ooo so its purely because the speed update and movement location update are not sent in the same network packet
Yes, or rather in the same RPC
In your own CMC you can basically pass over additional flags
One being "IWantToSprint"
And then the server will perform sprinting the same way the clietn will and they stay in sync
yes thanks a lot for this information i really needed this
everytime i think i understand networking, there is so much more to it
Hi, ive got a problem which im hoping someone can help with.. at the moment i have 1 PlayerCharacterBP, eventually im gonna have to have a few of them to have 5 or so players in the game, when i incorporate those BP's ive got a feature where you have to find keys to unlock certain doors, at the moment i have a 'HasKey' bool on the PlayerCharacterBP, now for the Key's BP i do a check once interacted with to see if the player has the key or not, if so display a HUD, if not pickup the key however the way im doing it is via a Character Ref in begin play which at the moment is the same BP for every character in the game.. Whats the best way to do this kind of check when there is multiple characters? this will also lead on to my next issue with HUDs lol
Anyone have any suggestions on replicating skeletal mesh movement? I have the location replicating perfectly, however the limbs of the character are not correct.
What I want:
What I get:
Are these simulating physics?
Yes, but no gravity
Well, doesn't matter if gravity or not
They use Physics to determine their location and that's not easy to sync
You can try only simulating on the server an replicating a struct or so with bone locations to then update the bones on the clients
+- some inter and extrapolation
I see, do you know of any good documentation or videos for that?
Sorry, I am brand new to UE4
Pass the Character that is interacting via your Interact function.
Not really. :P haven't really met anyone in the last 6 years that tried to sync that stuff
This is usually visible fluff that you don't sync
I figured as much, necessary for my application unfortunately. Thanks for the help.
Ahhh of course! would that just be an object reference of the BP Player Character?
Yop
@thin stratus Last question, do you think what I am trying to do work without simulating physics? When I disable physics before it seems like it disables the whole skeletal mesh and is set to the reference pose.
Nice one and then if i make the PlayerCharcterBP i have now the parent and make child copies of it for each player that should still work right?
That's what inheritance is for, yes
Thanks mate!
No, the SkeletalMesh is only using it's PhysicsAsset if you simulate Physics iirc
Gotcha, thanks
So same kinda thing, when the player picks up a key they can pick it up by interacting with it or if its been dropped (by a player dying for example) then ive made it so you can pick it up by walking over it, atm ive got it so again it checks the OtherActor and casts to the PlayerCharacterBP, is there a way around this as well so it makes sure its that specific player?
One thing you should keep in mind is that the Overlap happens on everyone.
You might want to limit actually aquiring the key to Server only and make the boolean for having the key and OnRep to drive visuals and general state
You don't need to RPC there, neither can you usually
Hey ya'll so I have a multiplayer game that uses the advanced sessions plugin. However, for some reason, when two players try to play from different machines, the session the host creates cannot be found(Even if they're on different or the same network). The session can only be found if the host starts up another instance of the game on their machine. What could be some causes for this?
Hello
How can I set a player name so it will persist ?
I am using PlayerController::SetName(const FString& S)
but it gets reset every map change...
Is it possible to replicate respawn timers? If I just call an RPC, I have a latency on the client.
@foggy rainYou'll have an easier time just replicating a single time value to the client. Player dies, respawn timer is set on server as ServerTime + 10.0f seconds as a float. It replicates to client. Client can use that by getting the replicated server time and doing RespawnTime-ServerTime=WhatToDisplay.
Thank you! Will just send server time as a second value in PRC to the client!
Servertime is already replicated. You just need to replicate or rpc the respawn time.
GetGameState -> GetServerWorldTimeInSeconds will get you the server time for any machine.
I meant the exact server time when it was calling the RPC.
GetGameState()->GetServerWorldTimeInSeconds() will return the current time, not the last time from RPC, right?
The time the RPC went through shouldn't matter. The only thing the client needs to know is the server time that the server intends to respawn at. The time at which the RPC was sent won't help anything.
Probably I don't get it...
I need to call an RPC to start the respawn timer on the client. I thought you were suggesting to just send the respawn time and the current server time (at the time of the call) and then start the same timer on the client with RespawnTime-ServerCallTime.
Or do you suggest to replicate the senconds left?
GameState has a value that is constantly ticked. 1.0f value per second of game time. That's ServerTime. If you kill a character, and then set RespawnTime as CurrentServerTime + TimeItTakestoRespawn. Then RespawnTime is all the client needs to display the timer.
Player dies at 537.53f ServerTime.
TimeItTakesToRespawn = 10.0f
Server sets RespawnTime for that player at 537.53+10.0 = 547.53. It RPCs or replicates this, either way works. Replication is probably better.
Client gets this value maybe a tenth of a second later after the replication. Client knows that it'll respawn at 547.53-Servertime. Now you get the time to display by doing RepawnTime-Servertime. So the client received the 547.53 value 4 seconds ago. It ticks, does it's 547.53-Servertime. Since that was four seconds ago, client will display approximately 547.53- 541.63 = 5.9 seconds to respawn.
Wow, now I get it! Thank you a lot!
I have another question. AGameStateBase contains a function called GetPlayerRespawnDelay. Should I override it to display respawn time? Is it returns seconds left or the whole respawn time?
I just thought that the respawn time is better to locate in PlayerState.
@foggy rain That looks like a call used to get the value that can be set to set a minimum respawn time. It won't work for anything but server code though. It's located on the GameMode. Any other call to that looks like it will just return 1.0, like on Clients.
Personally, I'd agree with you on the PlayerState. I'd want other players to see a player's respawn time and such and since it's associated with a player, it'd be best to put it there.
Here's the scenario:
On Client 1:
- Player touches coin
- Player's PlayerState.CoinCount +1 in PlayerController, "Executes On Server" event
- Update Client UI coin amount text box
On the Server side, that PlayerState.CoinCount is 1. Then the updated PlayerState will be replicated back to Client 1.
However, I am seeing that there is a replication delay between steps 2 and 3. The UI will actually update first before the PlayerState replication happens.
On the Client, UI shows "Coins: 0" when it should actually be "Coins: 1" after replication.
Using print statements, I can confirm the PlayerState will eventually get replicated over. But since the update Client UI is called already (step 3), the UI is outdated and the code does not know to update the UI again.
Is there a solution to this? Am I thinking this right?
Honestly. Prediction is a downright nightmare with UI. It starts out all nice and simple, but in reality, as a developer, you're really better off just taking the network delay on clients and always displaying the real value replicated from Server.
I'm okay with clients getting delays on UI updates because of replications
But the UI is incorrect because the replication is slow, because I call the UI update event after sending the PlayerState update (Execute On Server)
Was wondering if that's a good practice to do
You shouldn't rely on RPCs much with UI either unless the RPC is just meant to display something once, like a server wide message or something. OnRep functions with bindings, or ticks/timers will be your friend for keeping UI correct.
Here's an example:
On Client:
Picking up a Coin (in BP_Coin) will call the UpdateCrystalCount (in PlayerController)
Then it will update the PlayerState on the Server (which will eventually replicate it back to the Client), and update the HUD
Problem is PlayerState.CoinCount is still 0 for the Client when HUD is updated because PlayerState hasn't been replicated from the Server back to the Client yet
And after Client Update HUD is called, it won't be called again
So the UI is outdated when the replication from the Server back to the Client finally happens
Your value is on the playerstate?
Yeah, I wanted to keep all player values in PlayerState, I think it makes sense
Unless it isn't?
Create a delegate in the PlayerState like OnCoinCountUpdated. When UI or HUD is instantiated, get the local player's playerstate and bind an event to that delegate, the OnCoinCountUpdated. In the Playerstate, make that value Rep with Notify. In the OnRep function, call the delegate OnCoinCountUpdated. Now the UI knows to run that event after the value has been replicated to the playerstate.
Now your only networking related to updating that value on clients should be the server replicating the value.
Hm, I'll have to analyze what you just said some more but I think I kind of understand
Let me try it out
Thanks
Thanks for the info!
It's weird that this function is located in AGameStateBase and not managed by game mode
what function is called when a pawn is possessed by a client? It's an APawn, not a ACharacter
any tips on what sort of character polycount to aim for with multiplayer games in mind? maximum 8-10 players at a time, arenaโish, 12-15 ai also present per map. thanks.
That question is too situation specific, there is no general answer.
When replicating a component, do both the component and the owning actor need to override GetLifetimeReplicatedProps, or just the component itself?
Anything from one polygon to 50,000 should do it
Depends on the spec you're targeting, but polygons are cheap. Don't overdo it with 5 million poly models but anything sane will be fine
Thanks. I managed to get mine down from 1mil to 106kโฆ. just wondering if i should bother trying to go lower by baking etc..
100K ain't horrific for a hero character, but you will want to LOD that pretty hard. If the camera is at any distance from the character, each pixel is covering like 100 polygons, kind of a waste
yeh i have so far only reduced using lod in cc3..
It's also not really a multiplayer issue. Your networking won't care how many polygons your meshes have.
multiplayer is not only networking but feel free to defend your point whilst i go off and do something useful.
Only really true if you're planning on a local coop game.
Just the Component. However the Owning Actor must be set to Replicate.
Assuming you meant that your attempting to create a Property on the Component that is Replicated.
I'm trying to replicate the instance of the component
Which I believe is not what you're saying
Ok well in that case why would the Component itself need to implement GetLifetimeReplicatedProps? That is the function that allows the Replication of Properties on the object itself.
So with that in mind.
On the Owning Actor, you need to mark the Property thats holding the Component as Replicated and then add an entry to the Owning Actors GetLifetimeReplicatedProps function to cause it to be considered for Replication.
Oh so I misread the component replication page
But now that you say it that way it makes sense
A Component is a UObject, it gets replicated like any other property.
when the player connects to the server, there's a brief moment the player has no pawn, is there a way to control what location/rotation/view-target the player sees at this moment when it has no pawn?
The PlayerController is the default ViewTarget (when no Pawn exists and/or there is no other Actor with view focus). Just move the PlayerControllers position.
hey was wondering if anyone could help - i was wondering how i can stop the movement of each player after they have completed the race - i already have the full set up for completing the race just not disabling their movement after the game is done
i still want them to be able to press buttons so they can use the menus etc but i want their movement to be stopped until the rest of the players finish the race and then stopping the movement of any players who have finished
there is no enable movement function however so how would i re enable the movement?
SetMovementMode
DisabledMovement just calls this with a MOVE_None input
So you can call it yourself to set movement to MOVE_Walking or something
getting accessed none with this - im doing this blueprint in the gamestate as thats where the race completion stuff is all being done
Well the owner of a game state is never going to be your character
So the cast will never actually give you a valid value
You say this is at the end of a race? Wouldn't it be that you have a list of participating players?
the owner is probably the player controllaer
what you maybe want is getcontrolled pawn or sth
no, the owner of the game state will never be the player controller either
Anyone know how to get the corresponding PlayerController in PlayerState?
Get Instigator Controller is null, I have to input an Actor
GetOwner
Oh, that's strange
In PlayerState:
Get Owner takes in Actor and returns Actor
But the returned Actor (self) is actually a PlayerController, not an Actor
But I guess PlayerController is an Actor
So the owner of PlayerState is PlayerController, good to know
Looks like it works, thanks
Welcome to Inheritance :P
The Type that is returned by a function doesn't mean the thing that the Pointer is Pointing to is of that Type. It can also be a ChildClass
That's what casting is for :P
Thx @thin stratus
hi all.I am new to ue4. i am trying an mutiplayer game where users can push each other. the player is applied a knock back using LaunchCharacter node on componentHit.
on listen server the collision looks perfectly fine with with 300 ms ping,but when the game is run using Hamachi vpn and there is a jitter on knock back. i am not sure why this is happening.
any help would be appreciated
the following is the approach
- create a custom event set to run on server which is calling launchCharacter, and run it locally
It'll be near-impossible to make it smooth. Only the Server should detect the hit events and call launch character. Ideally the locally controlled character would "predict" the launch too, but it can't really do that when the source is other players
Characters interacting with each other in multiplayer is always going to have jitter/collision issues
Is there a way to replicate an actor only to a certain player, that isn't the owner? For example a Character that is possessed by an AI, but only a certain player should see it
When i spawned the character I set the owner to the player and tried "OnlyRelevantToOwner", however as the AI possesses it the owner is changed to the AIController
You can override AActor::IsNetRelevantFor so long as you're not using replication graph
Thanks, I'll do that :)
Can someone refresh my memory a bit: If I want to determine if a Character is the ListenServer's or some other client's via Roles, what Role setup do I expect?
I assume being on the Server side would be LocalRole == ROLE_Authority.
And for the owning Client, locally it would be LocalRole == ROLE_AutonomousProxy.
And for other Clients, locally it would be LocalRole == ROLE_SimulatedProxy.
Now if I'm on the Server side, so LocalRole == ROLE_Authority, how do I diff between my own Character and someone elses?
The RemoteRole must either be ROLE_SimulatedProxy or ROLE_AutonomousProxy.
I assume the it will always be LocalRole == ROLE_Authority and RemoteRole == ROLE_AutonomousProxy, or?
IsLocallyControlled() :D?
Unless you have to use roles ๐
Yeah I guess it would be ROLE_Authority on Server... and RemoteRole == None?
None :O
Yeah right, at least I'm not alone with those roles
Ah well, will just try with LocallyControlled then
Wanted to be as fancy as the CMC
I think on Server a remote player is local == authority and remote == autonomous
Blรคh, still doesn't do what I want it to do.
I just need the Current Timestamp in my CMC.
I think Remote for the Servers' own pawn though.. not sure
And I have Server and Client prediction data. Just can't figure out the one i need to use per character
Client apparently is also for ListenServers, locally at least.
I don't think Server has any prediction data for it's locally controlled char does it?
Hm idk. I could just use the World TimeSeconds I guess
Just for the Client I would need it to be in sync, which I think it is
Thanks for the reply. is there any work around for this issue
The best you can probably do is have only the server respond to hit events and launch the character
Integrating it with Client-Prediction is somewhat impossible to achieve here because other players will be lagging behind too much for it to be in sync anyway.
So somehow my "OnlyRelevantToOwner" actor does not get replicated to the owner at all. The owner is not the controller, but the controlled pawn of the player btw. Maybe that's the issue?
Not sure how that exactly works, but maybe it's only checked once if it should send the package to spawn the actor on the client and at that point your Character/Pawn is not possessed yet?
I would try passing the Controller or making sure the Actor gets spawned when the Character is possessed
About prediction: Lets say i want to reload and i already change the ammo counter (replicated integer) locally , and then i send a server request to reload. The server checks if(allowed to reload) and sees that the player is not allowed to. The local counter should be restored to the server version, but the local variable does not get updated bc replicated variables are only updated if they change on the server and the server one does not change in this case. Should i do this with a Client RPC? i know it'll work but maybe there is a more logical/simpler/built in way
Normally i would add a local check to see if the user is allowed to reload, then restore the ammo counter and then call the server reload. So the prediction would only be incorrect if the user bypasses the Allowed to reload check, which leads to the player not seeing the correct counter and nothing else
So maybe i should just not care
Thanks, think im gonna have to do a way more research into the online stuff as im quite new to it and have no idea what some of this stuff is lol
So this is weird. I have this in my BP_Checkpoint:
Top image: Player Array has two elements but the output for both of them are empty for the print statements
Bottom image: But by just adding a Player Array Temp and using that, it somehow works just fine as expected
I wonder why is that?
Can a cheater change your code/variable values?
Then cant he just remove the 'is authority' check and execute code that should only run on the server
@granite nest sure he could, but it wouldn't matter. If it didn't happen on the server, it didn't officially happen.
So i have noticed in multiplayer shooters, when i have 300 ping i can instantly aim and my fov will instantly change, so it is only done on the client. So as a cheater, i could make it that all my weapons zoom in x10 and noone would ever notice right
Probably
And i could also zoom in while jumping because i could remove that check to see if aiming is allowed
Sure
The thing with the Authority is that uuuusuuaaly, if you use C++, you can mark the code to be stripped from the Client package
Not a thing in BPs though I think
Ait
i guess game developers have to make a trade off between security and performance
More a trade off between security and how deep in your player's rear your are going
PC security is not a thing, you just need your kernel level anticheat to be good at finding out
straight, how do i call a variable from the server from the client?
You don't, but I'm not sure I follow. what are you trying to do?
Need more context
trying to call an array containing all P Controllers that have joined the session, I need those for the Playerlist TAB to be updated etc, tried using All actors of class but not seem to work
You already have that info. Look at the player array on game state. By the way you won't have the player controllers there, only the server has all player controllers. Clients only have their own
Player controller is not replicated. Use player state
that also includes having a variable that holds all the Controllers?
Such a variable can never replicate correctly
It should be an array of player states instead
Which already exist in game state
okay thanks
Hey uhm, i'm currently trying to use the Network Profiler.
But it seems like the GUI is kinda bugged in my case.
Like i can't even see what's above Details (PER SECOND)
Also doesn't seem like i can scroll up or similar
Idiotic question, but I'm not finding an answer. I have turn-based game module which I want to convert to multiplayer. If I use steam subsystem, does Steam provide a server to run my game, or that's on me and I have to manage the server myself?
It's nearly always on you
Steam does not provide hosting your Server
@rugged token
If you can't afford the huge server costs that come with trying to host Dedicated Servers for a community (which might never exist if your game doesn't go off), you might just fall back to ListenServers (cheating can't be prevented) and stop caring.
@thin stratusthanks, clear as day - this just ended my endeavor with making multiplayer. I just can't handle all of that by myself w/o any programming/network experience.
Well, UE4 gives you the Server
Wasn't there like a free option with AWS or so ? (Idk how it was called)
But you will have to host it somewhere
By far not free enough to use it.
tbh if you're making a game that needs dedicated servers you better hope you've already got a community to play it.
Just make s m o l games that don't need em
Ah we are all repeating ourselves every 2 weeks.
๐
Can we just make a website?
Ok, hosting a server is way beyond my ability. I don't even really know what a server is. So i'll just stick to single player and make another game that doesn't beg for multiplayer ๐
Allar, are you here for some Website thingy that tells people to stop making non-playerhosted Dedicated Server based games?
Sticking with Singleplayer saves you 10 years of your life, just by not having to learn it
MP is overrated ๐
So yeah, good call
Take it from someone who is looking at replicated movement for the past 4 hours, trying to figure out why the replaying of moves on client side just DOESN'T WANT TO DO WHAT I WANT TO
@twin juniperI have no knowledge of neworking, so aside from converting my single-player game to multiplayer, which might prove quite the trip on its own, I need to also dig into how networking and setting up a server works. Aaaanyway, i'll better make another singleplayer game from scratch, at least that's something I can definitely do w/o problems ๐
then, i'm not ๐ not alone anyway
I'm running into this "Failed to open descriptor file"when the game launches on the phone. I've searched through the comments here and I see many people have this issue but only one seems to have mentioned any fix - but it's ambiguous. They ( @dry tulip ) said "i might have figured out a work around, using the absolute path to the uproject file seems to be working". I haven't figured out what is causing this issue but this seems to indicate it's a path issue. Where is this path stored or changed at?
I'm not a programmer, I learned UE+blueprints in the last 3 years, I'm decent at it, learning mp now is something I can't afford.
so, i either find someone to work with, or drop it, stick to what I know I can do - u know...
anyway, thanks for the info everyone! ๐
I have now overridden IsNetRelevantFor(), but my actor still does not get replicated to the owner or the actor I check for in IsNetReleventFor. It also returns true for the controller I need it to replicate for
When I try to launch a client from a packaged build it launches as Standalone instead of Client. What is causing this? I don't even know which other context I should provide you guys with.
Here's the command line arguments I'm using: MyGameClientPackage.exe /Game/MyGame/MapsFolder/Map -ServerIP 127.0.0.1 -ServerPort 7777 -game -log -ResX=1280 -ResY=720 -WINDOWED
Still not replicating... oof
Does it make sense to mark a property as Replicated and ReplicatedUsing ?
Or is it enough to only use the ReplictedUsing if you are in need of a call back method ?
using alone is fine
Might should ask it a bit differently, does ReplicatedUsing also imply that it's Replicated
yes ๐
Alrighty
For a first person game, how do you guys implement the 2 different character models (one that the player sees and one that others see) ? my idea is just to add 2 skeletalmesh components to the fps template and set one to owner only see, and the other to owner no see, and then apply animations etc to the active one. Is this good or bad? I'm wondering if things wont look weird because in the fps character, the mesh is attached to the camera
Just using "True first person" is an option, but the problem with that way is that your animations have to be made for true first person which is why i gave up on first person ๐ฆ
that's a fairly standard approach. Games like DayZ use only 1 mesh, but they make the head vanish and the camera is from the head's viewpoint. It's why you can look down and see your legs and such.
Any chance that someone has a better source for learning the Network Profiler that this here ?
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/NetworkProfiler/
Is there someone with a good understanding of server / client movement? I'm having some problems with my character where the default movement is working just fine (charactermovement), but rotating a static mesh (a turret in this case) of that character is jittery on the client while it's smooth on the listen server. A force net update helps a bit, but it's still a bit jittery for the client. Does anybody know how to correctly implement this?
How do you save PlayerController when traveling to another map? e.g. a player select a character in the lobby and i want to spawn that character when map is loaded for that specific character.
currently what i'm doing is, taking the Unique Net ID and save it in GameInstance and upon loading new map in the new GameMode OnPostLogin I compare the Controller Unique Net ID with the one I saved in the GameInstance.
it's working fine, I'm just curious if there is some built in feature or better way of doing it.
how can i setMovementMode for other clients. i set it as usual but it only works for localplayer ๐ฆ
personnaly I use Unreal Insights (it can do cpu profiling as well as network) which IMO is more readable that the old profiler
Oh, didn't knew Unreal Insights is useable for network related stuff.
But it's also marked as experimental feature :S
yeah it's sill experimental :/ but I found it sooo more readable that I didn't bother learning the old one x)
Yeah, the old one also looks really old xD
yup xD
maybe someone here have used both and can tell you if one is better than the other
It says it shouldn't be shipped, but i guess Unreal Insights should anyways not be a part of the shipped build, or ?
yup ๐ค
@chrome bay sorry for tagging you directly but I was reading your blog post on burst counters again. in my situation i am using multicasts (need to pass parameters with each event rather than just the shot number, and not firing fast enough to cause issues hopefully!). do you think this will still have that "staccato" effect you talked about where things will come in bursts rather than at intervals, or is that just a quirk of variable replication that multicasting wont encounter?
Hey guys so this problem has been bugging me for a day now but essentially I am having a problem with session making. Using UE4's advanced session plugin, I am able to host and join a game fine from the same computer(by starting different instances of the game on the same computer), but when I try to host a game and try to join it from 2 different machines, the session cannot be found. Do you guys think its because I am using the wrong plugin version? I am using 4.25.4 and the closest one available is 4.25.3.
I tried moving all my matchmaking blueprint code onto a new project and I still get this same error
FindSessionsAdvanced essentially returns 0 servers
Potentially silly questions ahead: As someone with only a couple hundred hours of UE under my belt with no fully finished projects; would approaching a small, 5v5 multiplayer game be unrealistic? Just starting to dig into it, but handling hosting etc seems potentially prohibitive for a small indie game. Are there workarounds with things like Steam and Epic Online Services to mimick Peer to Peer connections or are dedicated services mandatory?
I ran into a weird problem so basically I made it so if you are the host of a game to display a Server host text using a widget that is placed in the viewport only if you are the host by using the HasAuthority node. It worked fine but when I redone the project using advanced sessions plugin and the clients all now recive the Serve Host text and the editor tells me that all the clients are authority. any way to fix this?
Should Listen Server's be what I'm investigating in this instance?
@boreal geyseri'll answer that in #online-subsystems
I'm thinking Listen Server's with additional host migration might be what I'm looking for?
that's not quite how it works. For something like you're trying to accomplish, dedicated servers are essentially mandatory for a fair game. By using listen servers, you ensure that one of your players is the host, outside of no latency, they are the authority, which means they could easily cheat. Dedicated servers helps alleviate this, but not entirely. You should look into PlayFab or Gamelift, both of which have free tiers you can use during your development period and then once your game (hopefully) starts making money, you'll be able to offset the costs.
Really appreciate the answer; thank you!
I will say, gamelift can get stupidly expensive fast. As can playfab.
the absolutely cheapest solution that's still cloud based is a custom scaling solution using AWS EC2 instances, which is what fortnite uses. However, that requires a lot of technical knowledge, planning, and maintenance
If you haven't published a game before, I'd go listen server for multiplayer
And go with a game design that has legs in single player mode. Don't rely on having the critical mass of players around.
Or if you must got multiplayer, think more like GarrysMod (self/community hosted) instead of a Live Service.
Good points ; it's more of a casual game concept and not meant (at least initially) to be competitive, so listen servers might make sense to start, then if it miraculously gets some traction I could try to implement dedicated server hosting. Thanks for the advice folks
My issue with implementing single player is scope; was shooting for a very narrow scope, one game mode, two maps, small casual multiplayer game but as I'm learning that may be more daunting than it seems lol
So I have a replicated bool IsAlive set in my char which I get in AnimInstance. I use that in my AnimBP to play death animation.
In 2 clients multiplayer, the anim won't play.
If the game design is one such that a small community can survive (Not being pessimistic but you have to plan for the worst), then a dedicated server design with community hosted servers would do just fine. Just don't expect to make anything competitive or with matchmaking etc.
Do you know if this'd work in multiplayer? https://gyazo.com/261031a33ffe9f9790f6a56354bbe5f8
Sure, that has nothing to do with networking. Networking's job is to make sure IsAlive and the Montage playing in UpperSlot are synced up
So i get server false and client true for the IsAlive bool, strange?
Is the bool replicated and are you setting it on server?
Ive IsAlive replciated in my char class. Here's the anim-instance. https://gyazo.com/bf7e856c3ffa70cf099db7ca5026754c
That should replicate, you gotta figure out where it's failing
like what. IsAlive has default val set to true. That's the only place it gets set. And it's set to false up there.
bool IsAlive = true;```
Just debug it and figure out if the failure is in getting the bool from server to client or from client actor to anim BP
So in AnimInstace class, the bool swithes from true to false and repeats.
LogTemp: Warning: ---------------------------0 FALSE
LogTemp: Warning: ---------------------------1 FALSE
LogTemp: Warning: ---------------------------0 TRUE
LogTemp: Warning: ---------------------------1 TRUE
Got it fixed. Instead of getting the variable directly I used a function to get it. Thanks
how can i set movement mode in multiplayer?
Set locally and in addition RPC to Server?
yes, i tried to use implementation to change the mode, but is does not work
It won't solve the issue, the RPC's won't arrive at fixed intervals and many of them may also be dropped.
Anybody online who has got an idea about this (^) problem?
For one, this will never be really smooth, cause you'd need to keep track of the moves and correct the client and what not.
But despite that you are missing the Prediction part
Your client is not setting the rotation locally too, so it has to wait for the server to tell it to move
Yea was my gut feeling as well, but what would be the correct solution to make it smooth then? Figure out the prediction part?
Hey so late response but you NEED an online subsystem, if you downloaded advanced sessions you should have the steam version there is a tutorial for that here: https://www.youtube.com/watch?v=EDNF2DNLhPc&t=2406s it uses steam that's in built in ue4 and the advanced session plugin and steam advanced session plugin.
Check out my Unreal Engine 4 courses:
โบSouls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
โบMultiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
โบMultiplayer Top-Down Dungeon...
I overrode Gamemode:PreLogin to prevent players from joining a listen server when it is currently in a gameplay level (only allow joining lobby level). It throws an error (just not the one I told it to) if they try.
How do I:
- Get it to throw MY error that tells them why their join was rejected?
- Even better, indicate on the Found sessions whether a game is in progress or not (currently in a gameplay level or a lobby level)?
I am using OnlineSubsystemNULL currently, not steam.
hi is it possible to play on dedicated server between two levels
like in minecraft between three worlds
Does anyone have a link for a good reference guide on how to design a well balanced multiplayer pvp game without getting the technicals, I'm looking for a high level overview of what makes for good balanced gameplay.
Does pkglag still work?
@graceful flame No real links, but my general thought process on that is the common triangle. In PvP things either need to be perfectly balanced, as in every player has access to the same thing as everyone else at all times. Like a common shooter. For more in depth games, the triangle is very common. Class A counters Class B, Class B counters Class C, and Class C counters class A.
This also goes well with the PvE balancing if you have different class types. Of course the Healer/Tank/DPS is the most common version of this. One class does their job a lot better with the help of another class, and that class does their job better with the help of a third class, etc. Tanks tank better with healers, Healers heal better with DPS killing things quicker, and DPS do their job better with tanks, often because of hit interrupts or backstab style effects.
Old paper RPG stuff is much the same. Warrior types often shred rouge types, rouge types will tear through casters, casters often control enough or have armor negating abilites to bring down warrior types. You just need some form of circle of life for your meta.
Thanks @kindred widget I'm glad to know that I'm designing my game with that triangle concept in mind. Different roles counter each other, but I think what I'm after here is more along the lines of when should a restriction be placed that limits the choice a player can make. How many limitations should there be? How many counters to your chosen role should there be? Too many counters and the game becomes far too complex, too few counters and it becomes predictable and repetitive fast.
This isn't really a #multiplayer topic, but generally speaking your player & game research will help you decide what elements do you want to be predictable/complex
Side bonus to handling that after game release. People love patch notes and gameplay changes.
also a reason why Q&A/alphas/betas are bae
and their love will be love & hatred at the same time xD
I suppose if I'm aiming for a MVP it should be kept simple. Right now its 5vs5 with 3 unique roles to choose per team. Eventually I want to make it 5vs5 with 6 roles to choose per team which would effectively double the pvp complexity, but I wonder what is "too much" when it comes to counter vs counter. I know moba games go really deep into complexity and players love it for that, but newbies hate it because it creates a steep learning curve. But on the other hand if its far too simple players will get bored. Trying to balance pvp balance is tough lol.
3 roles vs 6 roles != 2x complexity. It's usually way more than that, depending on the design of each role
Quick question: If I have two replicated variables, and I update both of them in the same Function, can I assume that they'll both eventually reach the clients at the same time?
You should, because packages are being sent after tick
So first engine runs function, and only then, when you changed your variables, it will build a network package and send it through some nerdy protocols
How to create subsystems only on client/server using ShouldCreateSubsystem? (How can I check authority/server to return true?)
Which type of subsystem is it? World?
Yep
And you're wanting to create it only on server I assume?
Both, I have two systems, I need one on authority and other one on clients only
Try this cpp const bool bIsClientOnly = GIsClient && !GIsServer;
or via (From UKismetSystemLibrary::IsServer) cpp return World ? (World->GetNetMode() != NM_Client) : false;
Ah, checking Netmode looks like a very solid idea, thanks (other works well too though)
don't use the GIsX, it won't work correctly in the editor with multiple PIE sessions
Trying to replicate rotation on an actor but I dont want to use multicast.
How would I do it?
I don't know what other information to provide, if you need any more I can provide.
@minor atlas i think the server that is executing and has the players joined to it can only run one level at a time.
But that one level can load other levels in or out during play. I dont know how to do that during multiplayer properly though.
Also You can send players to other servers when they go through a portal etc.
Gamelift doesnโt provide a backend service, you would have to make the identity and all other services yourself to be able to use gamelift.
The equivalent would be something like Accelbyte which you can use with Gamelift as they are an Aws partner
Is HasAuthority is the same is GetNetMode() <= NM_ListenServer?
@foggy rain Not exactly. Net mode does not equal authority. NetMode is the world netmode of the machine. So if there is a server, every other machine will be a client. If a machine is alone, it can be a standalone, and then there is also different server types.
Authority is the local role. In short it will return true if that machine has spawned that actor. For instance, if a client spawns an actor on it's own machine, it will return HasAuthority = true. A replicated actor on a client will be false since it's role will be simulated or autonomous proxy. While on the server it would be true for those same actors because it's the one that spawned them initially.
Thanks for the detailed explanation!
I asked earlier.nut it might have been drowned out by other conversations: I am using OnlineSubsystemNull over LAN, and overrode gamemode perlogin to reject players from.joining the server if the server is not in a Lobby level.
But i need 2 more things to happen and dont know how:
- The rejection error message is not the specific one I set in the override and it should be.
- I need the FoundSessions returned from Find Sessions BP node to contain info about whether the server is in lobby or not, so player can filter out servers that are busy playing and only show sessions that are available to join.
I have a related question about it. When I possess / unpossess a pawn from player controller, should I only do it on the server or in authority clients?
Server should handle possession calls entirely. It all gets replicated.
Hm... I have an issue then :D
I calling APlayerController::ServerRestartPlayer but it works only for a listen server controller. If I trying to call the same function on a client's controller - it not works. I looked in the source code and it stops on IsInState(NAME_Inactive) || (IsInState(NAME_Spectating), because it false on the client's controller.
What am I doing wrong?
Well. Where you call that from won't matter. It's a Server RPC so regardless of whether it's ran on the server or the client it'll end up on the server.
Glancing through general code calls. I'd assume that your player is in state Playing. You might try calling
ChangeState(NAME_Inactive);
ServerRestartPlayer();
But saying that, I assume there may be a better way to get to that if that's the case. I normally just go straight to the unpossess call.
So when you unpossessing, you are automatically going into inactive state?
It is strange that this does not happen to me. I will debug it, thanks!
I calling Controller->UnPossess(); from the pawn. Is this a right way to do it?..
how does GetLifetimeReplicatedProps work with inheritance? Is there a way to stop replicating a variable in a child class that the parent class is replicating, or change the replication condition of a variable in a child class that a parent class is replicating?
my use case is that I have a struct variable that I am replicating in the parent class, but the child class supports client side prediction of this struct, and I'm managing the state of it via RPCs and want to do a COND_SkipOwner in GetLifetimeReplicatedProps specifically in the child class.
@vivid seal not sure you can change the condition in child classes
we ran into a similar issue
and just skirted around the problem
its a fixable issue but it drives me nuts that I have to specifically code the parent class in a way that makes the child class work lol
either that or have the child class create a duplicate struct value and override every getter function for the original struct's info to instead get the child struct's info, and then just use the new struct as the "predicted" version and ignore the old struct.
that feels hacky tho
Is it possible to have a RepNotify with a parameter of the old value in blueprints or only c++?
๐
I think I looked into that before. There is for example DOREPLIFETIME_ACTIVE_OVERRIDE( AActor, ReplicatedMovement, bReplicateMovement ); this stuff, which could help.
But there should also be ways to just straight up manipulate the replicated property array
Check the UnrealNetwork.h file
There are some useful functions and macros in there
Specially starting line 360, which is reset macros
Use these to change the replication settings of an inherited property
so in the child class I'd use RESET_REPLIFETIME_CONDITION and that will work on a variable that is being replicated with no condition in the parent class, and change it to whatever condition (in this case, skipowner)?
and this would be done inside GetLifetimeReplicatedProps?
Hey, im working on a rolling/marble game and want it to work online,have some experience with replication, but somehow i dont get the movement to replicate.
The code breaks from client to server, and i Cantmove at all anymore at this point
Hm... I looked at the source code and the player only changes it's state on a local player's controller. It's super illogical, but here's a comment from the APlayerController::PlayerTick:
/* PlayerTick is only called if the PlayerController has a PlayerInput object. Therefore, it will not be called on servers for non-locally controlled playercontrollers. */
This is where it changes it's state on my listen server (e.g. this is.why it works on it).
But it will change it's state if the pawn will be destroyed.
Well, the ServerRestartPlayer is most likely the case of UI input. Something you'd call from a button or input key when the player is ready to restart. I'm not very familiar with it myself. Like I said I just call Unpossess and Possess myself through my own functions.
But it will not work for UI, because ServerRestartPlayer will check for it's state on the server and it will be wrong unless I won't change it on my server manually.
Yes, I understand. I just trying to reuse Epic's system :)
Oh, I looked deeper and there is no need to call UnPossess at all. Controller->ChangeState(NAME_Inactive); is enough, the pawn will be automatically detached.
So, about Saving Persistent Data for a Multiplayer Game..
I know GameInstance would be possible but is it Safe Enough?
Is External Database with untrusted api access best practice?
Any production ready service you could recommend?
DynamoDB is about as production ready as you can get
Playfab also has player data storage options, as does EOS
What does it mean? Warning: Property NPC_Character::IsAlive (SourceClass: NPC_Character) was not registered in GetLifetimeReplicatedProps. This property will not be replicated. Use DISABLE_REPLICATED_PROPERTY if not replicating was intentional.
Input actions are normally handled in a PlayerController blueprint or a Pawn blueprint?
You have the property IsAlive marked with UPROPERTY(Replicated) but you didn't put it in the GetLifetimeReplicatedProps function in your cpp
it depends on what your use case is. The player controller is a good spot for shared inputs, ie opening a settings menu, etc. If your player will be possessing different pawn types, ie a walking character vs a vehicle, then you may want to store those in the pawn itself.
I have this. DOREPLIFETIME(ANPC_Character, IsAlive);
show your declaration
also you can just use windows key + shift + s for snip screenshots.
just puts it on your clipborad
UPROPERTY(BlueprintReadWrite, Replicated, Category = "AI | Config")
bool IsAlive = true;
Do you know why i get this error: ANS_DealDamage.cpp(8): error C2027: use of undefined type 'USkeletalMeshComponent'
It happens when I'm packaging plugin
you're missing an include
this? Components/SkeletalMeshComponent.h
should be it yeah
Even though I should ask in plugin, but the project builds fine but during plugin package I get bunch of errors
Okay makes sense, thanks!
Do we need to put something to Build.cs in order to use PushModel?
I have an issue with ragdolls in multiplayer, when using the code without being networked it works flawlessly
however when I set replications "properly" and trigger ragdoll, pawns start to fly until I trigger "unragdoll" again
anyone knows about this issue ?
Depends. Do you use includes that are in a different module?
void ASCharacter::CalculateMeshLocation_Implementation(float DeltaTime)
{
FHitResult OutHit;
const FVector LineTraceStart = GetMesh()->GetSocketLocation(BoneSocketName);
UE_LOG(LogTemp, Display, TEXT("BoneSocketName: %s - TraceStart: %s"), *BoneSocketName.ToString(), *LineTraceStart.ToString());
FVector LineTraceEnd = FVector(0.0f, 0.0f, -1.0f) * 100.0f + LineTraceStart;
FCollisionQueryParams CollisionParams;
if(GetWorld()->LineTraceSingleByChannel(OutHit, LineTraceStart, LineTraceEnd, ECC_Visibility, CollisionParams))
{
CapsuleLocation = OutHit.Location + FVector(0.0f, 0.0f, 90.0f);
}
else
{
CapsuleLocation = LineTraceStart + FVector(0.0f, 0.0f, 90.0f);
}
MeshLocation = FMath::VInterpTo(MeshLocation, CapsuleLocation, GetWorld()->DeltaTimeSeconds, 50.0f);
}
There is a bug somewhere in this code when it is used in multiplayer
what this code does is calculate the distance to the mesh, set it on the replicated MeshLocation variable
Then, this code is called on Tick which is Multicast Reliable, after the calculation is done the location of the capsule component of the player is set to MeshLocation
when testing it on standalone it works perfectly
however when testing in a multiplayer settings the Z values keeps increasing endlessly
ok I narrowed it down, I increased the linetrace length to 200, now it appears that the X and Y are constantly changing and moving forward for some reason
which means GetMesh()->GetSocketLocation(BoneSocketName) keeps changing in value for some reason, even though the ragdoll has completely stopped movement
this only happens on multiplayer so I don't know what exactly is the cause, framerate? lag compensation?
Solved it by enabling always tick and refresh bones on skeletal mesh component
Nooo don't mark tick rpcs reliable!
That's the worst thing you can do haha
so I set it to not reliable ?
Yes
You are sending it every frame. It's not needed to be reliable
You will just fill the reliable buffer and other things will stop replicating properly
hummmm
I need to read your necronomicon of networking once again
thanks for the heads up
are there specific use cases where I should use Reliable ?
I think I've set most of the things here as reliable >.>
