lawndartleo 109 Posted November 21, 2013 I've created the following script to spawn a desk with a file on it in a random (3 possible markers) location. _desk = createVehicle ["Land_TableDesk_F",getMarkerPos "1",["2","3"], 0, "none"]; _file = createVehicle ["Land_File1_F", position _desk,[],0,"none"]; _file attachto [_desk,[0,0,.44]]; _file addAction ["Pick up", pickup_code]; What does it take to get the desk to spawn PRECISELY on the markers which I have placed in houses. To this point I have been unable to find anything on precision object spawning. Share this post Link to post Share on other sites
TeTeT 1523 Posted November 22, 2013 Try setPos on the marker position after you created the object. Depending on where you place it, you might prefer setPosASL or setPosATL over setPos. Share this post Link to post Share on other sites
2nd ranger 282 Posted November 22, 2013 If you want absolute precision I wouldn't use markers. Get the actual coordinates you want and use those instead. As TeTeT said, you may have to setPos it after it is spawned rather than relying on the randomization in createVehicle. Share this post Link to post Share on other sites
lawndartleo 109 Posted November 22, 2013 Well this just blew up into a real mess. The fact of the matter is I need to pass an array of [x,y,z,d] to set a location and direction. How can I randomly pick from a pool of 3 arrays? a1=[x1,y1,z1,d1] a2=[x2,y2,z2,d2] a3=[x3,y3,z3,d3] Pick ax and have it be used to set position and direction. Share this post Link to post Share on other sites
lordprimate 159 Posted November 22, 2013 _cordir = [[x1,y1,z1,d1],[x2,y2,z2,d2],[x3,y3,z3,d3]]; _rndpos = (_cordir select (round(random 2))); I donno .. it was just a quick mashup idea i havent tested it or anything, just an idea from what i have seen in other scripts. Share this post Link to post Share on other sites
Larrow 2821 Posted November 22, 2013 How can I randomly pick from a pool of 3 arrays? //Long version //An array of arrays (indexs 0, 1 and 2) _myPositions = [ [x1,y1,z1,d1], [x2,y2,z2,d2], [x3,y3,z3,d3] ]; _numOfPositions = count _myPositions; // 3 _randomNumber = random _numOfPositions; //give random number between 0.00000 and 2.99999 _index = floor _randomNumber; // 0, 1 or 2 _randomPosition = _myPositions select _index; //Short Version //An array of arrays (indexs 0, 1 and 2) _myPositions = [ [x1,y1,z1,d1], [x2,y2,z2,d2], [x3,y3,z3,d3] ]; _randomPosition = _myPositions select (floor (random (count _myPositions))); What does it take to get the desk to spawn PRECISELY on the markers which I have placed in houses. I remember when i was trying to spawn crates at house position, due to the objects being created inside the bounds of the house they kept appearing outside. Using "CAN COLLIDE" in create vehicle command solved this issue and they would spawn exactly where asked. _desk = createVehicle ["Land_TableDesk_F",getMarkerPos "1",["2","3"], 0, [color="#FF0000"]"CAN COLLIDE"[/color]]; Try that see if it solves your issue, then as the other have said you may still need to reset their position once created. Share this post Link to post Share on other sites
samatra 85 Posted November 22, 2013 createVehicle accept placement mode as 5th array element which you have as "none" now, change it to "CAN_COLLIDE" so createVehice would avoid checks for better placement and place it exactly where you have your coordinate Share this post Link to post Share on other sites
lawndartleo 109 Posted November 22, 2013 Thanks Larrow. I'll give that a roll. The depth of my scripting knowledge might get your socks damp.... so this is all Greek to me, but I am struggling through with help. Share this post Link to post Share on other sites
lawndartleo 109 Posted November 22, 2013 (edited) Spawning in buildings is not working well. Objects tend to spawn and flip out, flying all over the place. On ground, no problem. In a building, no placement consistency. Once I think I have a marker in a good spot, the spawned object starts behaving erratically again. I have to find buildings with rather large rooms to make it work consistently. Another problem is the spawn and attachment of the notebook. It randomly fails as well. A desk will be placed perfectly in a building but the file never shows up or gets burried in some geometry somewhere. The inconsistency is maddening. Edited November 22, 2013 by lawndartleo Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted November 23, 2013 Another problem is the spawn and attachment of the notebook. It randomly fails as well. A desk will be placed perfectly in a building but the file never shows up or gets burried in some geometry somewhere. Try enableSimulation false? Stops objetcs sinking into dektops etc. Share this post Link to post Share on other sites
johnnyboy 3793 Posted November 23, 2013 Before trying to place a desk in a building, use attachto to attach the items you want on the desktop. The files will then always be placed correctly relative to the desk. This takes some trial an error with the relative position until you get it right. Then setpos the desk where you want it, and any objects attached to desk should still be where you want them. Share this post Link to post Share on other sites
f2k sel 164 Posted November 23, 2013 Before trying to place a desk in a building, use attachto to attach the items you want on the desktop. The files will then always be placed correctly relative to the desk. This takes some trial an error with the relative position until you get it right. Then setpos the desk where you want it, and any objects attached to desk should still be where you want them. That didn't work in my test as soon as you move the desk the height of the object on the desk seems to change relative to the desk. I've only been testing editor placed objects for now. There is also a really odd problem. I place a desk outside named desk and a laptop named laptop. In the init of the desk I put laptop attachto [desk,[0,0,0.56]] and of course it works. However if there is a delay in attaching the laptop nothing happens. null=[] spawn {sleep 1;laptop attachto [desk,[0,0,0.56]]}; results in no attachment also true if you use I a trigger for the delay. however this does work null=[] spawn {sleep 1;laptop setpos (desk modelToWorld [0,0,0.41]);laptop attachto [desk] }; it also seems to work when you move the desk into the building. the height of the laptop remains remains fixed to that of the desk.. The reason for the delay is to allow the desk to find the height of the floor and settle. Share this post Link to post Share on other sites