HELP! Multiplayer physics state problem

Hi,
Just to start with: I lurked deeply into the abyss of unreal engine forums, and helpdesk. Searched everywhere. No solution found.
In my final desperation I call upon You - Gods of blueprints to show me the path to enlightment!

And the problem is:
I can easily simulate physics on objects on dedicated server. HOWEVER I can’t change the state of simulation on the mest in any way. IT works when run on server. does not when run as server event from a client.
I am making a weapon switching.
Once you pick up a weapon that goes into used slot, you drop previous weapon. When you do - I wish it not spawn a CRATE, nor to teleport under your feet. I want it to fall off your back, holster, hands or anything. and once picked up again - to STOP simulating and be attached to socket once again.

The result is as expected when run as a server. when testing in multiplayer with dedicated server however - a droped weapon disapears on client. A picked up wapon does show. when event attaches it do a socket it imediately falls off (the error say you tried to meld bodies on a simulated body) - so the state of simulate false does not take any effect.

I checked if its:

  1. authroity problem? Nope.
  2. Ownership problem? No.
  3. Run Physics on dedicated sevver boolion problem? No yet again.
  4. the event isnt run or go thru? nope. the execution chain follows perfectly and simply the simulate false is ignored. the simulate true works - however the object disapear on client even though it is still there on server simulating as should had.
  5. problem is the same for objects that are simulating from the start of map or at runtime.
  6. Doesn’t matter is the mesh is a skeletal mesh or static mesh. the problem is exactly the same.

IS this some common problem so obvious I am retarded to ask about it? Or maybe a bug? Or I am missing something important in the process? Please help…

Hey there :slight_smile:

We made a multiplayer game and we had the exact same problem.

Our weapons were physical actors while not held by the players. You could pick them up and throw them.

But we had a bug with every clients, they saw the weapon instantly appearing at the feet of the character dropping it or the weapon was simply disappearing from the screen.
The server was seeing all correctly: physical weapons being picked up and let down.

We never managed to cure the problem and we shipped like this (you can’t throw weapons in the final game, they just fall at your feet when you drop them).

We were out of time but I think we had several good leads:

  • attach actor to component behaves quite weirdly with replicated actors and “replicates movement” in general - try playing around it in a blank project and see how it behaves (we had pretty weird result even in this situation)
  • try printing the position of the weapon just after you detach it from the character on all machines, if they have a different location you know there’s something wrong at that very moment
  • we had a hunch that the weapon might get a crazy velocity on clients machine when being detached and get impulsed weirdly and fall to the ground as a result / gets pushed out of the map (try nullifying its velocity to check that out)

Let me know if it rings a bell, if not we’ll try thinking to some other stuff.

But the thing is, even if physic is not deterministic in Unreal, Clients should see the stuff being physically thrown, even if its position is different on Server at that stage.

I don’t know.

same machine. same machine run in dedicated server mode. same machine dedicated mode - not a single process. local LAN. no dedicated server full build yet. but the results are the same. the definition of instanity is doing something same way and expecting diferent results - so I dont expect a full blown build to behave better.

I can easily fake physics on non-replicated actors that sync with server only on “wake” and “sleep” of the physics body. HOWEVER the actor itself must be a replicated actor (even if movement doesn’t need to be replicated) - because of the weapons functionality and relevance.

HOWEVER. in a blank project in order to get a good physics replication I had to setup few things:

  1. make the actor replicated
  2. make the mesh a replicated component
  3. make the mesh replicate movement - as it replicates the physics or movement component state.

When used the same setup in the game project - the magazine at reload drops like a freaking slideshow. around 4 frames until its physics state go to sleep. However the weapon itself as made out of more components simply breaks as described. there are 2 problems:

  1. detach from actor - surely this blueprint node brings many issues as it does not replicate the state of detached object to clients. Objects that are attached and detached on server are FLOATING in front of my character on client. strange.
  2. the slideshow is being fixed by increasing the new update frequency. at 12 it seems pretty nice. but I am not sure if it replicates the transform even if the object is not moving?
  3. I still cant stop simulating the physics. I dont have problem with syncing the physics. I want to stop it completly. One way to do it is to spawn and destroy actors with proper physics state - but I cant do that as the ammo type, number, and weapon state and components are relevant. I cant despawn and spawn it all over again each time some interaction happens.

To anyone having the same problem:
There are 2 major problems with engine. I have no idea if its a bug or a feature.

  1. you cant properly DETACH replicated objects on server with replicaiton of bohavior to clients
  2. You cant change the physics state of objects after spawn.

So…
SMOKE AND MIRRORS.
We simply have to destroy and spawn actors in order to fake it. Also for any physics asset that is of little relevance - we spawn it NON-REPLICATED on all clients. like the magazine drop.

I can confirm item 1, this was haunting me for a long time. It’s an Engine bug that should be fixed in 4.16. However I still use a manual OnRep setup för attach and detach of my weapon actors on the player.

How exactly did you set it up? a logic link or screen? I am thinking of remodeling the game to spawn and despawn simulated or non-simulated actors. if there is a way to fake it on client side properly and safely Im in! :slight_smile:

edit: ps. i root for age of chivalry! :slight_smile: love the idea and main theme!

I just realized I answered in the Blueprint channel, my solution is in C++ but you setup an OnRep function and do the attach and detach from there.

PS, glad you like the Age of Chivalry Plague style :wink:

SOLVED:
base class ACTOR
single skeletal/static mesh as root object with those settings:

collision: enabled - query and physics (because i must trace and run physics on weapons)
object type: world dynamic
Collision preset: custom - make it ignore pawn
Can player step: NO!
component replicated: yes
enable physics on dedicated server: yes

The error was made by 2 things:

  1. you can change the “simulate physics” tick at runtime! however you cant set the collision preset! once the object is spawned from the default class its unchangeable in multiplayer.
  2. when attaching to component NEVER meld simulated bodies! When detaching it will break severly. Also on character ragdoll he will behave normally on server but start flickering and acting strange on non-owning clients.

I have physics on weapons. they unattach and drop on ground when picking up new weapon.

Edit: Also - I had some issues with ownership and instigators. I really want the game to be hard to cheat at. But some events must be triggered from the weapon itself, not external object like an ability class I made.

Thank you very much for sharing this :slight_smile: