Page 2 of 2

Re: Some water movement tag related criticism

Posted: 01 Oct 2015, 00:22
by 8611z
I understand that solution a would be a gadget, with lots of overhead, yes?
You can use Spring.XXX functions in unitscripts, too.
(If you need unitID as parameter, the unitID of the unit which runs the script is already stored in a variable named "unitID")
Something like

Code: Select all

script.Create()
  StartThread (waterCheck)
end

function waterCheck()
while (true) 
  local x,y,z = Spring.GetUnitPosition(unitID)
    groundHeight = Spring.GetGroundHeight(x,z)
    if groundHeight < 0 then --water always at y==0
     ...is on water...
     else
     ...on land...
Sleep (100)
end
setSFXoccupy() gets called when unit drives from "terrain type" to another. For example from land into water.
Make testscript and look what it outputs when you drive around.

Code: Select all

function script.setSFXoccupy (terrainType)
	Spring.Echo (terrainType)
end
UnitEnteredWater/UnitLeftWater would be gadget, yes.

I do not understand what you are doing with "hovers that can move underwater"...