New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix - Optimized NetworkTransform on all networked prefabs in the Invaders sample [MTT-7599] #168
base: develop
Are you sure you want to change the base?
Conversation
…unecessary transform data The server is not interpolating the ennemies position and given the game doesn't have any animation, not interpolating anything allows for the same movement feeling between clients and host.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks smooth!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure that they were improvements, but what were the changes to Invaders Game Manager and SceneTransitionHandler prefabs?
Just listed would be fine.
@fernando-cortez I think they got reserialized because I touched them, but haven't changed anything, the diff is only the component order that changed, not sure why. |
Ah that makes sense! I think that's fine if they go through. |
58580c2
@@ -10,10 +10,10 @@ GameObject: | |||
m_Component: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 2859882261451710602} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bastienunity it seems the order of scripts was changed here as well, is this intended? If not, can you revert it to avoid potential issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, funny story... When selecting the prefab, the Inspector refreshes after one frame and moves the NetworkObject component in third place on every single Prefab I select in the project. So any further changes made to the prefab will save the NetworkObject component position changed...
I can manually revert that change outside of Unity, but because it is forced and automatic, I think it's better to just commit it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Netcode is forcing reserialization, and we're going to keep running into this change in subsequent PRs, this can go through.
Let's expose our code to potential race conditions and address them, if they arise!
@@ -10,11 +10,11 @@ GameObject: | |||
m_Component: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 2037077820506562951} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -10,11 +10,11 @@ GameObject: | |||
m_Component: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 1361474663871475650} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -10,11 +10,11 @@ GameObject: | |||
m_Component: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 7651551376209856180} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -11,9 +11,9 @@ GameObject: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 6100000} | |||
- component: {fileID: 2336033219118315817} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -10,10 +10,10 @@ GameObject: | |||
m_Component: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 5053919295125167455} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -14,7 +14,6 @@ GameObject: | |||
- component: {fileID: 6100000} | |||
- component: {fileID: 11400000} | |||
- component: {fileID: 6564576217164106930} | |||
- component: {fileID: 8844355272195160781} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what component was removed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the NetworkTransform, Shields are spawned and destroyed but never move, so they don't need to sync their Transform at all.
@@ -11,11 +11,11 @@ GameObject: | |||
- component: {fileID: 400000} | |||
- component: {fileID: 21200000} | |||
- component: {fileID: 5000000} | |||
- component: {fileID: 3955316467729786863} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Description
The gameplay feeling is very different on clients vs. host in the Invaders Sample.
This PR is changing the interpolation of netwrok transforms to false in order to fix the issue.
Because the game is not using any physics or animations to move transforms in the scene, the server itself is not doing any interpolation between positions and simply forces the new transform position of enemies or bullets. Removing the interpolation prevents the client from smoothing that movement locally and makes all movements looks like they are behaving the same on the host and any client.
While updating the NetworkTransform, we also removed most of the sync values of the transform to keep only the ones that changes during the gameplay.
Players and SuperEnemy only need to sync their postion.x because they can't move vertically.
Enemies only need to sync their position.x and position.y.
Shields don't move, their NetworkTransform has been removed.
Bullets only need to sync their position.y because they only move vertically.
Before changes Host vs. Client
pre-changes-invaders.mp4
After these changes Host vs. Client
post-changes-invaders.mp4
Issue Number(s)
MTT-7599 - Turned interpolation to false on all the networked transform to make movements between host and client render movements the same way.
Contribution checklist