Hello,
When I try to rotate this wheel if I click on partition 3, partition 1 automatically goes instead of 3 and then rotates as I want. Basically I would like to stay 3 under the cursor.
Partition 3 was like an example. I need that no matter where I click the rotation starts from there.
Any help, please?
Sorry for my bad english.
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rotate : MonoBehaviour
{
private void OnMouseDrag()
{
Vector3 mouse_pos = Input.mousePosition;
Vector3 wheel_pos = Camera.main.WorldToScreenPoint(this.transform.position);
mouse_pos.x = mouse_pos.x - wheel_pos.x;
mouse_pos.y = mouse_pos.y - wheel_pos.y;
float angle = Mathf.Atan2 (mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
this.transform.rotation = Quaternion.Euler (new Vector3(0, 0, angle));
}
}
Yes, I tried but it didn’t solve my problem.
In attach is a simulation for the first situation.
If I put “angle + 180 °” instead of partition 1 is partition 3, but it’s still not what I need.
Thanks anyway.
Thank you very much for the answer.
Neither this script doesn’t work as I wanted.
I think I’ll give up with that. I’m a beginner and I should probably start with some easier things.
Thanks again for your help and for your time.