Jump to content
madrussian

Universal way to get any Turret's Direction

Recommended Posts

I know of (at least) 3 ways to get a turret's direction, but my usual bag of tricks is not working on a particular turret within a particular vehicle.  Could use some help, thanks!

 

Vehicle is Sherman tank from IFA3, type is "LIB_M4A3_75".  Turret is [1], the "hull" turret (the one you get in via "To Machinegunner's seat" action).

 

My normal methods for getting turret direction:

  1. Use weaponDirection command.  Of course this works on main gunner's turret only.  As this turret is not a main turret, weaponDirection returns non-direction of [0,0,0] as expected, so we need another method.
  2. From turret's config get "gunBeg" and "gunEnd", use selectionPosition to get the points in space, and then use vectorDiff to subtract gunEnd from gunBeg to get the turret's direction.  Normally this works, and normally I can confirm visually via addMissionEventHandler "Draw3D" with drawIcon3D command.  But in this case:  Upon manning this turret the gunBeg and gunEnd positions are in the right place, but as I move the turret around, the gunBeg and gunEnd points should move around accordingly, but they do not move around and instead errantly remain fixed in place.  (Again, this method and visual verification works with other vehicle types.)
  3. From turrets config get "animationSourceBody" and "animationSourceGun", and then use animationPhase command to compute the guns rotation from center in radians, and go from there to get turret's direction.  (Btw - "animationSourceBody" gives X transfer, and "animationSourceGun" gives Y transfer.)  (Also, for sub-turrets, you have to add/subtract the transfer of the parent turret, but as this turret is not a sub-turret, no addition/subtraction is necessary.)  When I try this on other vehicles, I can see the X transfer and the Y transfer change as I move the turret.  But for this troublesome vehicle/turret, X transfer and Y transfer both remain 0.  Which happens to correspond 100% to the visual result from method 2 (gunBeg and gunEnd positions incorrectly remaining fixed straight ahead as I move the gun around).

 

Should I be suspecting a broken config for this vehicle type ("LIB_M4A3_75") that's fouling up methods 2 and 3?

 

Anyone know a good universal method for getting turret's direction?

 

Anyone wonder why we don't have a (simple) turretWeaponDirection command to save us all these shenanigans?  Hmmm... I'm jealous... VBS seems to have this.

Share this post


Link to post
Share on other sites

Maybe this will work :

_turretDirection = eyePos vehicle _x; // _x is the player

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

×