der bastler 0 Posted February 4, 2003 I tried a simple script for vehicle-transport with helicopters: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _transporter = _this select 0 _transportobjekt = _this select 1 _laenge = _this select 2 #schleife01 _transppos = GetPos(_transporter) _transportobjekt SetPos [_transppos select 0,_transppos select 1,(_transppos select 2) - _laenge] ~0.01 ?(1==1): goto "schleife01" exit <span id='postcolor'> (just a simple first test -wanted to add some pendulum physics) but: the transported object is behaving like it's driving or rolling. Therefore it aligns to the terrain beneath which looks odd (a tank driving in the air) strange: I've a trailer-script made with GetPos/SetPos, but the trailed object stays perfectly horizontal aligned (and gets stucked in hills): </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;Anhängerskript für OFP _zugmaschine = _this select 0 _anhaenger = _this select 1 _abstand1 = _this select 2 _abstand2 = _this select 3 SKRIPTENDE = false #anh_schleife _zugmpos = GetPos(_zugmaschine) _zugmdir = GetDir(_zugmaschine) _anhpos  = GetPos(_anhaenger) _anhkupx = (_zugmpos select 0) - _abstand1 * Sin(_zugmdir) _anhkupy = (_zugmpos select 1) - _abstand1 * Cos(_zugmdir) _difanhx = _anhkupx - (_anhpos select 0) _difanhy = _anhkupy - (_anhpos select 1) ?(_difanhy == 0) && (_difanhx >= 0): _anhdir = 0 ?(_difanhy == 0) && (_difanhx < 0): _anhdir = 180 ?(_difanhy >= 0) && (_difanhx >= 0): _anhdir = atan(_difanhx / _difanhy) ?(_difanhy >= 0) && (_difanhx < 0): _anhdir = atan(_difanhx / _difanhy) ?(_difanhy < 0) && (_difanhx >= 0): _anhdir = atan(_difanhx / _difanhy) + 180 ?(_difanhy < 0) && (_difanhx < 0): _anhdir = atan(_difanhx / _difanhy) + 180 _anhkupx = _anhkupx - _abstand2 * Sin(_anhdir) _anhkupy = _anhkupy - _abstand2 * Cos(_anhdir) _anhaenger SetPos [_anhkupx,_anhkupy,(_anhpos select 2)+0.1] _anhaenger SetDir _anhdir ~0.01 ?(SKRIPTENDE): goto "ende" goto "anh_schleife" #ende exit <span id='postcolor'> The trailed object is not driving/rolling (wheels/tracks don't move). Why these differences? And is there a chance to use this effect for the trailer script? Share this post Link to post Share on other sites
der bastler 0 Posted February 4, 2003 A screenshot showing the effect. Share this post Link to post Share on other sites
Taurus 20 Posted February 4, 2003 der bastler I am no script expert, but i think you miss the getDir of the carrier(helicopter) like this: _x = (getPos _carrier) select 0 _y = (getPos _carrier) select 1 _z = (getPos _carrier) select 2 _cargo1 setPos [_x, _y, _z - 2] _cargo1 setDir (getDir _carrier) Share this post Link to post Share on other sites
Spitfire 0 Posted February 4, 2003 AFAIK, both setPos and setDir reset the pitch and roll of the vehicle, effectively "glueing" it to the horizon if used in a repeated loop. This has been the major gripe of scripting from the beginning. Especially the lack of functions capable of rolling objects around every axis. Share this post Link to post Share on other sites
der bastler 0 Posted February 4, 2003 Well, thanx. Hm, any workaround setting Dir without resetting pitch and roll? Share this post Link to post Share on other sites
Taurus 20 Posted February 5, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (der bastler @ Feb. 04 2003,20:42)</td></tr><tr><td id="QUOTE">Hm, any workaround setting Dir without resetting pitch and roll?<span id='postcolor'> Sir, what do you mean? SetPos alone made your M2A2 follow the terrain adding "SetDir" to it made it aligned (or glued as Spitfire said) with the horizon. You mean for the "towing" script or? Share this post Link to post Share on other sites
Liquid_Silence 0 Posted February 5, 2003 I have the same problem with my underslung cargo script, and I am using setDir as well...(and trig functions to set the cargo's position correctly under the helicopter...) Another problem with setPos'ing objects beneath a helicopter comes when you use BAS's MH47E...as it's (getPos select 2) is always close to zero, rather than giving it's actual height... (Fixed with a logic and the distance command...) The biggest problem with setPos'ing beneath a helicopter: The multilevel buildings in Nogova... Der Bastler: try your script at the airport in the desert area in the SW of Nogova...fly over one of the tall buildings at different height levels and notice the weird effect.... With more than one zero level stacked, you get an odd effect where the cargo jumps around...I have a compensator running with a camCreated trigger, to get a correction relative to sea level...but there's still one height level band that I can't correct the cargo for... I've completely rewritten my script and still can't find a solution that doesn't slow the script down immensely (and make ground collision detection impossible)... Share this post Link to post Share on other sites
Spitfire 0 Posted February 5, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Liquid_Silence @ Feb. 05 2003,05:39)</td></tr><tr><td id="QUOTE">With more than one zero level stacked, you get an odd effect where the cargo jumps around...I have a compensator running with a camCreated trigger, to get a correction relative to sea level...but there's still one height level band that I can't correct the cargo for...<span id='postcolor'> It's better to calculate the correction by making a trigger or gamelogic that moves around with the chopper, staying right underneath it with a looping setPos command. If you setpos it to an elevation of 0, it remains at the ground level, even when there is a multilevel building on that spot. Then, the height error the building is causing can be calculated by substracting the reported height of the helicopter from the distance of the helicopter and the trigger. If your reference point will stay put, you'll lose great deal of accuracy when you are far away from the reference point. Share this post Link to post Share on other sites
Liquid_Silence 0 Posted February 6, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Spitfire @ Feb. 05 2003,17:10)</td></tr><tr><td id="QUOTE">It's better to calculate the correction by making a trigger or gamelogic that moves around with the chopper, staying right underneath it with a looping setPos command. If you setpos it to an elevation of 0, it remains at the ground level, even when there is a multilevel building on that spot. Then, the height error the building is causing can be calculated by substracting the reported height of the helicopter from the distance of the helicopter and the trigger.<span id='postcolor'> Yeah, I'm using a camCreated trigger that is setPos'd to the helicopter every cycle (and since it's a trigger it's height is always sea level...) Basically the compensator works, but there is a certain height band it doesn't work in...(I wish BIS had chosen a different way of detecting walkable surfaces...) I am currently using a compensator that runs once a cycle, but I may have to use a looping compensator. I am still running a few tests to see the best way of doing this, 'cause I don't want to slow down the script too much. Progress is slow, 'cause I'm also working on a campaign I'm very interested in any information anyone discovers about the vehicle tilting thing, as this is another thing I'm gonna have to fix before my script is usable... Share this post Link to post Share on other sites
Prospero 1 Posted February 6, 2003 I posted a "floor enumerator" script which may help you - the whole point of the script was to attempt to get round such problems. Best I can offer, anyway. You may need more than one gamelogic. At least, that was my conclusion at the time. Try a search on "floor enumerator" in this forum. Should work. Prospero Edit: As for tilting with the terrain, you're stuck with it (unless you loop your setDir) depending on the simulation-type of the vehicle in question. I once tried camcreating an invisible dummy object with a "level" roadway LOD directly underneath the vehicle in question to prevent it from following the attitude of the terrain. No go. Actually this was part of my "let's try to get this object to pitch and roll" schtick. Needless to say, it didn't work. Share this post Link to post Share on other sites
Spitfire 0 Posted February 6, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Prospero @ Feb. 06 2003,20:55)</td></tr><tr><td id="QUOTE">You may need more than one gamelogic. At least, that was my conclusion at the time.<span id='postcolor'> Yes, I agree, though I haven't seen your floor enumerator script yet. I've done two scripts myself, one by making a single gamelogic moving with the unit. Then I made another one using 4 objects placed in different parts of the map near the waterline, and using the nearest one as a reference object to calculate the absolute height of any other unit or object. I estimated that using those 4 objects won't produce an error larger than 10 cm at most. Share this post Link to post Share on other sites
Liquid_Silence 0 Posted February 7, 2003 Spitfire: just use a camCreated trigger </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sea_level = "emptyDetector" camCreate [0,0,0] #loop _sea_level setPos (getPos chopper) chopper_height_asl = _sea_level distance chopper ~0.01 if (alive chopper) then {goto "loop"}<span id='postcolor'> would update "chopper_height_asl" every 0.01 sec with the height asl of the chopper, as the camCreated trigger doesn't ever change its height from sea level... I just camCreate a global trigger at the beginning of my script, and use it for all choppers that have cargo ropes (+ anything else requiring height above sea level readings) EDIT: Prospero: I'm having a look at the script. From the look of it, it's gonna be helpful Um, its the one from the thread titled "floor enumerator demo" or something like that, right? Share this post Link to post Share on other sites
Prospero 1 Posted February 7, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Liquid_Silence @ Feb. 07 2003,01:22)</td></tr><tr><td id="QUOTE">EDIT: Prospero: I'm having a look at the script. From the look of it, it's gonna be helpful Um, its the one from the thread titled "floor enumerator demo" or something like that, right?<span id='postcolor'> yup Edit: Looking back, that script could be made considerably faster but, hey, I wasn't that concerned with speed at the time. My excuse and I'm sticking to it. Share this post Link to post Share on other sites
Dschulle 0 Posted February 7, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Liquid_Silence @ Feb. 07 2003,01:22)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sea_level = "emptyDetector" camCreate [0,0,0] #loop _sea_level setPos (getPos chopper) chopper_height_asl = _sea_level distance chopper ~0.01 if (alive chopper) then {goto "loop"}<span id='postcolor'><span id='postcolor'> I'm a bit surprised, that the script worked. Since I did it like this and had to change the setpos line to: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sea_level setPos [(getPos chopper)select 0, (getPos chopper)select 1, 0]<span id='postcolor'> otherwise sometimes the distance was 0! Add. using: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">chopper_height_asl = (getpos chopper select 2) -(getpos _sea_level select 2)<span id='postcolor'>might be more precise. Share this post Link to post Share on other sites
Spitfire 0 Posted February 7, 2003 Liquid_Silence, my script with a moving gamelogic isn't meant to measure the mean sea level, it is to measure the height of some obstacles (buildings with elevated surfaces). The other script with four game logics, however, is meant to estimate the mean sea level and now that I think about it, using the trigger thinga would work better. Share this post Link to post Share on other sites
Liquid_Silence 0 Posted February 8, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Dschulle @ Feb. 07 2003,13:23)</td></tr><tr><td id="QUOTE">I'm a bit surprised, that the script worked. Since I did it like this and had to change the setpos line to: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sea_level setPos [(getPos chopper)select 0, (getPos chopper)select 1, 0]<span id='postcolor'> otherwise sometimes the distance was 0! Â Add. using: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">chopper_height_asl = (getpos chopper select 2) -(getpos _sea_level select 2)<span id='postcolor'>might be more precise.<span id='postcolor'> hmmm...I'll change mine accordingly. I haven't had any problems with it so far, but better to be safe than sorry About the distance thing: a) Distance seems to be perfectly accurate at reasonably short distances...I haven't tested it though, so you may be right... b) this would require a slower workaround for BAS's MH47E...since all getPos chopper select 2 does on that is return close to zero...my way works for all choppers without specifying which you're using... Share this post Link to post Share on other sites
Prospero 1 Posted February 9, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Liquid_Silence @ Feb. 08 2003,07:18)</td></tr><tr><td id="QUOTE">a) Distance seems to be perfectly accurate at reasonably short distances...I haven't tested it though, so you may be right...<span id='postcolor'> No. It doesn't matter if the distance between your objects is small. What matters is where they are on the map. The distance command uses the absolute locations of objects to determine the distance between them. Hence, if they're both top right corner (like about 10,000m for y and 10,000m for x), you're going to get significant rounding error, regardless of how close they are to each other. This problem is internal to the function. I came up with that trigger method for determining height ASL (i.e. without using the distance command AT ALL) especially to get round this problem. Prospero Share this post Link to post Share on other sites
Prospero 1 Posted February 24, 2003 oops wrong thread;) Share this post Link to post Share on other sites