Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class NewTowerMovement : MonoBehaviour
- {
- private Vector3 zAngle;
- private float angle = 1.0f;
- // Update is called once per frame
- void Update()
- {
- Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- mousePos.z = 0f;
- Vector3 aimDirection = (mousePos - transform.position).normalized;
- angle = (Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg) - 90;
- zAngle = (new Vector3(0, 0, angle));
- transform.eulerAngles = zAngle;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement