- Home /
whats causing this error?
NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value)
NetworkManagerBetter+$lobbySpawn$32+$.MoveNext () (at Assets/RPG/NETWORK/NetworkManagerBetter.js:169)
help please
EDIT: fixed, it didn't have a component, but how to make it look for a component inside the player parent? 'cause player is just a parent, inside it theres the player object with the component
are you sure that the object named "made" has some value and that you don't just define it as
Object made;
or something along those lines ? or that the object has a component named "SCR_player$$anonymous$$ove" ?
A references object is null, that could be the object made, the attempt to get the script component SCR_player$$anonymous$$ove returned null but than you tried to set the field/property playerName which of course wouldn't exist if the component was not found.
ShadoX: hmm, var made = Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
fixed, it didn't have a component, but how to make it look for a component inside the player parent? 'cause player is just a parent, inside it theres the player object with the component
Try finding out which object is null. Comment that line and ins$$anonymous$$d add this lines after or before it:
Debug.Log(made);
Debug.Log(made.GetComponent(SCR_player$$anonymous$$ove));
Debug.Log(made.GetComponent(SCR_player$$anonymous$$ove).playerName);
Answer by dsada · Jul 26, 2014 at 02:29 PM
Without the context no one can tell more than either your GameObject named "made" is null or it hasnt got SCR_playerMove type component.
Try to debug.Log them before this line.
if(made == null)
{
Debug.Log("made is null");
}
else
{
if(made.GetComponent<SCR_playerMove>() == null)
{
Debug.Log("hastn got the component");
}
}
And you will get the problem
fixed, it didn't have a component, but how to make it look for a component inside the player parent? 'cause player is just a parent, inside it theres the player object with the component
If u would like to find component in children:
made.GetComponentInChildren<SCR_player$$anonymous$$ove>();
if u would like to find component in parent:
made.transform.parent.gameObject.GetComponent<SCR_player$$anonymous$$ove>();