Search Unity

Using AddForce() on a networkObject

Discussion in 'Netcode for GameObjects' started by Durium, Mar 6, 2023.

  1. Durium

    Durium

    Joined:
    Feb 1, 2020
    Posts:
    37
    Hello friends! I am wondering about why the AddForce() is not working on my players rigidbody2D over the network.
    So i cant use AddForce() locally nor over the network and im wondering if we need to interract with the networkRigidbody or something? :)

    If anyone has info or a clue on why AddForce() wouldnt work feel free to tell me!

    What i have tried:
    - Changed RigidBody2D settings
    - Increased the force to 10000
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,975
    The NetworkRigidbody script makes any object attached to it switch to Kinematic mode except for the server. In theory it should work if you send an RPC to the server to tell it to add a force to a given object, and then it should work. Alternatively you'll need to switch to client authoritative movement (examples in the manual) but I don't think this works well with physics since you'd have each client simulate its own physics world.