Dynamic rigidbodys

I made an capsule, it has collider and rigidbody.
I added network tranform, network rigidbody, network object components to it. I move rigidbodys with force, when testing in multiplayer. They are not able to push each other, I want an simple solution for this problem.

Show us your code. At least a primitive, latency riddled behaviour should work.

But networked physics is ultimately the most challenging thing you can do. Practically no game does that, and the few who do (ie Rocket League) wrote their own physics engine and complex server simulation with per-player rollback and reconciliation.

I used visual scripting (bolt)

Particularly for networking you’ll quickly run into issues with Visual Scripting since you will have to a) register callback methods for network events (client connected, networkvariable changed, etc) and b) you will have to use common NetworkBehaviour messages such as OnNetworkSpawn and c) you will eventually need to implement either or both RPC methods that carry the [Rpc] attribute as well as using NetworkVariable fields.

I’m not even sure if you can get events and message methods hooked up in VS in the first place, let alone subclassed MonoBehaviour or methods with attributes. Even if all that is possible in VS, it won’t be a convenient nor debuggable environment.



:point_up_2:

Don’t use (get) input in FixedUpdate because it runs at 50 Hz by default whereas Input runs with the framerate 60 Hz or more, thus you may be skipping some input events.

So… there isnt any simple solution to this problem?
:smiling_face_with_tear:

Also, on fixed update checks if button is pressed at consant 50hz. Everything else is frame dependent

There’s pretty much no simple solution for anything multiplayer. By using Visual Scripting you’re just going to make it even more complicated. Actually you’re the first I hear of who attempted to use NGO with VS together. It might be possible but you’re pretty much on your own with this.

That may be true but if you were to do a “key pressed this frame” check and that happens to be in between two FixedUpdate then that event simply won’t register. You’ll notice this as an infrequent, seemingly random issue where the player just won’t jump every (on average) 20th time you press the button.

It’s almost unnoticable with constant input ie steering but you still force responsiveness down to 50 Hz from at least 60 Hz.

If you are using owner authoritative motion (i.e. client ownership dictates who has the authority to move the object), then the issue you are running into has to do with non-kinematic vs kinematic collisions.

With NetworkRigidbody (v1.x.x) the owner instance is non-kinematic and it will have physics forces applied but all instances not owned by the client (and are owner authoritative motion) will be considered kinematic.

  • Client-1
    • Player-1 (non-kinematic)
    • Player-2 (kinematic)
  • Client-2
    • Player-1 (kinematic)
    • Player-2 (non-kinematic)

On either end you will have a collision but it will be viewed as a collision with a kinmatic body.
You can solve for this by:

  • Using server authoritative motion
    • Benefit: It will make physics collisions easier
    • Draw-back: Clients have to send their input so there will be latency involved in user input vs motion.
  • Detecting collision and sending collision messages
    • Continue to use an owner authoritative motion model and send messages on the impact and apply a force based on the two bodies colliding.
      • Benefit: Client input is instant and applies to the locally owned objects
      • Draw-back: Collisions could be latent and visually appear slightly off (i.e. a gap between two bodies colliding).
        • You can offset this by using triggers larger than the colliders and calculate the velocity of the two bodies to determine if a collision will happen and handle it that way too.

But physics can be tricky to implement using owner authoritative motion models which is typically why a server authoritative motion model yields better results if the physics collisions are a higher priority in your project’s goals.

1 Like