How can you set the child of a gameobject active I have tried
gameObject.transform.child.gameObject.SetActive(true);
But I get the 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.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
BuildZone.Update () (at Assets/my assets/Scripts/BuildZone.js:24)
the script was attached to the parent of the object I was trying to make active
How can I make the object active?
Assets/my assets/Scripts/BuildZone.js(24,33): BCE0005: Unknown identifier: 'child'. is this C#?
– qwertyk31Nope - it's javascript. Could you post related lines from your code?
– ArkaneXhere is part of the script function Update () { if(inBuildZone) { if(INV.sticks >= 30 && Input.GetKeyDown ("r")) { Debug.Log("Build house"); child.gameObject.SetActive(true); } } } the Debug.Log is called. does it matter if the game object with the "child.gameObject.SetActive(true);" is also a child?
– qwertyk31Did you declare/assign
– ArkaneXchildvariable? In the sample code from my answer,childis both declared and assigned as part offorloop. And regarding your question - it doesn't matter.Thanks it works now
– qwertyk31