Forum Jump :

Author Message


Posts: 7
Rank:


Level: Member

Country: nz
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-07-10 04:08        
     
Hi Guys,

So I've been trying all day how to figure out how to launch a missile or another object from the players position. Before I give up I thought I'd ask here for help.

I need the object to launch like a bullet would from a gun or from whichever direction and/or angle that the player is aiming/looking at called by a simple script or add action.

Right now the object launches at which ever direction i'm facing at, but not up or down. If the player looks up and then calls the script, the object needs to launch upwards skywards for example. So wherever the player is aiming at the object needs to fly in that direction.


Right now i've got:


Bullet = "Land_canteen_f" createVehicle position player;

Bullet setpos getpos Player;
Bullet setPosATL (Bullet modelToWorld[0.23,1,1]);
Bullet setDir getDir Player

_vehicle = Bullet;
_vel = velocity _vehicle;
_speed = 100;
_dir = direction _vehicle;


_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

Damage attachTo [Bullet,[0, 0, 0]];



Any help would be greatly appreciated. Cheers.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#2 Posted at 2016-07-10 21:34        
     
You could try some vectors like eyeDirection (head direction in fact). As KK's remarked see also positionCameraToWorld.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 7
Rank:


Level: Member

Country: nz
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-07-11 12:46        
     
# Pierre MGI : You could try some vectors like eyeDirection (head direction in fact). As KK's remarked see also positionCameraToWorld.

Hi there, would you know how to translate what I've got to do something like that by any chance?

Cheers for the reply.

Added 1 second later:

# Pierre MGI : You could try some vectors like eyeDirection (head direction in fact). As KK's remarked see also positionCameraToWorld.

Hi there, would you know how to translate what I've got to do something like that by any chance?

Cheers for the reply.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#4 Posted at 2016-07-13 00:08        
     
Sorry for late reply. eyeDirection doesn't work well. So try this script instead:
0 = [100] spawn { 
  params ["_speed"]; 
  _bullet = "Land_canteen_f" createVehicle position player; 
  _bullet setPosATL (player modelToWorld[0.23,1,1]); 
  _vel = velocity player; 
 _dir = direction player; 
 _bullet setVelocity ((getCameraViewDirection player) vectorMultiply _speed)
}

You can adjust speed in [] as parameter of this spawn code (working in a trigger like "radio A" repeatable).

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 7
Rank:


Level: Member

Country: nz
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2016-07-13 06:24        
     
# Pierre MGI : Sorry for late reply. eyeDirection doesn't work well. So try this script instead:
0 = [100] spawn { 
  params ["_speed"]; 
  _bullet = "Land_canteen_f" createVehicle position player; 
  _bullet setPosATL (player modelToWorld[0.23,1,1]); 
  _vel = velocity player; 
 _dir = direction player; 
 _bullet setVelocity ((getCameraViewDirection player) vectorMultiply _speed)
}

You can adjust speed in [] as parameter of this spawn code (working in a trigger like "radio A" repeatable).

You sir are amazing. The only problem is, it doesnt work on AI as I'm assuming that getcameraview is for players only. Is there a workaround for this? Cheers.

Added 1 second later:

# Pierre MGI : Sorry for late reply. eyeDirection doesn't work well. So try this script instead:
0 = [100] spawn { 
  params ["_speed"]; 
  _bullet = "Land_canteen_f" createVehicle position player; 
  _bullet setPosATL (player modelToWorld[0.23,1,1]); 
  _vel = velocity player; 
 _dir = direction player; 
 _bullet setVelocity ((getCameraViewDirection player) vectorMultiply _speed)
}

You can adjust speed in [] as parameter of this spawn code (working in a trigger like "radio A" repeatable).

You sir are amazing. The only problem is, it doesnt work on AI as I'm assuming that getcameraview is for players only. Is there a workaround for this? Cheers.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#6 Posted at 2016-07-13 08:14        
     
If we suppose your AIs aim at something, use weaponDirection .

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS