Home   Help Search Login Register  

Author Topic: set velocity 2 da front  (Read 1103 times)

0 Members and 1 Guest are viewing this topic.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
set velocity 2 da front
« on: 01 Jul 2007, 13:19:31 »
it shud not b a very complex ting but it includes maths nd i used 2 skip dese classes wen i cud learn em  :D  :confused:

i wanna set my vehicles velocity streit ahead... now i know dat wen used simple da setvelocity [x,y,z] moves my vehicle on da map not considering my vehicles heading...

now i wanna push da vehicle streit 2 were it heads

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: set velocity 2 da front
« Reply #1 on: 01 Jul 2007, 13:36:00 »
Try this

Code: [Select]
// Accelerate.sqf
_vehicle       = _this select 0;
_speedmax    = _this select 1;
_acceleration = _this select 2;
_seconds      = _this select 3;

_vdir = vectorDir _vehicle;
_speed = speed _vehicle / 3.6;
_timeini   = dayTime * 3600;
while {(dayTime * 3600) < (_timeini + _seconds)} do
{
   if (_speed < _speedmax) then
   {
      _speed = _speed + _acceleration;
   };
   _vehicle setVectorDir _vdir;
   _vehicle setVelocity [(_vdir select 0)*_speed, (_vdir select 1)*_speed, -1];
  Sleep 0.01;
};

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: set velocity 2 da front
« Reply #2 on: 02 Jul 2007, 01:59:04 »
da prob is sometin else... i have a heli script (in my mision) were da heli seems 2 miss its target if he has 2 make right turn (i scripted da heli 2 avoid flyin above town)... what happens is dat it flies 2 much 2 da south (chop starts flyin north towards south) and misses its destination... so i have a setdir setting its heading 2 da right place but after dat it returns flying south all by itself (without turnin its face back south)

so i dont wanna accelrate da chopper toward da dirction 4 more dan a second or so

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta