DanielW Posted June 28, 2012 Share Posted June 28, 2012 Hi Can anyone explain me how i can get the Terrain Entity out of my Scene in C++ ? Regards Daniel Quote Link to comment Share on other sites More sharing options...
Canardia Posted June 28, 2012 Share Posted June 28, 2012 It's the first entity, so GetChild(scene,0) will return the terrain entity. You can also use FindChild("terrain"), but it's slower. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DanielW Posted June 28, 2012 Author Share Posted June 28, 2012 when i use GetChild(scene,0) my game quits and FindChild(scene,"terrain") is not finding anything Quote Link to comment Share on other sites More sharing options...
Canardia Posted June 28, 2012 Share Posted June 28, 2012 I just looked at gamelib, and there I get the terrain in 3 steps: e=GetChild(scene,i); ... cl=GetEntityKey(e,"class"); ... if( cl=="Terrain" ) { // printf("******** FOUND TERRAIN ********\n"); terrain = e; SetEntityKey(e,"status","handled"); } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DanielW Posted June 28, 2012 Author Share Posted June 28, 2012 Ok have tryed this: TTerrain terrain; TEntity scene=LoadScene("scene/scene1.sbx"); int i; for(i=0;i<CountChildren(scene);i++) { TEntity e = GetChild(scene,i); str cl = GetEntityKey(e,"class"); if(cl=="Terrain") { terrain = e; SetEntityKey(e,"status","handled"); } } when i try to debug its still quits while its loading Quote Link to comment Share on other sites More sharing options...
Rick Posted June 28, 2012 Share Posted June 28, 2012 Make sure you scene variable is valid. I normally use the abstract system like "LoadScene("abstract::scene1.sbx") and scene 1 can be anywhere in your game dir and it'll find it and load it. Quote Link to comment Share on other sites More sharing options...
Canardia Posted June 28, 2012 Share Posted June 28, 2012 Use string, not str for cl. str is just unsigned char*, and does not support == comparison. I recommend to copy paste shamelessly any code from gamelib, because it just works and is tested. If you can do it better, please do so, but it won't be tested, unless you test it yourself Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DanielW Posted June 29, 2012 Author Share Posted June 29, 2012 its still dont working when i delete GetChild elverything Loads but with it it starts Loading elveryting and then quits whitout any message or error. didnt know of the gamelib in the assetstore will give it a look thanks edit: in my scene i have only the Terrain an Atmosphere and light do i need there something more ? Quote Link to comment Share on other sites More sharing options...
DanielW Posted June 29, 2012 Author Share Posted June 29, 2012 k have found the Problem GetChild should start at 1 not at 0. thanks for the help ^^ 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.