So we are trying to replicate about a hundred ai actors a time by synchronizing their position and rotation nothing else via a net multicast and it explodes our bandwidth how can we optimize it or what alternatives do exist?
thanks in advance
Hi there @Wertwer09. Hope you’re well!
This topic has been moved from International to Programming & Scripting: C++.
When posting, please review the categories to ensure your topic is posted in the most relevant space.
Thanks and happy developing!
oh yes ill watch out for it in the future it was my second post ever in this forum so thanks for moving it and thanks always
Why do you want to multicast the location and rotations? You can just enable Replicate Movement in the actor defaults and let unreal handle the replication. Multicasts are not free, they can be culled, and if they are all reliable, and you are doing 100-200 each frame, that’s way above the engine’s limits
ive tried to just set replicate movement but then they keep interpolating from one place to another or better said they snap from one place to another
Are you sure nothing else is setting their location in some other way? Because I have used replicate movement on more than 200 actors at a time with no issue in the past, I’ve probably used it with thousands of actors at a time, with and without movement components
i only set the velocity of the movement component on the server but ill have a look again
Doing that is scary, I’ve also had snapping issues with that in the past. Try to use the already existing functions to move the pawns, such as MoveTo or AddMovementInput
okay ill try it instantly and will report in a minute
UKismetSystemLibrary::IsServer am i right that this should prevent all clients from using the function that is in the scope of an if statement with this ?
First of all, AI controllers only exist on the server, so anything you do there should only happen on the server. Otherwise, a simple HasAuthority check can tell you if you have network authority over the actor, which, under normal circumstances, should be the server for AI
okay yeah the movement should only happen on the server but they still keep snapping
do i need to replicate the movement component ?
What is the MovementComponent on your Pawn?
Are you using Character or something else?
The CharacterMovementComponent has a lot of special code to make sure replication of movement doesn’t snap.
If you’re using another Pawn class and a nother MovementComponent, then you have to make sure that that MovementComponent knows how to properly interpolate movement when receiving replication data. You could read the code for the CharacterMovementComponent for inspiration.
iam using the floating pawn movement component
iam sry to ask but do you maybe know where in the character movement component the interpolation happens because its a very huge script
it also shouldnt be a problem if i call the add movement input in an external ai handlers tick that handles the movement for all ais ?
I don’t think FloatingMovementComponent has any interpolation. It’s intended to use for “browse level” type situations for a local client, as far as I can tell.
Character and Vehicle and Projectiles have implemented network replication, and I believe physics components also have reasonable replication support.
You might want to change your Pawn to use a physical body, and a physics movement component, and then drive the physics using forces and torques. Perhaps that will work better? I haven’t tried it, but that’s what I would try next, before breaking down and developing my own movement component (or subclassing the floating component) and adding interpolation.