Hi,
I’m not quite sure what i’m doing wrong, but I have a character Prefab ( which is just a model with a script ), and i’m trying to attach another prefab (a Ski model) to it’s foot. In my manager script ( which is definitely running ), i use the following code
Transform character = (Transform)Object.Instantiate(PrefabCharacter, point, Quaternion.identity);
Transform leftFoot = character.transform.FindChild("l_toe");
Transform leftSki = (Transform)Object.Instantiate(SkiModel, point, Quaternion.identity);
leftSki.parent = leftFoot; // 1
//leftSki.parent = character.transform; // 2
leftSki.localPosition = Vector3.zero;
leftSki.localRotation = Quaternion.identity;
The weird thing is that if i replace (1) with (2), it sort of works - the ski attaches somewhere on the character who is walking around, despite it not being attached in the correct position. What worries me, is that if i do a
Debug.Log("Blah: " + leftSki.position);
under that code, I get a runtime error saying that get_position could not be accessed. Anyone got any ideas?
Just to cover a few things, i did some debug logging to make sure all those objects are what i’m casting it to, so those assumed casts should be safe.
Thanks in advance
David Goemans