nullsystems 0 Posted March 4, 2008 Hi, When creating two objects next to each other: _1 = "CampEmpty" createVehicle (vehicle player modelToWorld [0, 10]) _2= "ShedSmall" createVehicle (vehicle _1 modelToWorld [1, 1]) That method works perfectly, unless im facing south...and of course the items are left-to-right, right-to-left backwards. So, does anyone know of a way to fix this, so the _2 item would ALWAYS be on the RIGHT hand Side, or LEFT hand Side of the first item _1 ? EDIT*** Infact, when I face east and west, it tottaly goes wrong. I know WHY this happens due to the co-ordinates + - changes but I don't know of an easy way to fix it without a few good wasted IF statements that would be alot of work. I guess what im trying to say is, the position I place the first item down on and the direction, I want everything else to be relative to that...in the correct place and direction. Share this post Link to post Share on other sites
t_d 47 Posted March 4, 2008 you need to apply the dir of player to the camp before creating the Shed: _obj1 setDir (getDir player); And dont use identifier names starting with numbers. I am suprised that _1 and _2 is working. Probably because they are local variables. Share this post Link to post Share on other sites
nullsystems 0 Posted March 4, 2008 I have done that. And im not using those, they are examples. Script issued by an addAction: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dir = getDir Player _sTent = "CampEmpty" createVehicle (vehicle player modelToWorld [0, 10]) _sTent setDir _dir ~1 _dir = getDir _sTent _sShed = "ShedSmall" createVehicle (vehicle _sTent modelToWorld [1, 1]) _sShed setDir _dir - 180 I don't think you got the jist of what my problem is. If you face north, everything comes out fine, change dir and everything after the first TENT is in the wrong alignment. Share this post Link to post Share on other sites
t_d 47 Posted March 4, 2008 You dont need "vehicle" command. Theoretically it should work. Maybe the center of the Camp isn't where it is supposed to be. Yeah your picture shows that the center of the Camp is at the edge and not at the inside. Only reason I could think of for your problem. Share this post Link to post Share on other sites
nullsystems 0 Posted March 4, 2008 Theoretically it should, but it doesnt lol. If you think about it like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _x = 0 ( Distance North from Center of Map ) _y = 0 ( Distance East from Center of Map ) _z = 0 ( Alt ) _dir = 0 ( Facing North ) If you then: setPos [_x + 1, _y + 1, _z] It will come out, 1meter North, 1meter East. Changing Direction, and those co-ordinates will STILL be +1 and +1 of North and East. I need to get them to alternate automatically when facing a different direction. Example 1: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dir +150; [_x -1, _y +1,_z] Example 2: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dir +260; [_x +1, _y -1,_z] The only way I can see about doing this is an almighty IF ELSE statement to check the dir and set the +/- on the co-ordinates. Share this post Link to post Share on other sites
nullsystems 0 Posted March 4, 2008 Quote[/b] ]Yeah your picture shows that the center of the Camp is at the edge and not at the inside. Only reason I could think of for your problem. I don't follow, thats an example of three camp layouts. The first one, being the positions and shape I want. The other two showing the problems when changing direction. Share this post Link to post Share on other sites
t_d 47 Posted March 4, 2008 Before ArmA (with modelToWorld command) sin und cos were used for such stuff and modelToWorld simplifies that. The problem is that the camp has an unusually center. So to solve your problem you have to use player as base for the second object. Somthing like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dir = getDir Player _sTent = "CampEmpty" createVehicle (player modelToWorld [0, 10]) _sTent setDir _dir _sShed = "ShedSmall" createVehicle (player modelToWorld [1, 11]) _sShed setDir _dir You may need to change the coords for second object. Share this post Link to post Share on other sites
nullsystems 0 Posted March 5, 2008 Right, well ive tried it. But its still coming out fairly random. This must also be because when you turn buildings around on their DIR, their center point isnt quite right. Ive tried but failed in what I want to do. Basically, I have a set collection of buildings, they have to remain in exactly their positions but be able to be ported around to different areas on the map, when they are placed they must remain in their positions. Is there anyway to have a MAIN version of those buildings and just COPY them to somewhere? Share this post Link to post Share on other sites
MetalGearXM 0 Posted March 5, 2008 If it were really a big issue, I'd switch out that one simple line with some good old fashion trig: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _dir = getDir Player _sTent = "CampEmpty" createVehicle (player modelToWorld [0, 10]) _sTent setDir _dir _dis = 5 ; (How far infront of the tent origin - In this case 5 meters) _offc = 100 ; (How far right or left - In this case 2 meters right) ?(_dir <= 90): _temp = 90 - _dir ?((_dir > 90) && (_dir <= 180)): _temp = 180 - _dir ?((_dir > 180) && (_dir <= 270)): _temp = 270 - _dir ?((_dir > 270) && (_dir <= 360)): _temp = 360 - _dir _y = _dis * sin(_temp + _offc) _x = _dis * cos(_temp + _offc) ?(_dir <= 90): _posx = (getpos _sTent select 0) + _x ?(_dir <= 90): _posy = (getpos _sTent select 1) + _y ?((_dir > 90) && (_dir <= 180)): _posx = (getpos _sTent select 0) + _x ?((_dir > 90) && (_dir <= 180)): _posy = (getpos _sTent select 1) - _y ?((_dir > 180) && (_dir <= 270)): _posx = (getpos _sTent select 0) - _x ?((_dir > 180) && (_dir <= 270)): _posy = (getpos _sTent select 1) - _y ?((_dir > 270) && (_dir <= 360)): _posx = (getpos _sTent select 0) - _x ?((_dir > 270) && (_dir <= 360)): _posy = (getpos _sTent select 1) + _y _pos2 = [_posx, _posy, 0] _sShed = "ShedSmall" createVehicle _pos2 _sShed setDir _dir Actually, that might not be right.. But really close. Just tweak it a little bit. Share this post Link to post Share on other sites
tj72 0 Posted March 5, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _object = "Logic" createvehicle getpos player _dir = getdir player _object setdir _dir _cam2="Camera" camcreate [0,0,0] _cam2 camsettarget _object1 _cam2 camsetrelpos [0,400,0] _cam2 camcommit 0 _object1 setpos getpos _cam2 camdestroy _cam2 _stent = "CampEmpty" createVehicle getpos _object1 deletevehicle _object1 This will place objects based on the RELATIVE position with the normal getpos style coordinates. Trig would also work of course but this is a quick and easy way to do the same thing. The 400 is forward 400 meters. If you use player and then you can createvehicle with the _cam position or I like to make a logic at the cam pos and use that with createvehicle then delete the cam and the logic right after. This works perfectly. Share this post Link to post Share on other sites
t_d 47 Posted March 5, 2008 Damn it, I think I know whats wrong. createVehicle isnt really accurate with its pos. Please try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_dir = getDir Player _sTent = "CampEmpty" createVehicle [0,0] _sTent setPos (player modelToWorld [0, 10]) _sTent setDir _dir _sShed = "ShedSmall" createVehicle [0,0] _sShed setPos (player modelToWorld [1, 11]) _sShed setDir _dir Share this post Link to post Share on other sites