Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Movement : MonoBehaviour
- {
- public Transform target;
- private Vector3 mousePos;
- // Use this for initialization
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y,10);
- Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
- lookPos = lookPos - transform.position;
- float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
- transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
- }
- }
Add Comment
Please, Sign In to add comment