Master_Chief 0 Posted September 24, 2004 I need to setpos an object onto the ocean's surface, and I need it to work even when the object is on land. I figured out the height above sea level to calculate how far below 0 i need to place the object so it lines up with the ocean. btw I used the 'emptydetector and distance to a gamelogic' technique that I have used before. However, it just doesn't work. the object is either to far above or below the water and its z position increase exponentially when the object moves up a hill. Can someone help me out? Share this post Link to post Share on other sites
Guest [B.B.S.] T_D Posted September 24, 2004 highNN.sqf by Dax <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_obj1","_obj2","_P1","_P2","_dis"]; _obj1 = _this select 0; _obj2 = _this select 1; _P1 = getPos _obj1; _P2 = getPos _obj2; _dis = sqrt(((abs((_P1 select 0)-(_P2 select 0)))^2)+((abs((_P1 select 1)-(_P2 select 1)))^2)); _dis = sqrt (abs(((_obj1 distance _obj2)^2)-(_dis^2)))-1000; if(_dis<0)then{_dis=0}; _dis Put an Empty HeliH on the map call it NN and set its height -1000. preload the function: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">highNN = preprocessfile "highNN.sqf" to get the absolute high you have to write this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_absZ = [NN,object] call highNN object is the object you want to know the high of. Share this post Link to post Share on other sites
Master_Chief 0 Posted September 24, 2004 it creates the same problem Share this post Link to post Share on other sites
Unnamed_ 0 Posted September 25, 2004 I use this function by Vektorboson, see it thats any better? Just call it with an XYZ position. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Private ["_currpos","_result","_sensor"]; _CurrPos = _This Select 0; _Result=0; _sensor = "EmptyDetector" createVehicle [0,0,0]; _Sensor SetPos [_CurrPos Select 0,_CurrPos Select 1,0]; _Result=(GetPos _Sensor ) select 2; DeleteVehicle _Sensor; Abs(_Result) Share this post Link to post Share on other sites
T J 0 Posted September 27, 2004 The sea level varies hour to hour, day to day. You need to detect the difference as you have seen between something static on the ocean floor as it were (EMPTYDETECTOR) and somnething which lies on the surface of the ocean/ground (invisible H) Update this as regular as possible to coincide with the tides. Then you can check if the object is on ground, and adjust the maths accordingly to set to the correct position. A long time ago I demonstrated that exactly this was possible, and made a video to show rotorwash from a helicopter being affected by the tides. Stick at it, you'll get there. TJ Share this post Link to post Share on other sites
Junker 0 Posted September 28, 2004 cant u place an empty boat in the top corner and get is level Share this post Link to post Share on other sites
Master_Chief 0 Posted September 28, 2004 Yeah thats what I was doing, however another part of the script was interfering and now it works perfectly edit ------ BTW, it seems that gamelogics don't actually float on the water, so they don't give an accurate reading of the height above sea level Share this post Link to post Share on other sites