-
Notifications
You must be signed in to change notification settings - Fork 4
NetworkSpawn #16
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
NetworkSpawn #16
Conversation
| } | ||
| ``` | ||
|
|
||
| # Reference-level explanation |
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.
makes a lot of sense, thank you for this RFC.
I only have one question, do you mind outlining where/how you'd wire OnNetworkDespawn events on the server and clients?
Some neighbor codes and/or call-stack to get to the OnNetworkDespawn would be great!
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 added this to the reference level section of the RFC. I also plan to do some small refactoring around how NetworkStart is called (no behaviour changes just throwing out unused legacy code)
|
|
||
| The internal function will be used so that NetworkBehaviours can subscribe to internal MLAPI events. | ||
|
|
||
| `OnNetworkDespawn` will also be called on the server when a `NetworkObject` gets destroyed because that also counts as a despawn. |
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.
Surley this should only occur if IsSpawned is true? Otherwise you could have a NetworkObject that is never actually spawned, (thus OnNetworkSpawn is never called) but OnNetworkDespawn is called.
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.
OnNetworkDespawn is very interesting to me, would this also give me room to gracefully fade away the object over some time on client or the object would be destroyed anyway before I could fade 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.
You won't be able to use OnNetworkDespawn for this specific use case because MLAPI would still force destroy the object after. In this case you would need to implement a custom destroy handler to override the destroy logic of MLAPI:
https://docs-multiplayer.unity3d.com/docs/advanced-topics/object-pooling
@TwoTenPvP Yes, correct this will only occur if IsSpawned is true.
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.
@LukeStampfli, Makes sense. thanks for pointing out the object-pooling.
Would OnNetworkDespawn also be called when server runs Show/HideNetwork?
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.
Currently NetworkShow and NetworkHide spawn/despawn an object on the client and would trigger the OnNetworkSpawnandOnNetworkDespawn` functions
0xFA11
left a comment
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.
LGTM! 🚀
Though, only one side-question: Do you have any plans to let docs people know and help them get things up-to-date with this upcoming change?
|
@MFatihMAR I was planning to let docs people know once the RFC is accepted and the PR is merged. |
JesseOlmer
left a comment
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.
lgtm
See linked RFC document →
RFC proposing renaming
NetworkStarttoOnNetworkSpawnand introducing aOnNetworkDespawnvirtual event function.