callihn 10 Posted September 8, 2010 (edited) I'm trying to use the C130 for a paradrop but the crazy pilot dives below the start height and then back up to it, I have the chopper spawned at the correct height and have also set flyin height but as soon as right after the player gets in he dives strait down and then comes back up to the correct height, most of the time aside from looking completely stupid it's not a problem, however sometimes he crases into the hillside because of it, how do I stop this awkward behavior please? _transport = createVehicle [_transportVehicle, _transportSpawn, [], 0, "FLY"]; _transport setpos [_transportSpawn select 0,_transportSpawn select 1, d_halo_height]; if (_randomNum < 1) then { _transport setDir 0; }else{ _transport setDir 180; }; _transport engineon true; _transport flyInHeight d_halo_height; _transport lock false; switch (X_Drop_Side) do { case "WEST": { _pilot = d_pilot_W; }; case "GUER": { _pilot = d_pilot_G; }; case "EAST": { _pilot = d_pilot_E; }; case "CIV": { _pilot = "Civilian"; }; }; _grp = [X_Drop_Side] call x_creategroup; _unit = _grp createUnit [_pilot, _jumpPos, [], 0, "NONE"]; _unit moveInDriver _transport; __addDead(_unit); __addDead(_transport); _unit setSkill 1; [_unit] join _grp; _unit setCaptive true; _delTransport = { private ["_unit","_transport","_grp"]; _unit = _this select 0; _transport = _this select 1; _grp = _this select 2; deleteVehicle _transport; deleteVehicle _unit; transportAvailable = true; deleteWaypoint [_grp, 0]; deleteWaypoint [_grp, 1]; deleteWaypoint [_grp, 2]; deleteWaypoint [_grp, 3]; deleteWaypoint [_grp, 4]; }; removeAllWeapons _transport; _wp = _grp addWaypoint [_transportSpawn, 0]; _wp setwaypointtype "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointSpeed "FULL"; player moveInCargo [_transport,20]; To clarify this does not seem to have anything to do with targeting as there is nothing to target. Think I fixed it, looks like it was falling backward and down from it's spawn, so I made some changes: _transport = createVehicle [_transportVehicle, _transportSpawn, [], 0, "FLY"]; _transport engineon true; _transport flyInHeight d_halo_height; _transport forceSpeed 150; _transport setpos [_transportSpawn select 0,_transportSpawn select 1, d_halo_height]; if (_randomNum < 1) then { _transport setDir 0; }else{ _transport setDir 180; }; _transport lock false; switch (X_Drop_Side) do { case "WEST": { _pilot = d_pilot_W; }; case "GUER": { _pilot = d_pilot_G; }; case "EAST": { _pilot = d_pilot_E; }; case "CIV": { _pilot = "Civilian"; }; }; _grp = [X_Drop_Side] call x_creategroup; _unit = _grp createUnit [_pilot, _jumpPos, [], 0, "NONE"]; _unit moveInDriver _transport; __addDead(_unit); __addDead(_transport); _unit setSkill 1; [_unit] join _grp; _unit setCaptive true; _delTransport = { private ["_unit","_transport","_grp"]; _unit = _this select 0; _transport = _this select 1; _grp = _this select 2; deleteVehicle _transport; deleteVehicle _unit; transportAvailable = true; deleteWaypoint [_grp, 0]; deleteWaypoint [_grp, 1]; deleteWaypoint [_grp, 2]; deleteWaypoint [_grp, 3]; deleteWaypoint [_grp, 4]; }; removeAllWeapons _transport; _wp = _grp addWaypoint [_transportSpawn, 0]; _wp setwaypointtype "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointSpeed "FULL"; player moveInCargo [_transport,20]; Take that back, this is crazy, WTH is wrong with this game? You can find the latest version of the entire script here: http://forums.bistudio.com/showpost.php?p=1736011&postcount=15 Looks like it happens when the transport is spawned north of the jump, still working on it. Edited September 8, 2010 by callihn Share this post Link to post Share on other sites
kylania 568 Posted September 8, 2010 Either spawn it where the dip won't cause it to crash or set it's velocity from the start so it's moving when the pilot gets in instead of falling. Share this post Link to post Share on other sites
callihn 10 Posted September 8, 2010 (edited) Either spawn it where the dip won't cause it to crash or set it's velocity from the start so it's moving when the pilot gets in instead of falling. Thanks, I was looking for speed and not velocity, just another example of how searching is of little help when you know not what you seek. Sadly it is still decending, but again from the northern approuch only, updated the other post to reflect the resent changes. Seems the setDir has something to do with it, though it's worse without it for sure, also regardless of direction setVelocity seems to be getting ignored for the most part. Edited September 8, 2010 by callihn Share this post Link to post Share on other sites
twirly 11 Posted September 17, 2010 This should also work if used right after the creating the plane.... _speed = speed _ride; _ride setVelocity [sin(_dir)*_speed/3.6,cos(_dir)*_speed/3.6,0]; Share this post Link to post Share on other sites
callihn 10 Posted September 17, 2010 Honestly, I don't know why it would, have you tested it? Share this post Link to post Share on other sites
f2k sel 164 Posted September 17, 2010 So you never did find a fix? Somebody else was having an odd problem the other day where the aircraft would spawn and the pilot was in the plane but the plane would still crash. The odd part was that sometimes it didn't and it had nothing to do with speed, for some reason the pilot wouldn't start the engines. The fix in this case was easy _pilot action ["engineOn", vehicle _pilot]; in you mission try _unit action ["engineOn", _transport _unit]; placed after the units have spawned and placed in the aircraft it might work. Also check if the pilot is in the pilot seat . Share this post Link to post Share on other sites
callihn 10 Posted September 17, 2010 Nope the script is in the mission but it's not being used because of this, of course he is in the pilot seat, how else would it climb. ;) I dunno I might try that sometime. Share this post Link to post Share on other sites
f2k sel 164 Posted September 17, 2010 This should also work if used right after the creating the plane...._speed = speed _ride; _ride setVelocity [sin(_dir)*_speed/3.6,cos(_dir)*_speed/3.6,0]; That should work, when you use setpos to position the aircraft it stalls it, adding velocity gives it it's speed back. Share this post Link to post Share on other sites
twirly 11 Posted September 17, 2010 That should work, when you use setpos to position the aircraft it stalls it, adding velocity gives it it's speed back. Yes it does work....gives back the velocity. Been using it for a very long time. It is a nice solution. Share this post Link to post Share on other sites
callihn 10 Posted September 22, 2010 (edited) Thanks, tested both suggestions and neither helped, so no it doesn't work. Edited September 22, 2010 by callihn Share this post Link to post Share on other sites
kylania 568 Posted September 22, 2010 You need to set velocity in the direction of flight, which involves trigonometry and makes Baby kylania cry. I remember seeing an example of it once before, but can't remember where. :) If I find it again I'll post it here. Actually, twirly's solution above might be it. :) Share this post Link to post Share on other sites
twirly 11 Posted September 22, 2010 You need to set velocity in the direction of flight, which involves trigonometry and makes Baby kylania cry. I remember seeing an example of it once before, but can't remember where. :) If I find it again I'll post it here.Actually, twirly's solution above might be it. :) Please try it.....it works in many many scenarios I have made. It nearly drove me nuts trying to find a solution. Share this post Link to post Share on other sites
kylania 568 Posted September 22, 2010 In testing every time I used it I crashed, since it was setting my speed to 0... :eek: Share this post Link to post Share on other sites
twirly 11 Posted September 22, 2010 In testing every time I used it I crashed, since it was setting my speed to 0... :eek: _ride = createVehicle [_veh, _vehpos, [], 0, "FLY"]; _crew = createGroup EAST; _driver = _crew createUnit ["RU_Soldier_Pilot",[0,0,30], [], 0, "NONE"]; _speed = speed _ride; _ride setVelocity [sin(_dir1)*_speed/3.6,cos(_dir1)*_speed/3.6,0]; _driver assignAsDriver _ride; _driver moveInDriver _ride; This works a charm for me! Always! I think I remember having trouble with the order of the commands.....that's why the order is strange. Share this post Link to post Share on other sites
kylania 568 Posted September 22, 2010 Ahh, I see, you're not declaring _dir1 in that example, so it's 0. That's setting the velocity down to 0 too! Change _dir1 to getDir _ride and it's smooth sailing! Share this post Link to post Share on other sites
twirly 11 Posted September 22, 2010 OK...I missed that or would have tried my best to make it make more sense! All good now? Share this post Link to post Share on other sites
Evil_Echo 11 Posted September 22, 2010 (edited) You need to set velocity in the direction of flight, which involves trigonometry and makes Baby kylania cry. I remember seeing an example of it once before, but can't remember where. :) If I find it again I'll post it here.Actually, twirly's solution above might be it. :) I wrote functions long ago that allowed for proper rotation of axis. It uses tensors, which are heavy math, but baby kylania would not cry since EE already did all the work. Demo video - rotating a crate in 3d. gj6TJEyazO8 The code... init.sqf private [ "_makeR", "_applyR", "_i", "_pos", "_R", "_v_dir", "_v_up" ]; _makeR = compile loadfile "buildRotationMatrix.sqf"; _applyR = compile loadfile "applyRotation.sqf"; sleep 5; for [{_i = 0}, {_i < 200}, {_i = _i + 1}] do { _pos = getPosATL crate; crate setPosATL[_pos select 0, _pos select 1, (_pos select 2) + 0.01]; sleep 0.01; }; _R = [1, 0, 0] call _makeR; hint "X axis"; sleep 5; for [{_i = 0}, {_i < 1000}, {_i = _i + 1}] do { _v_dir = [vectorDir crate, _R] call _applyR; _v_up = [vectorUp crate, _R] call _applyR; crate setVectorDirAndUp [_v_dir, _v_up]; sleep 0.01; }; _R = [0, 1, 0] call _makeR; hint "Y axis"; sleep 5; for [{_i = 0}, {_i < 1000}, {_i = _i + 1}] do { _v_dir = [vectorDir crate, _R] call _applyR; _v_up = [vectorUp crate, _R] call _applyR; crate setVectorDirAndUp [_v_dir, _v_up]; sleep 0.01; }; _R = [0, 0, 1] call _makeR; hint "Z axis"; sleep 5; for [{_i = 0}, {_i < 1000}, {_i = _i + 1}] do { _v_dir = [vectorDir crate, _R] call _applyR; _v_up = [vectorUp crate, _R] call _applyR; crate setVectorDirAndUp [_v_dir, _v_up]; sleep 0.01; }; makeR - make a rotation tensor... private [ "_ct", "_cr", "_cp", "_st", "_sr", "_sp", "_rotation" ]; _ct = cos(_this select 0); _cr = cos(_this select 1); _cp = cos(_this select 2); _st = sin(_this select 0); _sr = sin(_this select 1); _sp = sin(_this select 2); _rotation = [ [_cp*_cr, -1*_sp*_ct + _cp*_sr*_st, _sp*_st + _cp*_sr*_ct], [_sp*_cr, _cp*_ct + _sp*_sr*_st, -1*_cp*_st + _sp*_sr*_ct], [-1*_sr, _cr*_st, _cr*_ct] ]; _rotation applyRotation - apply a rotation tensor to a vector, return resulting vector private[ "_v", "_r", "_r0", "_r1", "_r2", "_newVector" ]; _v = _this select 0; _r = _this select 1; _r0 = _r select 0; _r1 = _r select 1; _r2 = _r select 2; _newVector = [ (_v select 0)*(_r0 select 0) + (_v select 1)*(_r1 select 0) + (_v select 2)*(_r2 select 0), (_v select 0)*(_r0 select 1) + (_v select 1)*(_r1 select 1) + (_v select 2)*(_r2 select 1), (_v select 0)*(_r0 select 2) + (_v select 1)*(_r1 select 2) + (_v select 2)*(_r2 select 2) ]; _newVector Edited September 22, 2010 by Evil_Echo 1 Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2010 (edited) Great bit of scripting Evil_Echo I've been after a way to go beyond 90degres of rotation for a while. I don't know the right way to ask this but is there a way to rotate an object relative to it's direction? Edited September 22, 2010 by F2k Sel Share this post Link to post Share on other sites
Evil_Echo 11 Posted September 22, 2010 (edited) Great bit of scripting Evil_Echo I've been after a way to go beyond 90degres of rotation for a while.I don't know the right way to ask this but is there a way to rotate an object relative to it's direction? The above code does exactly that. In the example I'm rotating 1 degree each step relative to previous orientation. You could generate a rotation tensor with any angle(s) you wish - a 3d tumble is trivial with this method. The only thing here is I'm using axis based on map coordinates. You could apply a similar technique to generate a rotation tensor based on model coordinates as well - I just have not bothered with that yet. Edited September 22, 2010 by Evil_Echo Share this post Link to post Share on other sites
f2k sel 164 Posted September 22, 2010 Cheers I'll take another look but I think it's way beyond my ability. Share this post Link to post Share on other sites
twirly 11 Posted September 23, 2010 @Evil....Thank you for posting this. Very cool! Share this post Link to post Share on other sites
callihn 10 Posted September 26, 2010 (edited) Yea, now we know how to rotate a box in front of us, however I still don't know why the plane is falling and I don't see why one would need trig to do it either the direction is already known before the velocity is set as the plane was just set there facing that direction prior to velocity being applied. Edited September 26, 2010 by callihn Share this post Link to post Share on other sites
twirly 11 Posted September 26, 2010 (edited) Yea, now we know how to rotate a box in front of us, however I still don't know why the plane is falling and I don't see why one would need trig to do it either the direction is already known before the velocity is set as the plane was just set there facing that direction prior to velocity being applied. @callihn...Why is your plane still falling mate? Use this and it won't fall....honestly! _plane= createVehicle ["A10", _planepos, [], 0, "FLY"]; [color="Red"]_plane setDir 180;[/color] _dir = getDir _plane; _speed = speed _plane; _plane setVelocity [sin(_dir)*_speed/3.6,cos(_dir)*_speed/3.6,0]; _crew = createGroup WEST; _pilot = _crew createUnit ["USMC_Soldier_Pilot",[0,0,30], [], 0, "NONE"]; _pilot assignAsDriver _plane; _pilot moveInDriver _plane; Edit: Made a change (in red)....this works. Tested it. Here is an Arma 2 example :- http://www.mediafire.com/file/pmmtl2lhf90mm2h/AA_ARMA_Test_Create_Plane.utes.zip Good luck! Edited September 26, 2010 by twirly Share this post Link to post Share on other sites