Skip to content

Conversation

LukeStampfli
Copy link
Contributor

See linked RFC document →

RPC proposing a physics solution for co-op games.

@LukeStampfli LukeStampfli added the open RFC is open for review and comments label Aug 31, 2021
Copy link

@andrews-unity andrews-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks fine to me..

@SamuelBellomo SamuelBellomo self-requested a review September 2, 2021 15:42
@jeffreyrainy jeffreyrainy self-requested a review September 2, 2021 16:54
Copy link
Contributor

@jeffreyrainy jeffreyrainy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That all seems reasonable to me.

I think we'll need a bit fancier ways to synchronize physics in the future (there bigger fish to fry first, though), but this is a good solid start.

@mattwalsh-unity mattwalsh-unity self-requested a review September 2, 2021 17:53
Copy link
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good and just piggyback on what NetworkTransform does for ClientAuth for now


## Why we do not synchronize triggers and collision events

1. Collision and Trigger events contain information in reference types (classes) which is not something we could properly serialize. In addition these events contain information about the components and GameObject involved in the collision. We currently have no way to serialize that information over the network.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have restrictions similar to parenting and make sure we sync at least the collisions with NetworkObjects? We'd be able to sync a net obj's ID.
I'm guessing it'd still be hard to get an ID from a material for example. Wouldn't it still be ok to sync partial information? It'd be better than nothing, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to do something but it would be very limited. The collision event contains information such as:

  • The collider it collided with (we cannot synchronize this it's not a NetworkBehaviour and one Rigidbody can have many and they can be on child objects.
  • Contacts, contact points, velocities, impulse could in theory be synced but they would not reflect the situation on the client at the time the NetworkCollision would be fired.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could still have a "DelayedCollisionPoint", telling users this isn't an exact point, but still something that happened in the past if you want to play some sparkle VFX for example?
It's not the mountain I want to die on, if you don't think that'd add value, we can close this :)


3D and 2d Physics work exactly the same. The only difference is that the Rigidbody2D and NetworkRigidbody2D components need to be added to the GameObject instead of the Rigidbody and NetworkRigidbody components. The `Update` simulation mode of Physics2D is supported.

# Reference-level explanation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth putting a note for Brian when he reads this, that a lot of the bellow should also be included


## Synchronizing Rigidbody Parameters

We will not synchronize any Rigidbody parameters besides `IsKinematic`. For instance we will not synchronize the Mass or the Drag or the Constraints of a Rigidbody. The reasons we do not synchronize them are to save bandwidth and to keep the use cases of Rigidbody flexible. If synchronization of a specific Rigidbody parameter is needed users can add this with a custom script using a NetworkVariable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to save bandwidth" --> maybe I'm missing something, that's a few bytes at spawn, then nothing if it doesn't change, no?
Not sure I understand the flexibility bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People might change these values but not change velocities. For instance it is quite common to adjust the mass or add constraints to a RigidBody at runtime. If the controller of the body never changes there is no need to synchronize those values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a dirty check though no? That's different from saying we'll never sync these values. It's a bit like what Fatih did with NetworkTransform's state and per-axis synchronisation.

@LukeStampfli LukeStampfli merged commit 67bcfbe into master Oct 4, 2021
@LukeStampfli LukeStampfli deleted the rfc/physics branch October 4, 2021 09:03
@LukeStampfli LukeStampfli added the accepted RFC has been accepted label Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted RFC has been accepted open RFC is open for review and comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants