Jump to content

Recommended Posts

Hello guys!

 

I'm pretty confused about all the setPos's and getPos's commands... I've placed down an object1 via editor, and now I'm trying to attach object2 to it, so that object2is always on the ground level, wherever I place objectX.

 

And if its possible, I'd like to be able to change x and y axis distances (like in attachTo).

 

Anyone?

  • Confused 1

Share this post


Link to post
Share on other sites

A little explanation what I want to happen:

I've placed down an object in the editor, IED, lets call it ied1.

I've placed down another object in the editor, IED, lets call it ied2.

Added some empty markers and synced those to ied1 to get a bit randomness.

And now, I want ied2 stay in certain distance from the ied1, wherever ied1 will spawn.

If I use attachTo command, for example: "ied2 attachTo [ied1, [3, 9, 0] ];" , it works fine, but attached IED, ied2, won't stay on terrain level when terrain gets bumpy.

 

So, is there a similiar command like attachTo, but attached object will take its place on the terrain level?

 

 

Share this post


Link to post
Share on other sites

no need to attach. attachTo is thought to mount an object on another. that's not what you want.

your way is getPost (Alternative Syntax) and setPos:

 

private _max_range = 100;
private _min_range = 10;

private _rnd_range = _min_range + random (_max_range - _min_range);
private _rnd_dir = random 360;

private _desired_pos = ied1 getPos [_rnd_range, _rnd_dir];

ied2 setPos _desired_pos;

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, sarogahtyp said:

no need to attach. attachTo is thought to mount an object on another. that's not what you want.

your way is getPost (Alternative Syntax) and setPos:

 


private _max_range = 100;
private _min_range = 10;

private _rnd_range = _min_range + random (_max_range - _min_range);
private _rnd_dir = random 360;

private _desired_pos = ied1 getPos [_rnd_range, _rnd_dir];

ied2 setPos _desired_pos;

 

Thanks sarogahtyp!

 

I'll put that to test.

 

Just curious, what about commands setPosATL and getPosATL? Are you familiar with those? What kind of cases that would be the way  to go?

Share this post


Link to post
Share on other sites
14 minutes ago, jonipetteri said:

Just curious, what about commands setPosATL and getPosATL? Are you familiar with those? What kind of cases that would be the way  to go?

 

ATL, AGL, ASL and so on ... specifies the used position format. this is related to how z value (height) of position is measured/set.

further information on wikis Position page

the wiki entry of each position related command tells you which position format is needed or given by the command. this has to be taken into account everytime you use a command with a position as parameter or return value.

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
8 hours ago, sarogahtyp said:

 

 


private _max_range = 100;
private _min_range = 10;

private _rnd_range = _min_range + random (_max_range - _min_range);
private _rnd_dir = random 360;

private _desired_pos = ied1 getPos [_rnd_range, _rnd_dir];

ied2 setPos _desired_pos;

 

Okay, for some reason this code is messing up my attachTo setup.

I've placed (in editor) IED, in this case ied1, and another IED, in this case ied2.

I've also placed down third small object (in editor), HDMI-Cable, in this case cable1.

I've attached cable1 to ied2 using attachTo command (to make it look a bit differend than normal), and wrote it in init box of the cable1.

 

Now, the code above works just fine, but it somehow "removes" my attachTo command, and this cable1 will now stay in the same place where I put it it the editor.

 

Any idea why?

Edited by jonipetteri
  • Confused 2

Share this post


Link to post
Share on other sites

You should post your code, otherwise folks can only guess what you are doing wrong.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, lexx said:

You should post your code, otherwise folks can only guess what you are doing wrong.

Read last post, please.

Share this post


Link to post
Share on other sites

There is always at least 3 solutions for a problem:

  •  the wrong one;
  •  the right one;
  •  the jonipetteri one.

Joke apart, you should read what sarogahtyp wrote and disregard your attachTo setting (for all that stuff). That means you have to apply the code on ied2 AND cable1AND... with relative positions from ied1 I guess.

Share this post


Link to post
Share on other sites
1 hour ago, jonipetteri said:

Read last post, please.

 

I did, and you must do something wrong in your code.

Share this post


Link to post
Share on other sites
2 minutes ago, lexx said:

 

I did, and you must do something wrong in your code.

Like I said, sarogahtyps code works fine. I run it via Game Logic-module in the editor.

 

I've attached cable1 to ied2 by writing cable1 init box this: ied2 attachTo [cable1, [0, 0, 0] ]; and this code is not working after I run sarogahtyps code.

 

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

×