User Tools

Site Tools


guides:compute-water-elevation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
guides:compute-water-elevation [2020/04/22 12:44] – created vjraymonguides:compute-water-elevation [2020/04/23 18:39] vjraymon
Line 1: Line 1:
-Custom component: how to compute ground or water elevation+====== Custom component: how to compute ground or water elevation ====== 
  
 Since 1.5, Foundation allows to mod Custom component and links it to a fbx (see Exemple02) Since 1.5, Foundation allows to mod Custom component and links it to a fbx (see Exemple02)
Line 5: Line 6:
 The following LUA code computes and returns the global Y elevation of water from a global position: The following LUA code computes and returns the global Y elevation of water from a global position:
  
- +<code lua> 
 function MY_CUSTOM_COMPONENT:computeWaterElevation(_globalPosition) function MY_CUSTOM_COMPONENT:computeWaterElevation(_globalPosition)
     local raycastResult = {}     local raycastResult = {}
Line 26: Line 27:
     end     end
 end end
 +</code>
  
 You can do the same with the ground by replacing OBJECT_FLAG.WATER by OBJECT_FLAG.GROUND You can do the same with the ground by replacing OBJECT_FLAG.WATER by OBJECT_FLAG.GROUND
  
-If the water (or the ground) is not found (for instance when the _globalPosition out of the map) then a warning is edited in the logs, and the code return the Y of the _globalPosition.+If the water (or the ground) is not found (for instance when the ''_globalPosition'' out of the map) then a warning is edited in the logs, and the code returns the Y of the ''_globalPosition''
 + 
 +This can be used, for instance, when moving an object on the ground or water whatever the slope (the water HAVEN'T the same elevation anywhere on a vanilla map !).
  
guides/compute-water-elevation.txt · Last modified: 2021/02/23 11:52 by minotorious

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki