Advertisement
CakeMeister

2dshooter rotation phan5

Jul 26th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class effectrotate : MonoBehaviour {
  6.  
  7.    
  8.     // Update is called once per frame
  9.     void Update () {
  10.         Vector3 difference = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
  11.         difference.Normalize();
  12.  
  13.         float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
  14.         this.transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement