Detecting unit depth in water.
Posted: 27 Dec 2010, 08:28
So I want to do some cool stuff with animation but I need a way to tell if the unit is underwater or even better the specific unit depth in the water. Now, I am currently using:
Fun shit is that the head hides as soon as the toe touches the water. Also sfx occupy doesn't seem to to trigger except when the unit enters or leaves and fun shit is that the getwater height even though it is printing shit like:

So maybe I need to be doing this different. I am not against setting up a gadget to test when units are in the water and then checking unit depth(assuming such a thing is possible) however, I wanted to ask around.
Here is what I am going to try and do. Effectively, I want to detect when a unit reaches a specific depth(this is an amphibious unit) at this point in time the unit will switch over to a swim mode animation with speed boost. However, AS IT stands now I can only pick up in or out of water, rather silly and sadly kind of stupid. So I was hoping someone here may have some idea. There are no examples of such a thing in spring and before someone says pelican, that is a hover unit and it doesn't have to check actual depth.
Code: Select all
setSFXoccupy(setSFXoccupy_argument)
{
terraintype = setSFXoccupy_argument;
if(terraintype == 2)
{
SET MAX_SPEED to [4];
speedMult = 5;
}
else
{
SET MAX_SPEED to [1.0];
speedMult = 2.5;
}
get PRINT(get GROUND_WATER_HEIGHT(get PIECE_XZ(base)));
if(get GROUND_WATER_HEIGHT(get PIECE_XZ(base)) <= -50000)
{ hide head; }
else
{ show head; }
}
the head hides as soon as the unit touches water[ 326] Value 1: 431640, 2: 0, 3: 0, 4: 0
[ 336] Value 1: 431640, 2: 0, 3: 0, 4: 0
[ 592] Value 1: -38516, 2: 0, 3: 0, 4: 0
[ 608] Value 1: -938666, 2: 0, 3: 0, 4: 0
[ 768] Value 1: -173538, 2: 0, 3: 0, 4: 0
[ 800] Value 1: -61020, 2: 0, 3: 0, 4: 0
[ 928] Value 1: -151035, 2: 0, 3: 0, 4: 0

So maybe I need to be doing this different. I am not against setting up a gadget to test when units are in the water and then checking unit depth(assuming such a thing is possible) however, I wanted to ask around.
Here is what I am going to try and do. Effectively, I want to detect when a unit reaches a specific depth(this is an amphibious unit) at this point in time the unit will switch over to a swim mode animation with speed boost. However, AS IT stands now I can only pick up in or out of water, rather silly and sadly kind of stupid. So I was hoping someone here may have some idea. There are no examples of such a thing in spring and before someone says pelican, that is a hover unit and it doesn't have to check actual depth.