aiPlayer aim

Scripting questions, discussions, etc
  • 1
  • 2
13 posts Page 2 of 2
Posts: 345
Joined: Tue Feb 03, 2015 10:30 pm
by Steve_Yorkshire » Mon Aug 06, 2018 7:00 pm
@ Hodo33 Got a fix for you. :mrgreen:
The reason this is happening is that the further the distance from the target, the smaller the aim rotation change and the default code setting ignores anything under 0.01f. Aiming at a playerObject near his eyeNode and at the same position height makes the rotation change even smaller.

Check out these pics, no change in LOS at range (~70 units) between z offset 0 and +0.5, but definite aim change up close between +0.5 and +1.0.


Changing AIplayer.cpp ~line 478 in getAiMove to make default ignore rotation smaller. I added 2 more zeros as 1 didn't seem enough at >100m distance.
            // This should be adjusted to run from the
            // eye point to the object's center position. Though this
            // works well enough for now.
            F32 vertDist = mAimLocation.z - location.z;
            F32 horzDist = mSqrt(xDiff * xDiff + yDiff * yDiff);
            F32 newPitch = mAtan2( horzDist, vertDist ) - ( M_PI_F / 2.0f );
            if (mFabs(newPitch) > 0.0001f)//yorks was 0.01
               Point3F headRotation = getHeadRotation();
               movePtr->pitch = newPitch - headRotation.x;
And this is the difference at 120 units.

@ Azaezel @ JeffR maybe one for rolling into development? (you know github hates me :lol: )

Just to note, this is using the standard Lurker file only with projectile spread set to 0 and projectileData lifetime very much increased - just for testing, it doesn't use the eyeOffSet value which I suggested earlier in this thread (so you can ignore that).
datablock ShapeBaseImageData(LurkerWeaponImage)
   // Basic Item properties
   shapeFile = "art/shapes/weapons/Lurker/TP_Lurker.DAE";
   shapeFileFP = "art/shapes/weapons/Lurker/FP_Lurker.DAE";
   emap = true;

   imageAnimPrefix = "Rifle";
   imageAnimPrefixFP = "Rifle";

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   firstPerson = true;
   useEyeNode = true;
   animateOnServer = true;

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off.
   correctMuzzleVector = true;
//... etc etc
This newPitch setting of 0.0001f, gives pitch offset increments of z +1.0 at 650 metres/units - which is way more than visual distance.
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Sun Sep 09, 2018 3:52 pm
Thanks for the info Steve. I will make some changes there and see what happens.
Posts: 104
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Fri Sep 21, 2018 4:16 pm
I just noticed I hadn't responded to this. Steve got the magic fix and the bots are brutal now. Thanks for the help to all ....
  • 1
  • 2
13 posts Page 2 of 2

Who is online

Users browsing this forum: No registered users and 3 guests