I'm learning unity and i'm trying now make an inventory, i made a simple interface, and now i'm trying to make a item visualization. I look for some codes from web and i found this one:
using UnityEngine;
public class TurnObject : MonoBehaviour
{
protected Vector3 posLastFame;
public Camera UICam;
// Update is called once per frame
void Update()
{
if(Input.GetMouseButtonDown(0)) {
posLastFame = Input.mousePosition;
}
if (Input.GetMouseButton(0)) {
var delta = Input.mousePosition - posLastFame;
posLastFame = Input.mousePosition;
var axis = Quaternion.AngleAxis(-90f, Vector3.forward) * delta;
transform.rotation = Quaternion.AngleAxis(delta.magnitude * 0.1f, axis) * transform.rotation;
}
}
}
I know some code, but I'm not good with geometrics. In this code when I move my mouse horizontal way, my object turn in the Y axis. And that's good. But when I move my mouse vertical the object move in the X axis instead of Z axis.
Is there a way in this code for change this? I really have difficulty to understanding geometrics in Unity.