Home   Help Search Login Register  

Author Topic: Keeping a helo flying to a dynamic waypoint  (Read 901 times)

0 Members and 1 Guest are viewing this topic.

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Keeping a helo flying to a dynamic waypoint
« on: 19 Jul 2005, 01:10:26 »
Alright,

Anybody know how I could get a helo to fly to, without stopping, a dynamic waypoint.

So basically I have a boat moving across the water and I need the helo to fly over and cross right above the boat.  Problem is using " helo domove getpos boat " in a loop won't work because the helo tries to flare when it gets close and thus never reaches the point exactly above the boat which is still moving away.

Any ideas?

Blip :joystick:



...NIGHT WALKER....

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Keeping a helo flying to a dynamic waypoint
« Reply #1 on: 19 Jul 2005, 04:00:24 »
how about setting the waypoint up in front of the boat once the helo gets close to it?

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Keeping a helo flying to a dynamic waypoint
« Reply #2 on: 19 Jul 2005, 06:28:42 »
Quote
how about setting the waypoint up in front of the boat once the helo gets close to it?

That was my part of my initial attempts.  Problem was that to get the helo not to flare to early meant that the waypoint had to be some 100m in front of the boat which made any chance of the helo flying directly over the boat impossible.  

Some how I need to make it so the helo will fly to the boat in level flight, constantly making little changes to adjust the changing position of the boat and then when it gets their slow down to match the speed of the boat.  

Blip :joystick:
...NIGHT WALKER....

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Keeping a helo flying to a dynamic waypoint
« Reply #3 on: 19 Jul 2005, 14:57:49 »
Code: [Select]
_boat = _this select 0
_helo + _this select 1
_wp = []
_d = 2

#loop
_dir = [getpos _helo,getpos _boat] call dirtopos
_wp = [((getpos _boat select 0) *120 sin _dir),((getpos _boat select 1) * 120 cos _dir),0]
_helo domove _wp
?_helo distance boat < 100:_d = 1
~_d
goto "loop"

try that, it uses the dirToPos function in the ed. depot

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Keeping a helo flying to a dynamic waypoint
« Reply #4 on: 19 Jul 2005, 15:47:01 »
We are getting closer...


Code: [Select]
_boat = _this select 0
_helo = _this select 1
_d = 2

#loop
_dir = [getpos _helo,getpos _boat] call dirtopos
_wp = [((getpos _boat select 0) *120 *sin _dir),((getpos _boat select 1) * 120 *cos _dir),0]
_helo domove _wp
?_helo distance boat < 100:_d = 1
~_d
goto "loop"

I dropped the _wp = [] because I kept getting an error saying it was getting 0 values when it expected 3.

The script itself worked okay.  The helo is just very sporadic on its approach and over shoots every time, and never really gets right on top of the boat.  

Do you think we could use setvelocity and just script the whole flight to the boat?

Blip :joystick:
« Last Edit: 20 Jul 2005, 05:17:55 by Blip »
...NIGHT WALKER....

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Keeping a helo flying to a dynamic waypoint
« Reply #5 on: 19 Jul 2005, 17:58:08 »
well what you have to do is when the helo gets over the boat exit this and run your rappel script

something like:
Code: [Select]
_boat = _this select 0
_helo = _this select 1
_d = 4

#loop
_dir = [getpos _helo,getpos _boat] call dirtopos
_wp = [((getpos _boat select 0) *120 *sin _dir),((getpos _boat select 1) * 120 *cos _dir),0]
_helo domove _wp
?_helo distance boat < 100:_d = 2
?(sqrt((((getpos _boat select 0) - (getpos _helo select 0))^2) + (((getpos _boat select 1) - (getpos _helo select 1))^2)) <= 2):[_helo] exec "rappel.sqs";exit
~_d
goto "loop"

i doubled the delay in the loop to try and fix the sporadic movement
« Last Edit: 19 Jul 2005, 17:59:12 by Triggerhappy »

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Keeping a helo flying to a dynamic waypoint
« Reply #6 on: 20 Jul 2005, 05:17:15 »
Code: [Select]
_wp = [((getpos _boat select 0) *120 *sin _dir),((getpos _boat select 1) * 120 *cos _dir),0]
I think something in here is causing the waypoint be set as _wp to be moved either way right or way left of the boat instead of being right ontop of the boat.  

So basically what I am saying is that the helo is criss crossing back and forth across a straight line to the boat.

I added a setdir for the boat so that it stays on a straight line.  Seemed to help a little bit.  

Is there a way to use setvelocity to get to a certain position.  I have tried using it a few times and it seems to keep the helo level and moving, but I can't figure out how to code the vector to the boat.

Blip :joystick:
...NIGHT WALKER....

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Keeping a helo flying to a dynamic waypoint
« Reply #7 on: 20 Jul 2005, 17:46:01 »
oh, no,  just a typo

instead of
Code: [Select]
...* 120 * sin....
it should be
Code: [Select]
...+ 120 * sin...
and also the same error on the cos part

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Keeping a helo flying to a dynamic waypoint
« Reply #8 on: 22 Jul 2005, 04:59:04 »
It is still moves to much.

I am combinging it though with homefry's setpos scripts to see if I can't get them to work together.  It actually looks very promising, and rather smooth.

Blip :joystick:

GOT IT, TOPIC SOLVED
« Last Edit: 30 Jul 2005, 02:31:10 by Blip »
...NIGHT WALKER....