Jump to content

Get entity in C++


Vulcan
 Share

Recommended Posts

Hi!

 

I recently encountered a problem when I tryied to get an entity based on its name. First I made a box in LE as "Box 1" in the scene list/graph. And I was trying to find the entity "Box 1" in C++ but for some reason it does not show up. I am not sure how to interact with this box otherwise.

 

list<Entity*>::iterator iter;
for (iter = world->entities.begin(); iter != world->entities.end();++iter)
{
fileLogger.Log("Entity: " + (*iter)->GetKeyValue("name"));
}

 

When looking through the log I don't find "Box 1" anywhere.

...
[21:13:39] Entity:
[21:13:39] Entity:
[21:13:39] Entity:
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: cardboardbox
[21:13:39] Entity: Directional Light 2
[21:13:40] Entity:
[21:13:40] Entity: BarbarianLDigit110
[21:13:40] Entity: BarbarianLFoot
[21:13:40] Entity: barbarian_knee_pad_L
[21:13:40] Entity: BarbarianLCalf
...

 

In LE scene graph there is "Directional Light 2", several "cardboardbox" and last "Box 1". Rest is loaded from C++.

I don't know what to do, please help!

Link to comment
Share on other sites

CSG gets collapsed with all the other CSG and you can't pull it out if this happens. There are 2 ways to prevent this collapse from happening and allow you to access the CSG. 1) Give it a mass 2) Attach a Lua script to it. If you don't want it to have a mass just make an empty entity script and attach it to the CSG and then you should be able to access it via your code.

Link to comment
Share on other sites

CSG gets collapsed with all the other CSG and you can't pull it out if this happens. There are 2 ways to prevent this collapse from happening and allow you to access the CSG. 1) Give it a mass 2) Attach a Lua script to it. If you don't want it to have a mass just make an empty entity script and attach it to the CSG and then you should be able to access it via your code.

Thank you! Adding mass did the trick.
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...