FindChild()
Blitz3D Forums/Blitz3D Programming/FindChild()
| ||
Hey everyone can someone give me an example of how to use the FindChild() command. My main problem is i can't figure out what i'm supposed to put for the second parameter. |
| ||
The name of the child you're trying to find. It's case-sensitive, if I recall correctly. |
| ||
Player = LoadAnimMesh("Player.b3d") PlayerRightHand = FindChild(Player,"RightHandBone") It's case sensitive. You can use it to retrieve bones or childs to animate them seperately or just to attach them some objects like swords. |
| ||
where do you get the name of the child entity though? |
| ||
In your modelling application where you named them or by iterationg through the childs using countChilds() etc |
| ||
so does the findchild become an entity that can be edited individually? |
| ||
It does if you go: L_Arm = FindChild(MyMesh,"LeftArm") Then you have a new entity of L_Arm which is parented to MyMesh |
| ||
that's what i'm doing but when i do any of rthe entity commands on it it says it doesn't exist. |
| ||
Then you looked for a child that did not exist or is not a child to this entity. Did you use LoadAnimMesh? LoadMesh will remove any hierarchy. |
| ||
Dreamora is right, I've been using LoadMesh as my boned meshes didn't have any animation, I was just using the bones for particle placement. So they didn't work until I find I had to use LoadAnimMesh command. By the way, use b3d viewer to see the bones in your mesh. It's way easier than anything else. Here is the b3d viewer; http://www.blitzbasic.com/Community/posts.php?topic=72765#813477 |
| ||
Kip I used to have issues with this as well and what the guys above saying is correct. findchild looks for the name of a joint on a mesh. Example If I create a model im Milkshape then the names in the model cannot be found as individual entities as Milkshape only exports a single ROOT entity. However if I add joints and name them logically. Like leftwrist then assign the relevant vertex`s to the joint I can use the findchild command to locate and work on this joint within code. You need to load the model with loadanimmesh then use Lwrist=findchild(modelname,"leftwrist"). You may need to use global infront if it is outside the main loop. Once this is done you should not get any errors. Next thing is to make sure any action performed on the joint is carried out after Updateworld and before Renderworld else it wont show. Hope this helps. |