Jump to content

Recommended Posts

Posted

Hello,

i was playing arround a little bit with C++, and i had problems with selecting the terrain.

This is my code:

TEntity cScene = LoadScene("abstract::test2.sbx");
ScaleEntity(FindChild(cScene,"Terrain"), Vec3(1,1,1));

 

Does some one know, what is my problem?

 

greats

Posted

I think FindChild is looking for the "name" key, and not the "class" key.

GameLib gets the terrain entity correctly by looking for "class"=="Terrain".

If you don't want to use GameLib, you could just copy the function GetFirstEntityByKey(key,value) from it, and use it as: terrain = GetFirstEntityByKey("class","Terrain");.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

I Also thought about that,

but every time when i test it, it was the last chil.

 

But, i have one more question, why does this two ways to get the terrain height doesn´t work:

First Way:

VObject::kiObject->Y = TerrainHeight(cTerrain, kiObject->X*2,kiObject->Y*2); // 2 is the Meter per tile

 

Second way:

	if(LinePick(&cPick, Vec3(kiObject->X,kiObject->Y,kiObject->Z), Vec3(kiObject->X,kiObject->Y-10,kiObject->Z), 5))
	{
		kiObject->Y = cPick.Y;
		std::cout << cPick.Y << std::endl;
	}

 

Can some one help me?

 

 

greats

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.

×
×
  • Create New...