How to correctly track not-player-controlled objects?

Options
Hi,

I'm making a 2d football game and I'm having trouble tracking the ball. Player movements are okay cause they are command controlled and can be predicted/corrected. The problem comes with the ball. When players collide against the ball it doesn't look bad, but when they shoot the ball, collisions get messy and weird stuff happens (clients predict wrong stuff and when server corrects them the ball just interpolates to the right position, which just looks and feels bad.

This is what I do to shoot the ball.

GetComponent().AddForce(dir * force,ForceMode2D.Impulse);

I'm using rigidbody2d for both the players and the ball since I need force based movements so that forces get transferred on collisions.

Is there anything wrong with my approach? Can I use rigidbodies at all?

Thanks.

Comments

  • stanchion
    Options
    Do you have a video of what this looks like?
  • Raúl
    Options
    Hi,

    I can give you the project if you want to check it out:

    https://github.com/ruloi/boltball

    Develop branch, play debug the "Game" scene. You move with WASD and shoot with space.
  • stanchion
    Options
    I will take a look. FYI you cannot publicly share Bolt, it is a paid asset.
  • stanchion
    Options
    It looks like you're not properly syncing the rigidbody. Otherwise you can make the rigidbody kinematic on the client.
  • Raúl
    Options
    Thanks for checking it out. I'll remove the project from github or remove BOLT from the repo.

    How should I track the rigidbody? If I make it kinematic it won't be affected by forces which is the whole point of using it.
  • stanchion
    Options
    If it's only kinematic on non owner it'll move on the server and it's transform will be synced to clients
  • Raúl
    Options
    Okay I did that and improvement is noticeable, but we are not quite where we want to be.

    The best thing should be tracking the rigidbody values correctly, right? I'm guessing with commands so that we can apply corrections from the server. Could you provide any help with that? I'm kind of lost here and no tutorials say how to track these kind of physics dependent objects over the network. I'm sure others will find it useful un the future too.

    Thanks again!
  • stanchion
    Options
    Rigidbodies are not included in the tutorial. It is very complex and implementations will be very different based on what kind of rigidbody you are networking.
  • Raúl
    Options
    Okay, I understand, but could you provide any help with that?
  • stanchion
    Options
    I offer consulting if you need some one on one help.