Answer the question
In order to leave comments, you need to log in
The object is spinning near the center, not in the center, how to fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class slcamera : MonoBehaviour
{
public float offset;
void Update()
{
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; ;
float rotateZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotateZ + offset);
}
}
Answer the question
In order to leave comments, you need to log in
I advise you to first study or finish your studies if you don’t understand the C# unity code, well, or C# itself if you don’t know it, since there is nowhere to develop without it. I can advise a free course from
ANDROIDHELPER
But still, about your question, I will make a test project with your code and the object (3D object) will spin quietly
, standing in place, maybe this is not what you wanted to achieve, if so, explain in more detail what do you want to achieve
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question