Home   Help Search Login Register  

Author Topic: Position between objects  (Read 1421 times)

0 Members and 3 Guests are viewing this topic.

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Position between objects
« on: 15 Mar 2011, 04:49:02 »
How can I return a position between two objects and a certain distance away from either of them?

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Position between objects
« Reply #1 on: 15 Mar 2011, 06:22:11 »
EDIT:
Found something similar, though it's in .sqf form.
CSL_GetMoveIncrementInfantry.sqs
Code: [Select]
// to use
// pass 2 positions, returns a 3rd postion in between the 2 positions 100 meters away

_postionA = _this select 0;
_postionB = _this select 1;

_X1 = _postionA select 0;
_Y1 = _postionA select 1;
_X2 = _postionB select 0;
_Y2 = _postionB select 1;

_distanceA = _X1 - _X2;
_distanceB = _Y1 - _Y2;
_distanceC = sqrt ((_distanceA * _distanceA) + (_distanceB * _distanceB));

_reductionRatio = _distanceC/100;

_returnPostion = [(_X1 +((_X2 - _X1)/_reductionRatio)), (_Y1 +((_Y2 - _Y1)/_reductionRatio)),00.00];

_output = _returnPostion;
_output

Its somewhat advanced, so I can't figure out how it is done or what formula is used. (I'm quite weak in maths.LOL)

----------------------------------

I think you should browse through the OFPEC Editor's Depot and at the ArmAholic for script packs.
I've seen a script that do this before, but can't remember.

If you are familiar with scripting, I think you should use a gamelogic to do the job.
First determine dis btwn the two obj.
Then half it. Find direction from one obj to another. (You'll get two)
Then setpos the gamelogic to the appropriate position.

There may be better ways. So wait for others comments if you have time.

Also, I'll take a look at the scripts to see if I could find one.

Regards,
haroon1992
« Last Edit: 15 Mar 2011, 06:51:41 by haroon1992 »
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: Position between objects
« Reply #2 on: 15 Mar 2011, 07:54:16 »
That script is perfect. Thanks. It's in .sqs form by the way. ;)

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Position between objects
« Reply #3 on: 15 Mar 2011, 13:58:50 »
No it's not in .sqs, you can determine whether a script is in .sqs format or not by seeing it's comments.

I'm glad that my post was helpful.

Cheers,
Haroon1992
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: Position between objects
« Reply #4 on: 21 Mar 2011, 15:59:22 »
The script did actually work when I used it in SQS form... after I removed the comments at the beginning, of course. I suppose it would work as SQF too, but I always thought that SQF scripts were more organized with structuring and all.

But that doesn't matter. Problem solved. :)