gamecreator Posted February 1, 2018 Share Posted February 1, 2018 I'm open to doing something wrong here but this seems like it should work. I imported an FBX with two textured boxes and two collisionhulls for them. It loads fine, displays fine. However, when I try to print the names of the objects, only the collisionhulls work. The other two crash the program. Files attached. Code below. As you can see, the two collisionhulls provide the names properly but the models themselves (children 0 and 3) do not. room=Model::Load("Models/world/room.mdl"); printf("\n\nchildren: %d\n\n", room->CountChildren()); // Returns 4 printf("name: %s\n",room->GetChild(0)->GetKeyValue("name")); // Will crash program printf("name: %s\n",room->GetChild(1)->GetKeyValue("name")); printf("name: %s\n",room->GetChild(2)->GetKeyValue("name")); printf("name: %s\n",room->GetChild(3)->GetKeyValue("name")); // Will crash program world.zip Quote Link to comment Share on other sites More sharing options...
Rick Posted February 1, 2018 Share Posted February 1, 2018 Are you sure it’s the names causing the crash vs the children coming back as null? So trying to call a function on a null object would cause the crash. 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted February 1, 2018 Author Share Posted February 1, 2018 Gave it a shot with the following. None of the four printed. if(room->GetChild(0)==NULL) printf("NULL0\n"); if(room->GetChild(1)==NULL) printf("NULL1\n"); if(room->GetChild(2)==NULL) printf("NULL2\n"); if(room->GetChild(3)==NULL) printf("NULL3\n"); Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 1, 2018 Share Posted February 1, 2018 This lua code works: function Script:Start() System:Print("Model Name: "..self.entity:GetKeyValue("name")) local children = self.entity:CountChildren() for i = 0, children-1 do System:Print("Child "..i.." Name: "..self.entity:GetChild(i):GetKeyValue("name")) end end 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
gamecreator Posted February 1, 2018 Author Share Posted February 1, 2018 Thanks macklebee. That gave me an idea which turned out to be what I needed. I needed to use cout instead of printf because GetKeyValue returns a std::string. I'm not sure why the two collision hulls worked with a char * and the models didn't but probably just coincidence. This can be closed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.