Author: Tommy_harhar
Author Website:

Short description: Move objects from one place to another and maintain relative height.
Date: 2016-12-28 16:54
Submitted by: tommy_harhar

Comments: (0)


Compostion Mover


Having struggled to find a script (that I could get to work) to move a group of objects from one place to another, while maintaining their height relative to each other, I've come up with this.

You place your composition of objects in the editor, then either name one of them such that you can pass its name as a parameter, or add a new 'marker' object and name that.

Then place a destination object, also named, and call the script from a trigger or the init file etc.
The objects will be moved, while keeping their formation and relative height to each other.
You can also have the original and/or destination objects deleted, to keep things tidy.

Any feedback is greatly appreciated.


Usage:From init file or trigger.
_movestufff = [startobj,destobj,85,0,1] execvm "compositionmover.sqf";


0 - Object name: Object to start moving from.
1 - Object name: Object to move the composition to.
2 - Distance in meters: Range around starting object to pick objects from.
3 - Binary 0 or 1: Delete starting object after move?
4 - Binary 0 or 1: Delete destination object after move?

SQF file inside mission folder:
_objects = nearestobjects [_this select 0,[],_this select 2];
_startpos = _this select 0;
_destpos = _this select 1;
_direction = _startpos getdir _destpos;
_distance = _startpos distance2d _destpos;
	_newpos = [_x, _distance,_direction] call BIS_fnc_RelPos;
	_x setposasl _newpos;
	_x setposasl [getposasl _x select 0,getposasl _x select 1,((getposasl _x select 2) + (getposasl _destpos select 2))];
}	foreach _objects;

_cleanup = if (_this select 3 == 1 ) then { deleteVehicle _startpos } else {};
_cleanup = if (_this select 4 == 1 ) then { deleteVehicle _destpos } else {};

Tags: No tags