Applying Impulse Force on NetworkedRigidBody2D

Options

Hi,

I have a simple setup of a 2d game with a player who can kick the ball.

Ball is a NetworkedRigidBody2D, when I apply force on the client using:

Vector2 direction = ball.Rigidbody.position - rb.position;

direction.Normalize();

ball.Rigidbody.AddForce(direction * KickForce, ForceMode2D.Impulse);

The client is experiencing a weird drop of a few frames at the beginning or a fast few frames rubberband effect.

Is any way I can mitigate this effect? It only appears at the beginning of a applying force.

Answers

  • emotitron
    Options

    Hi Poke,

    First thing I would recommend is getting on the Discord, so you can potentially get somewhat more real-time help from other users, or Fusion devs.

    There are too many unknowns in the above question to answer, but the most common mistakes are:

    1) Not using GetInput() inside of FixedUpdateNetwork() for all controller code.

    2) Predicting RBs that are player controlled - which will always cause a correction on proxies, because proxies (clients that are NOT the input authority) are predicting without foreknowledge of player inputs. In this case some effort has to be made to give your proxies a way to "guess" user inputs so they can apply them to the simulation - to reduce the number and severity of missed predictions.

    Also, the NRB2D component may not be correct, as work on NRB is happening, and some of those changes have not made it into the 2D handling.

    More information that would be needed is:

    Is this Shared Mode or Server/Client?

    When you say client, do you mean a proxy, or the controlling player's client?

    Is this being experienced as input lag?

    What does your controller code look like?


    Cheers,

    Davin

  • poke646
    Options

    I've uploaded a video with demonstration of this "pop" like effect when player kicks the ball. This effect is only visible on joined players. The host is ok.