Home   Help Search Login Register  

Author Topic: relative position of objects  (Read 463 times)

0 Members and 1 Guest are viewing this topic.

Offline SEAL84

  • Members
  • *
  • Always lurking
relative position of objects
« on: 04 Mar 2004, 05:32:37 »
Hi again.

I set up a scripted resupply/reinforcement route for a blackhawk and I'm probably going to use it in a mission I'm making....when the chopper's altitude drops below 2 meters, ammo crates are setpos'd to its position (offset slightly to avoid collision).

Right now it's simply using the chopper's X/Y coords to move the crates (highly complicated stuff here :P), but I want to know if there's a way to take into account the chopper's direction.

Example:     Chopper faces due North and the crates are moved to a position 2 meters west of the bird to simulate tossing them out the door.

Chopper now faces due East....boxes are still created at (getpos chopper select 0)-2, putting them more or less under the tailboom.  

It just doesn't look right sometimes, if you follow what I'm saying.

Is there a way to make the crates move to a position relative to the chopper's heading?  For example always make the crates appear 2 meters away at heading 270* (puts them 2 meters to the left, no matter which way it's facing)?

It's a cosmetic thing, I know, but it would be nice to do it the "right" way.
« Last Edit: 04 Mar 2004, 05:33:50 by SEAL84 »

sa8gecko

  • Guest
Re:relative position of objects
« Reply #1 on: 04 Mar 2004, 06:38:03 »
You have to use a little trigonometry.
To put the crates to the left of the chopper (that is, chopper
heading + 90 degrees) use
... setpos [(getpos chopper select 0) + x* sin (dir - 90),
(getpos chopper select 1) + x*cos (dir - 90), getpos chopper select 2]
where:
dir = direction chopper
x = how many meters to the left
« Last Edit: 04 Mar 2004, 06:40:54 by sa8gecko »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:relative position of objects
« Reply #2 on: 04 Mar 2004, 11:30:22 »
Use getDir for the chopper direction.   For the up-down coordinate it might be better to use ground level rather than the chopper height, but worth experimenting to see how it looks.  I haven't checked the trigonometry (there is no doubt that trig is what you need to solve this question) but the whole script could look like this

_dir = getDir chopper1

crate1 setpos [(getpos chopper select 0) + x* sin (_dir - 90),
(getpos chopper select 1) + x*cos (_dir - 90), 0]

If you're not familiar with trig then I think somebody (toadlife?) wrote a quick and dirty guide which is in the Ed Depot somewhere .... or am I thinking of the stuff at the end of the unofficial comref .....
« Last Edit: 04 Mar 2004, 11:30:41 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:relative position of objects
« Reply #3 on: 04 Mar 2004, 16:31:20 »
Arg now I have to eat those words from math class three years ago:

"I'll never use trig for anything!"

I'll try it out this afternoon; thx guys.

Offline SEAL84

  • Members
  • *
  • Always lurking
Re:relative position of objects
« Reply #4 on: 04 Mar 2004, 22:48:36 »
That did the trick....thanks again