Jump to content
Sign in to follow this  
PELHAM

How to setpos objects created from a marker array?

Recommended Posts

I have created a path of helper object spheres using the following code. It creates 1 sphere on each marker at ground level.:

{"Sign_sphere100cm_EP1" createVehicle getMarkerPos _x;} forEach[

"L01","L02","L03","L04","L05","L06","L07","L08","L09","L10",
"L11","L12","L13","L14","L15","L16","L17","L18","L19","L20",
"L21","L22","L23","L24","L25","L26","L27","L28","L29","L30",
"L31","L32","L33","L34","L35","L36"];

The problem: I would like to set each sphere 30m above the ground with setPosATL. As there is no array for the spheres how would I do that?

Is it even possible or do I have to create all the spheres and setpos each one in the editor?

I have tried various combinations of the setposATL syntax combined with _x and I had an

{sp = "Sign_sphere100cm_EP1" createVehicle getMarkerPos _x;} forEach[

and tried using a

{setposATL [blah blah]} for each units sp;

but that did not work either.

Am I going about this in the right way or would you not start from here lol.

Edited by PELHAM

Share this post


Link to post
Share on other sites

Doesn't work as in it isn't on the correct height? Or?

If you are already managing to create them at ground level, you could simply use:

{
_tempSign = "Sign_sphere100cm_EP1" createVehicle getMarkerPos _x;
_tempSign setPosASL [getPosASL _x select 0, getPosASL _x select 1, (getPosASL _x select 2) + 30];
} forEach
[
"L01","L02","L03","L04","L05","L06","L07","L08","L09","L10",
"L11","L12","L13","L14","L15","L16","L17","L18","L19","L20",
"L21","L22","L23","L24","L25","L26","L27","L28","L29","L30",
"L31","L32","L33","L34","L35","L36"
];

The ASL commands always seem to work exactly as one would expect, while the regular setPos/getPos and the ATL variation seem dodgy...

EDIT: Fixed the code.

Edited by galzohar

Share this post


Link to post
Share on other sites
Ok, I'm rather new to this but first you should declare your array.

Then use a forEach loop.

http://community.bistudio.com/wiki/Control_Structures#forEach-Loop

I don't know how to do the last part.

The problem is there is no array to declare: The spheres are created 1 on each marker at ground level with the code in post 1. If that creates an array of spheres how do I call that information?

---------- Post added at 12:16 ---------- Previous post was at 12:02 ----------

Doesn't work as in it isn't on the correct height? Or?

If you are already managing to create them at ground level, you could simply use:

{
"Sign_sphere100cm_EP1" createVehicle getMarkerPos _x;
_x setPosASL [getPosASL _x select 0, getPosASL _x select 1, (getPosASL _x select 2) + 30];
} forEach
[
"L01","L02","L03","L04","L05","L06","L07","L08","L09","L10",
"L11","L12","L13","L14","L15","L16","L17","L18","L19","L20",
"L21","L22","L23","L24","L25","L26","L27","L28","L29","L30",
"L31","L32","L33","L34","L35","L36"
];

The ASL commands always seem to work exactly as one would expect, while the regular setPos/getPos and the ATL variation seem dodgy...

Yes the code I use creates 1 sphere on each marker at ground level, the problem is how to alter their position, I tried this one, didn't work:

{
"Sign_sphere100cm_EP1" createVehicle getMarkerPos _x;
_x setPosASL [ getPosASL _x select 0, getPosASL _x select 1, (getPosASL _x select 2) +100]
} forEach  
["L02","L03","L04","L05","L06","L07"];

It only creates 1 sphere at ground level - is it because we are nesting several _x values in one code block and it's getting confused?

Edited by PELHAM

Share this post


Link to post
Share on other sites

Sorry, my bad, not _x setPosASL, _x is the marker. Instead use the fixed code in my original post (which is now edited).

Share this post


Link to post
Share on other sites

If it doesn't want to move up with setposasl, create an invisible helipad or game logic at the position and then attachto the spere to it, at right height.

Of course, it might be better to just replace the markers with the hpads.

Share this post


Link to post
Share on other sites

I think I am going to go back and start again. I was attempting a shortcut but of course the best way is scripting each sphere individually so you have more options and control.

I am going to use a combination of markers and Hpads so I can move/delete spheres and task hints along the track at will.

There does not seem to be a method of either setPos or deleting objects created in this way.

See you all much, much later. My father always told me there were no shortcuts in life lol.

Thank you for your help.

Share this post


Link to post
Share on other sites

Hmm, this works for me when I try it from a trigger:

{_obj = "Sign_sphere100cm_EP1" createVehicle getMarkerPos _x; _obj setPos [getPos _obj select 0, getPos _obj select 1, (getPos _obj select 2)+1.2]} forEach ["L01","L02","L03"]

But, a bunch of helpers? Won't that look kinda weird?

Edit: Oh, I did have some problems, and I see I ended up pretty much with the same stuff galzohar showed. The point is, give it a reference so you can move it after creation. I'm using _obj in my example. ATL or not didn't seem to matter in my test.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites
Hmm, this works for me when I try it from a trigger:

{_obj = "Sign_sphere100cm_EP1" createVehicle getMarkerPos _x; _obj setPos [getPos _obj select 0, getPos _obj select 1, (getPos _obj select 2)+1.2]} forEach ["L01","L02","L03"]

But, a bunch of helpers? Won't that look kinda weird?

Edit: Oh, I did have some problems, and I see I ended up pretty much with the same stuff galzohar showed. The point is, give it a reference so you can move it after creation. I'm using _obj in my example. ATL or not didn't seem to matter in my test.

Excellent, thanks Carl! Why didn't I think of that!? Probably because _x has done so many wonderful things for me lately I was convinced it would be the answer lol.

I need the markers for a low level confidence course in my helicopter training mission between houses, trees and telephone poles. It stretches accross the entire island of Utes and they are 50m apart so does not look too bad.

The conditions to win the task are no slower than 130kts and no higher than 20/25m. You need a line for reference so you know where to go. A single helper isn't enough.

I am thinking of scripting the whole thing individually so it looks a bit more professional and I can hideObject, show and setObjectTexture etc to change the colours / alpha.

Hopefully after someone sees the enormous effort put into this, some of the admins will let me fly in Domination :D.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×