Jump to content
Sign in to follow this  
jwllorens

Function to aim vehicle turret at position and fire?

Recommended Posts

I've found it somewhat irritating how difficult it is in ArmA to get a vehicle turret, or an infantry for that matter, to aim a certain weapon at a position and fire.

 

Does anyone have a working function for this?

 

All I want is to make the vehicle turret aim at a position such that it will compensate for the ballistics of the projectile fired by a specific muzzle and for the velocity of the vehicle itself.   I want to be able to call this function and have it override any behavior the AI in the turret is currently executing, such as targeting an enemy or seeking cover, ect.  Even getting the AI to aim reliably at enemies is challenging, and seems downright impossible if you want them to aim at a noncombatant or three-dimensional world position.

 

 

If not a function to do this, is there a function that will return ballistic information contained within the config file for a weapon/muzzle/projectile, and a function to aim a turret in an exact direction corresponding to a vector?  I could dust off my engineering dynamics books and try my hand as some vector math to do all the work in between, to find the unit vector direction to aim the turret given config file ballistics information and a position, which could be fun.

Share this post


Link to post
Share on other sites
tank dowatch targetpos;
tank fire currentweapon tank;

In case of the regular slammer replace currentweapon tank with "cannon_120mm".

 

That's it.

  • Like 1

Share this post


Link to post
Share on other sites
tank dowatch targetpos;
tank fire currentweapon tank;

In case of the regular slammer replace currentweapon tank with "cannon_120mm".

 

That's it.

 

 

That works for the 120mm cannon, but doesn't seem to work for the LMG.  It also doesn't seem to work for other smaller caliber guns such as the 40mm on the Marshall.  

 

The gunner doesn't seem to want to fire unless doWatch is called on an enemy.  

 

 

Also, I can't tell if doWatch is adjusting the aim for distance or tank movement, it doesn't seem to be.

 

I'm also having trouble getting the doWatch to work if the turret is already targetting something and is in combat.  I've tried setCombatMode, setBehaviour, disableAI.  Certain combinations fix this problem, but then they render the "fire" command useless.

 

 

fireAtTarget is more reliable, but the aim of the turret is always way off since fireAtTarget doesn't actually force the unit to aim and just fires the weapon wherever the muzzle is pointed.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×