Jump to content
Sign in to follow this  
bobby budnick

How to find a point halfway between 2 objects?

Recommended Posts

I don't think it is as simple as halving the difference between the two points. Or is it?

I am working on a large map and I need to do this so I can make extra long waypoints since addWayPoint has a limited range. Thanks for the help.

Edit:

I am working on something now. I will update the post if I can figure it out.

Edited by Bobby Budnick

Share this post


Link to post
Share on other sites

there might be a cool cos/sin formula for it but it's been awhile since I did maths so I'd just do it this way...

_pos1 = getpos _obj1;

_pos2 = getpos _obj2;

_x1 = _pos1 select 0;

_y1 = _pos1 select 1;

_x2 = _pos2 select 0;

_y2 = _pos2 select 1;

_x3 = (((_x1 max _x2)-(_x1 min _x2))/2)+(_x1 min _x2);

_y3 = (((_y1 max _y2)-(_y1 min _y2))/2)+(_y1 min _y2);

_halfway = [_x3,_y3,0];

Edited by Squ33z3

Share this post


Link to post
Share on other sites

Yeah the midpoint formula. I had come back to say I discovered the solution.

((x1 + x2)/2, (y1 + y2)/2)

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  

×