Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void GetDotProduct()
- {
- currentlyAttackingObject = enemyAttackObjects.ElementAt(0);
- Vector3 enemyForward = currentlyAttackingObject.transformV.forward;
- Vector3 enemySide = currentlyAttackingObject.transformV.right;
- Vector3 towardsEnemy = currentlyAttackingObject.transformV.position - transformV.position;
- float dotProductForward = Vector3.Dot(enemyForward, towardsEnemy);
- float dotProductRight = Vector3.Dot(enemySide, towardsEnemy);
- currentlyAttackingObject.DetectedPlayerObject.DetermineBoundingBoxPoints(); //Necessary to calcualte new bounding world points
- if(dotProductForward < 0 && dotProductRight < 0) //If Upper Right
- {
- if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.UpperRightPoint, transformV.position) <= attackRange)
- {
- if(!isAttacking)
- {
- TargetInRange(currentlyAttackingObject);
- }
- }
- }
- else if(dotProductForward < 0 && dotProductRight > 0) //If Upper Left
- {
- if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.UpperLeftPoint, transformV.position) <= attackRange)
- {
- if (!isAttacking)
- {
- TargetInRange(currentlyAttackingObject);
- }
- }
- }
- else if (dotProductForward > 0 && dotProductRight > 0) //If lower left
- {
- if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.LowerLeftPoint, transformV.position) <= attackRange)
- {
- if (!isAttacking)
- {
- TargetInRange(currentlyAttackingObject);
- }
- }
- }
- else if (dotProductForward > 0 && dotProductRight < 0) //If lower right
- {
- if (Vector3.Distance(currentlyAttackingObject.DetectedPlayerObject.LowerRightPoint, transformV.position) <= attackRange)
- {
- if (!isAttacking)
- {
- TargetInRange(currentlyAttackingObject);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement