YouGroove Posted June 8, 2013 Share Posted June 8, 2013 Anyone has some C++ example to loop throught all entities existing in some loaded Map ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted June 8, 2013 Share Posted June 8, 2013 http://www.leadwerks.com/werkspace/page/tutorials/_/map-loading-and-getting-entities-r44 Modify this to save each Entity in the callback to a list and then you can loop through that list after Map::Load(). Quote Link to comment Share on other sites More sharing options...
YouGroove Posted June 8, 2013 Author Share Posted June 8, 2013 I don't understand very well your example. And i don't want callback. In fact i place NPC characters entities in the editor. And loading the map by code, i would need to find where are the entities placed in the level in the editor, and drive them by code in C++. like LoadMap init () { -> load map TableEntities = find All Entites characters on loaded Map } Load Map loop { For each Entity on table (){ entity.update(); } I mean more simple code, and just managing entities on a loaded map on some array or table. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted June 8, 2013 Share Posted June 8, 2013 You have to use a callback at this time to loop over the entities loaded in your map. This callback is fired each entity when you call Map:Load. You can then process them in the callback or store them in an array/list and loop over them at a later time. Your other option is to use the individual entity scripts attached to each entity and handle all your game logic there. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted June 8, 2013 Author Share Posted June 8, 2013 Ok i found by reading again the tutorial comments. You need to attach some empty script even for models to have them finded in the Map at loading. And it's to you to manage to load them by their name, they won't be loaded with map loading. Other engines load the models you have placed, why LE3 don't do that I can't imagine the workflow, having to do that for 20 different characters you have to place. You will need to create them by code by their name, and on editor each time not forget to attach some script at level creation. Let's hope LE3 to grow up instead on relying on LE2 system too much. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
beo6 Posted June 8, 2013 Share Posted June 8, 2013 You only need to use that workaround for CSG Level Geometry that you want to access in code. All other entities are accessible straight away. Also nothing against Ricks tutorial but the save and load tutorial by Aggror is a bit more complete in that part. including a full list of all entities in your map. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted June 8, 2013 Author Share Posted June 8, 2013 Sorry beo6, but characters don't load when you just call the loadmap function in C++. And other non animated models load automatically. Any models placed in the map should be auto loaded like any engine. Quote Stop toying and make games 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.