Guest User

Untitled

a guest
Jul 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Movement : MonoBehaviour
  6. {
  7. public Transform target;
  8. private Vector3 mousePos;
  9. // Use this for initialization
  10. void Start()
  11. {
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y,10);
  18. Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
  19. lookPos = lookPos - transform.position;
  20. float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
  21. transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
  22. }
  23. }
Add Comment
Please, Sign In to add comment