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.
WaterCheck() { var GroundHeight; while(TRUE) { GroundHeight=get GROUND_WATER_HEIGHT(get PIECE_XZ(hull)); if (GroundHeight<=FLOAT_DEPTH) { bFloating = TRUE; move hull to y-axis FLOAT_DEPTH speed [5]; turn hull to x-axis 0 speed <90>; turn hull to z-axis 0 speed <90>; if(bMoving) { emit-sfx SFXTYPE_WAKE1 from wake; } set MAX_SPEED to WaterSpeed; set UPRIGHT to 1; } else { bFloating = FALSE; if (GroundHeight<0) { move hull to y-axis GroundHeight now; } else { move hull to y-axis [0] now; } set MAX_SPEED to LandSpeed; set UPRIGHT to 0; } sleep 150; } }
The unit is a vehicle, and upon reaching certain depth, it "floats up": wheels no longer touch the bottom, it becomes upright and gets much lower speed (too bad I can't make it stop leaving tracks on the bottom). WaterCheck() is started from Create().
This works reliably as far as I can tell. It can be optimized of course, for example setSFXOccupy might be used to disable the looping check when unit is out of the water and enable it again when it enters the water. Not that there is any noticeable performance loss with dozens of that unit on a map as it is.
And technically my vehicle is a hover, because there is no other (simple) way to make it float on the water surface. However upright=0 hovers behave like vehicles on land.
sanada, I will tell you what one of my programming instructors once told me.
Never be afraid to ask, odds are someone has already solved the problem and you will likely waste a lot of time in redundant effort when you simply could have asked.
You can check out the shiva in BAR (look for "Swimming Animation") Or find the skeleton script from the Cursed, which the shiva script is based on, regarding changing behaviour in water.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum