Jump to content
Sign in to follow this  
Master_Chief

Setpos and hasl detection...

Recommended Posts

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

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

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

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

Yeah thats what I was doing, however another part of the script was interfering and now it works perfectly smile_o.gif

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×