Hello, I'm trying something very simple, an electron orbiting an atom...
my C# code is the following
public class AtomScript : MonoBehaviour {
public int electrones;
public Transform electronPrefab;
// Use this for initialization
void Start () {
GameObject clone = Instantiate(electronPrefab, transform.position * 1.5f, transform.rotation) as GameObject;
clone.transform.parent = transform;
}
// Update is called once per frame
void Update () {
}
}
And it throws an exception
NullReferenceException: Object reference not set to an instance of an object
AtomScript.Start () (at Assets/AtomScript.cs:12)
Line 12 is clone.transform.parent = transform;
I don't understand where is the error. If I write this code in JS it works without any problem.
:(
↧