SHARE
TWEET

Untitled

a guest May 2nd, 2015 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    private void GetDotProduct()
  2.     {
  3.         currentlyAttackingObject = enemyAttackObjects.ElementAt(0);
  4.         Vector3 enemyForward = currentlyAttackingObject.transformV.forward;
  5.         Vector3 enemySide = currentlyAttackingObject.transformV.right;
  6.         Vector3 towardsEnemy = currentlyAttackingObject.transformV.position - transformV.position;
  7.  
  8.         float dotProductForward = Vector3.Dot(enemyForward, towardsEnemy);
  9.         float dotProductRight = Vector3.Dot(enemySide, towardsEnemy);
  10.  
  11.  
  12.         currentlyAttackingObject.DetectedPlayerObject.DetermineBoundingBoxPoints(); //Necessary to calcualte new bounding world points
  13.  
  14.         if(dotProductForward < 0 && dotProductRight < 0) //If Upper Right
  15.         {
  16.             if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.UpperRightPoint, transformV.position) <= attackRange)
  17.             {
  18.                 if(!isAttacking)
  19.                 {
  20.                     TargetInRange(currentlyAttackingObject);
  21.                 }
  22.             }
  23.         }
  24.         else if(dotProductForward < 0 && dotProductRight > 0) //If Upper Left
  25.         {
  26.             if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.UpperLeftPoint, transformV.position) <= attackRange)
  27.             {
  28.                 if (!isAttacking)
  29.                 {
  30.                     TargetInRange(currentlyAttackingObject);
  31.                 }
  32.             }
  33.         }
  34.         else if (dotProductForward > 0 && dotProductRight > 0) //If lower left
  35.         {
  36.             if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.LowerLeftPoint, transformV.position) <= attackRange)
  37.             {
  38.                 if (!isAttacking)
  39.                 {
  40.                     TargetInRange(currentlyAttackingObject);
  41.                 }
  42.             }
  43.         }
  44.         else if (dotProductForward > 0 && dotProductRight < 0) //If lower right
  45.         {
  46.             if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.LowerRightPoint, transformV.position) <= attackRange)
  47.             {
  48.                 if (!isAttacking)
  49.                 {
  50.                     TargetInRange(currentlyAttackingObject);
  51.                 }
  52.             }
  53.         }
  54.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top