Code archives/3D Graphics - Mesh/TerrainY equivalent for mesh terrains

This code has been declared by its author to be Public Domain code.

Download source code

TerrainY equivalent for mesh terrains by PsychicParrot2003
Simple function to act as a 'terrainy()' for a mesh terrain (or any kind of mesh floor, I guess...) Make your mesh terrain pickable using entitypickmode - in the case of a terrain mesh, you'll use mode 3 for polygon.

use: terrainy=getmeshterrainy(entity)

So, whereas you pass in the x,y,z to terrainy() - here, you just pass in the name of the entity you want to check under. This function returns the first 'pickable' entity under the entity you pass in...

The main line:
pick=LinePick(EntityX(ent),EntityY(ent)+20,EntityZ(ent),0,-30,0)
has two numbers 20 and 30. This says "start looking for entities at entityy(entity)+20 and stop at -30. This 'projects' a line from above the entity to below it. Change these values to 'tune' to your own world sizes if you have any problems.
Function getmeshterrainy#(ent)

pick=LinePick(EntityX(ent),EntityY(ent)+20,EntityZ(ent),0,-30,0)
Return (PickedY())

End Function

Comments

None.

Code Archives Forum