nicholas-maltbie / FallingParkour

Multiplayer racing game made with Unity
MIT License
18 stars 3 forks source link

Push Objects Locally #49

Closed nicholas-maltbie closed 3 years ago

nicholas-maltbie commented 3 years ago

Description

Added many quality of life changes to pushable objects and removed the delay when hitting an object (hopefully) to allow for players to be able to push objects even if they have a longer ping time (too long will result in inconsistent results).

This comes from allowing a player to be the 'owner' of an object after they hit this.

Also cleaned up interactions between IPushable objects and IMovingGroundObjects by adding the two classes RelativeVelocityMovementTracking and RelativeVelocityRigidbodyTracking that allow for transfer of movement to players based on relative velocity. This will stop a player for shooting off at supersonic speeds while pushing a box they are standing on top of (despite how fun that bug can be).

Also of note, there seems to be a small error with the NetworkRigidbody, when it changes owners quickly clients will try to write to the variable without permission, this is probably due to the owner change state not being propagated to the client fast enough. This could be mitigated by giving the client ownership a short period (such as 0.05 seconds) but would involve tuning based on the situation. This has been temporarily mitigated by allowing for all clients to write to the NetworkRigidbody component (instead of just the owner) and therefore, when conflicting writes are received by the server from non owners, they are either ignored or blended between differnet values. This might result in jittery situations if multiple clients are all pushing the same object at once but this probably wont happen.

How Has This Been Tested?

This has been tested in the following situation

  1. On the server pushing an object alone
  2. On the server with one client connected. Tested passing object between server and client, pushing object as client, and pushing object as server
  3. On the server with two clients connected.
    • Tested passing object between client and server
    • Tested passing object between clients
    • Tested pushing object as client or server after having a differnet player push the box

These tests all occurred on the same computer with essentially zero network transport delay, should test over internet as well.

Checklist:

nicholas-maltbie commented 3 years ago

Ok, so local control works very well but running into some kind of permission error. Going to just push the object locally and on the server and hope it works itself out :D