- Home /
Question by
pyrotech850 · Jan 22, 2020 at 07:09 PM ·
rotationrestrictions
I got this code from a video. It works great but I need restraints on it and I don't know how to add some.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class point : MonoBehaviour
{
public float offset;
private void Update()
{
Mathf.Clamp(Angle, minAngle, maxAngle);
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
}
}
edit: Im trying to make my players head follow the mouse pointer so if whoever helps me can also tell me how to get the head and the restraints to flip when my player is facing left not right.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612221943im_/https://answers.unity.com/themes/thub/images/avi.jpg)