Advertisement
asqapro

AIChaseTurn

Sep 15th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(pZ>mZ){
  2.     zDis = transform.position.z - player.transform.position.z;
  3.     xDis = transform.position.x - player.transform.position.x;
  4.     if(zDis>xDis){
  5.         rotation = ((zDis)*-(xDis))/2.45;
  6.     }
  7.     else if(xDis>zDis){
  8.         rotation = (zDis)*-(xDis)*1.45;
  9.     }
  10.     if(trueRot>rotation){
  11.         transform.Rotate(Vector3.up*rotation);
  12.         trueRot += rotation;
  13.     }
  14. }
  15. else if(pZ<mZ){
  16.     zDis = player.transform.position.z - transform.position.z;
  17.     xDis = transform.position.x - player.transform.position.x;
  18.     if(zDis>xDis){
  19.         rotation = ((zDis)*(xDis))/2.45;
  20.     }
  21.     else if(xDis>zDis){
  22.         rotation = (zDis)*(xDis)*2;
  23.     }
  24.     if(trueRot<rotation){
  25.         transform.Rotate(Vector3.up*rotation);
  26.         trueRot += rotation;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement