Jump to content

Make one group drive in the opposite direction of another group.


Recommended Posts

Posted

Hi!

 

I'm looking for a way to make a group retreat from another group. I know how to make them drive to a point in a set direction for a set distance. Now I need to get the direction to be the opposite direction of another group. How do I find that?

 

I guess I need the bearing from GroupA to GroupB, and then flip it 180 degrees. But how do I get the bearing between those two points?

Posted

The heading from Group B to Group A is the same as the heading of Group A to Group B flipped 180 degrees.

 

Ripped this from mist, donno whatever the calls would be when using møøse.

 

avgPos and ref in this are just two points. Could simply be the lead vehicle that is alive in both groups. I think the value for ref is the heading from that point to the avgPos point.

 

 

local vec = {x = avgPos.x - ref.x, y = avgPos.y - ref.y, z = avgPos.z - ref.z}
local dir = math.atan2(vec.z, vec.x)

if dir < 0 then
   dir = dir + 2 * math.pi	-- put dir in range of 0 to 2*pi
end
return dir

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
The heading from Group B to Group A is the same as the heading of Group A to Group B flipped 180 degrees.

 

I... did not think of that.

 

Thanks buddy! I'll give it a whirl. I'm using whatever method works and my missions tend to be a hodgepodge of Mist, Moose and regular old straight to the API scripting.

Posted
I'm failing with this. The unit always drives almost straight north (heading between 003 and 005).

Sounds like you have a unit issue. dir is in radians not degrees. Try Direction=math.deg(dir) and see if that works better. It depends on what the function you put "dir" in expects.

A warrior's mission is to foster the success of others.

i9-12900K | RTX 4090 | 128 GB Ram 3200 MHz DDR-4 | Quest 3

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Posted
Sounds like you have a unit issue. dir is in radians not degrees. Try Direction=math.deg(dir) and see if that works better. It depends on what the function you put "dir" in expects.

 

That was it! Thanks a lot!

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...