Problem is not reproducible or outdated
NullReferenceException at adding a NetworkTransformChild component
I have written the following code:
// Create a network transform child component in the parent to sync this boat over the network
NetworkTransformChild networkTransform = transform.parent.gameObject.AddComponent<NetworkTransformChild>();
networkTransform.target = transform;
However, it gives me the following error:
When I double click it, it brings me to the first line of the code I just showed. The weird thing is that the component does get made, even with the right settings. However, the component is disabled from the start.
Do you guys have any idea of what is causing this error?
Answer by dpoly · Jan 05, 2017 at 11:39 PM
Read the message. The bug is in the Awake() method of TransformChild, not in this code. Perhaps the source for that is not available at present.
But it should be. This script runs at the moment this object is created, which is after hosting a match.
So show the code of the Awake() function, which is where the error is really happening.