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 armrotation : MonoBehaviour {
- public Player player;
- public float x;
- public Vector3 fliparm;
- // Use this for initialization
- void Start () {
- x = transform.localScale.x;
- fliparm = transform.localScale;
- player = GetComponentInParent<Player>();
- }
- // Update is called once per frame
- void Update () {
- Vector3 difference = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
- difference.Normalize();
- float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
- if (difference.x >= 0)
- {
- transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
- player.armright = true;
- }
- else
- {
- transform.rotation = Quaternion.Euler(0f, 0f, rotZ+180);
- player.armright = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement