Difference between OnStart and OnStartServer

I was initializing my components in code instead of assigning them in Unity and this is the first time it seems that the lecture doesn’t quite work with that method.

I kept getting a crash image that was only resolved by moving any code assigning my health to a component into the

OnStartServer

methods instead of the

OnStart

where it was working for other components.

Why is this different? Is the event subscription something that needs to occur before the normal OnStart?

Hi there,

According to the Mirror-Documentation, normally Start() gets called after OnStartServer(). It could be that depending on how things are initialized in the scene that health is not yet setup when you are calling OnStartServer, but by Start it is? Maybe this has to do with the way some components are network-behaviours and other’s aren’t. I’m not really sure what could cause this discrepancy.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms