M1ke_SK 230 Posted March 2, 2017 I have two points on map. Point A is in air and point B is in ground. I want to move object from point A to point B in time X seconds. (smooth falling effect) I got so far: _end = getPosASL player; _distance = 800; _seconds = 15; _object = "Land_Camping_Light_F" createVehicle [0,0,0]; _object setPosATL [(_end select 0) + selectRandom [_distance, -_distance], (_end select 1) + selectRandom [_distance, -_distance], _distance]; _velocityX = ((_end select 0) - ((getPosATL _object ) select 0)) / _seconds; _velocityY = ((_end select 1) - ((getPosATL _object ) select 1)) / _seconds; _velocityZ = ((_end select 2) - ((getPosATL _object ) select 2)) / _seconds; _object setVelocity [_velocityX, _velocityY, _velocityZ]; But object is not falling on point B ( _end - position of player) Share this post Link to post Share on other sites
gc8 970 Posted March 3, 2017 Hi made few changes to your script.. _end = getPosATL player; // change: ATL isntead of ASL _distance = 800; _seconds = 5; _object = "Land_Camping_Light_F" createVehicle [0,0,0]; _object setPosATL [(_end select 0) + selectRandom [_distance, -_distance], (_end select 1) + selectRandom [_distance, -_distance], _distance]; while { _object distance player > 0.1 } do // change: a loop... { _velocityX = ((_end select 0) - ((getPosATL _object ) select 0)); // change: no dividing _velocityY = ((_end select 1) - ((getPosATL _object ) select 1)); _velocityZ = ((_end select 2) - ((getPosATL _object ) select 2)); _object setVelocity [_velocityX, _velocityY, _velocityZ]; }; Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted March 3, 2017 8 hours ago, gc8 said: Hi made few changes to your script.. _end = getPosATL player; // change: ATL isntead of ASL _distance = 800; _seconds = 5; _object = "Land_Camping_Light_F" createVehicle [0,0,0]; _object setPosATL [(_end select 0) + selectRandom [_distance, -_distance], (_end select 1) + selectRandom [_distance, -_distance], _distance]; while { _object distance player > 0.1 } do // change: a loop... { _velocityX = ((_end select 0) - ((getPosATL _object ) select 0)); // change: no dividing _velocityY = ((_end select 1) - ((getPosATL _object ) select 1)); _velocityZ = ((_end select 2) - ((getPosATL _object ) select 2)); _object setVelocity [_velocityX, _velocityY, _velocityZ]; }; What exactly will this loop do other than setVelocity to an object as fast as the engine can iterate through the loop? Hint: Spoiler You can use a physics trajectories formula using launch distance and time until impact to calculate the horizontal launch velocity of the object at a given height. Cheers 1 Share this post Link to post Share on other sites
gc8 970 Posted March 3, 2017 4 minutes ago, Grumpy Old Man said: What exactly will this loop do other than setVelocity to an object as fast as the engine can iterate through the loop? Cheers it makes the speed of the object to change according to the distance to the end position. Edit: there should be sleep in the loop.. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted March 3, 2017 6 minutes ago, gc8 said: it makes the speed of the object to change according to the distance to the end position. That point was clear if you reread my post. The question was what the loop is doing other than setting the objects velocity as fast as possible. It only works if the player is standing perfectly still. If the player is moving you will never exit the loop which is running at full speed. Can get ugly real fast if used multiple times in a row for multiple players. Also it's not a smooth falling effect, more like floating. But that's open to interpretation I guess. I understand from OPs post that he wants some kind of freefall with horizontal launch velocity. Cheers Share this post Link to post Share on other sites
gc8 970 Posted March 3, 2017 4 minutes ago, Grumpy Old Man said: That point was clear if you reread my post. The question was what the loop is doing other than setting the objects velocity as fast as possible. It only works if the player is standing perfectly still. If the player is moving you will never exit the loop which is running at full speed. Can get ugly real fast if used multiple times in a row for multiple players. Also it's not a smooth falling effect, more like floating. But that's open to interpretation I guess. I understand from OPs post that he wants some kind of freefall with horizontal launch velocity. Cheers good points there. here's an updated version: _end = getPosATL player; // change: ATL isntead of ASL _distance = 800; _seconds = 5; _object = "Land_Camping_Light_F" createVehicle [0,0,0]; _object setPosATL [(_end select 0) + selectRandom [_distance, -_distance], (_end select 1) + selectRandom [_distance, -_distance], _distance]; while { _object distance _end > 0.1 } do // change: a loop... { _velocityX = ((_end select 0) - ((getPosATL _object ) select 0)); // change: no dividing _velocityY = ((_end select 1) - ((getPosATL _object ) select 1)); _velocityZ = ((_end select 2) - ((getPosATL _object ) select 2)); _object setVelocity [_velocityX, _velocityY, _velocityZ]; sleep 0.001; }; not sure what's best sleep time there , probably have to try it out. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted March 3, 2017 Best solution is in the spoiler in my post above. Cheers Share this post Link to post Share on other sites