Jump to content

TerrainElevation


Clackdor
 Share

Recommended Posts

I want to use the TerrainElevation() function.

 

flt TerrainElevation( TEntity terrain, flt x, flt y )

 

If I have loaded a map using

 

TEntity scene = LoadScene("abstract::pacman.sbx");

 

How do I access the TEntity terrain reference required as an argument for TerrainElevation?

Link to comment
Share on other sites

I appreciate the answer. Haven't put it in my code yet, but, how did you know that it was the 0 child? I figured it would be a GetChild or FindChild function. I spent about an hour though assuming that I couldn't know the child order, looking for the name of the terrain to use FindChild.

Link to comment
Share on other sites

It's always child 0, unless it has been changed. I think also FindChild(scene,"terrain") works, and should be used to ensure future compatibility.

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 ■

Link to comment
Share on other sites

Ok, so neither of those is working. In the case of GetChild, I get a reference, but the TerrainElevation function causes a crash, which tells me that it is not returning a TTerrain type, but a different entity. If the case of FindChild, the reference is null, so I'm thinking that "terrain" isn't the correct name to be searching for.

Link to comment
Share on other sites

I don't have your answer but I'm pretty sure you can't search for a child of a scene. I think that once a scene is created it doesn't have a context any more. But I'm not sure I just recall hearing that somewhere.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Well this works for me:

 

for (i = 1; i <= childCount; i++)
{
               newChild = GetChild(child,i);
	newChildCount = CountChildren(newChild);
	if(newChildCount>0) processChildren(newChild);

	// Get the terrain entity
	childClass = GetEntityKey(newChild, "class","");
	if(childClass ==  "Terrain")
	{
		terrain = newChild;
	}

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

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