Jump to content

GetChild()->GetKeyValue("name") Crashes Program


gamecreator
 Share

Recommended Posts

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.jpg.1a53c2a27aafe3fa01dac4e737eb4437.jpg
 

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

Link to comment
Share on other sites

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

 

  • Like 1

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...