Jump to content

Finding the root object


juur
 Share

Recommended Posts

This is probably a dumb question, but how can I search for a random entity by name when I don't know it's parent?

 

Is there a way to do root:FindChild() ? If so, how do I get the 'root' entity?

 

On the documentation page for World it has

  • std::list<Entity*> entities

 

But I can't figure out how to access this from Lua.

 

I have a number of different cameras, as childs to different entities, and I need to find the Camera entity so I can switch cameras. The cameras are not created in code so I have no handle.

Link to comment
Share on other sites

I wouldn't use multiple cameras as who knows what a pain will happen there. I'd use pivots as location/rotation markers and just move your 1 camera around to those pivots. I think an "unsupported" way is world:FindEntity(""). Not sure what it'll do if the same name exists with more than 1.

Link to comment
Share on other sites

Thanks Rick, that does the trick and I agree multiple cameras is probably a bad thing.

 

There also doesn't seem to be an API for the current camera either, the App.camera field indicated here isn't populated, are all the C++ style members in the documentation invalid for Lua?

Link to comment
Share on other sites

maybe this help you

 

World.ForEachEntityInAABBDo

PC : Win 10 Pro 64 Bit , 4x cores ~2 GHz , 8 GB RAM , AMD R7 265

2D : Photoline , Zooner Photo Studio 13 , Art Rage Studio 3.5.4 , Ashampoo Snap 7 , ...

3D : Shade 15 Basic , Carrara 8.5 & DAZ Studio 4.8 , Cheetah 3D 6.3.2 , Via Cad 8

Music : Samplitude Music Studio , Music Creator 7

IDE : Leadwerks Engine 3.x , Unity 5.x , (Unreal 4.8.x) , AGK v2.x , Construct 2 , (Clickteam Fusion 2.5) , ShiVa 1.9 , Game Maker Studio , MS Visual Studio .Net , Android Studio , Monkey , ...

Link to comment
Share on other sites

Not sure I follow? I can't see anything about entities on the page for the Camera class.

maybe this help you

 

World.ForEachEntityInAABBDo

A bit of a hack but could work. Doesn't feel right to be (ab)using that sort of feature for such a basic 'global search' feature.

Link to comment
Share on other sites

You can also do this (not supported tho) :

 


-- Get world

self.world=World:GetCurrent()

 

--Find camera by looping over every entity in self.world:

if self.camera==nil then

for i=0,self.world:CountEntities()-1 do --CountEntities is not a supported command

if self.world:GetEntity(i):GetClass()==Object.CameraClass then

self.camera=self.world:GetEntity(i) --GetEntity is not a supported command

tolua.cast(self.camera,"Camera")

System:Print(self.world:GetEntity(i):GetClassName())

break

end

end

end

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

<snip>

I still have no idea what you're getting at, sorry. I know how to open the page on Camera, and I know Camera is derived from Entity, but how does that help?

 

I still have no idea what you're getting at, sorry. I know how to open the page on Camera, and I know Camera is derived from Entity, but how does that help?

Ahh, I meant there is no way (or i can't find one) of *getting the current camera* not *the camera isn't documented*

Link to comment
Share on other sites

recursive GetParent should also bring you to root item from any entity, but i not tested myself.

PC : Win 10 Pro 64 Bit , 4x cores ~2 GHz , 8 GB RAM , AMD R7 265

2D : Photoline , Zooner Photo Studio 13 , Art Rage Studio 3.5.4 , Ashampoo Snap 7 , ...

3D : Shade 15 Basic , Carrara 8.5 & DAZ Studio 4.8 , Cheetah 3D 6.3.2 , Via Cad 8

Music : Samplitude Music Studio , Music Creator 7

IDE : Leadwerks Engine 3.x , Unity 5.x , (Unreal 4.8.x) , AGK v2.x , Construct 2 , (Clickteam Fusion 2.5) , ShiVa 1.9 , Game Maker Studio , MS Visual Studio .Net , Android Studio , Monkey , ...

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...