Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(pZ>mZ){
- zDis = transform.position.z - player.transform.position.z;
- xDis = transform.position.x - player.transform.position.x;
- if(zDis>xDis){
- rotation = ((zDis)*-(xDis))/2.45;
- }
- else if(xDis>zDis){
- rotation = (zDis)*-(xDis)*1.45;
- }
- if(trueRot>rotation){
- transform.Rotate(Vector3.up*rotation);
- trueRot += rotation;
- }
- }
- else if(pZ<mZ){
- zDis = player.transform.position.z - transform.position.z;
- xDis = transform.position.x - player.transform.position.x;
- if(zDis>xDis){
- rotation = ((zDis)*(xDis))/2.45;
- }
- else if(xDis>zDis){
- rotation = (zDis)*(xDis)*2;
- }
- if(trueRot<rotation){
- transform.Rotate(Vector3.up*rotation);
- trueRot += rotation;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement