- Home /
script works with orthographic camera but not with perspective
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class arm_rotator : MonoBehaviour
{
public float offset=0f;
void Update()
{
Vector3 direction=Camera.main.ScreenToWorldPoint(Input.mousePosition)-transform.position;
direction.Normalize();
float roty=Mathf.Atan2(direction.y,direction.x)*Mathf.Rad2Deg;
Debug.Log("angle" + roty);
transform.rotation=Quaternion.Euler(0,0,roty+offset);
}
}
Comment
Your answer
Follow this Question
Related Questions
Move camera forward/backwards with mouse wheel 1 Answer
How can I switch between two cameras ? 1 Answer
How can i make a FF Crystal Chronicles Ring of Fates Controller in Unity ? (Final fantasy) 0 Answers
Setting Virtual Camera by Script 0 Answers
How to make camera position relative to a specific target. 1 Answer