using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAroundTestScript : MonoBehaviour
{
public Transform pivot;
private Vector2 mouseStartPos;
private Vector2 curMousePos;
public float x = 0;
public float y = 0;
public float z = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
MouseRotation();
}
private void MouseRotation()
{
mouseStartPos = curMousePos;
curMousePos = Input.mousePosition;
Vector2 delta = curMousePos - mouseStartPos;
Vector3 rotAxis = new Vector3(x, y, z);
transform.RotateAround(pivot.position, rotAxis, -delta.x);
}
}
I’m learning to use transform.RotateAround(). I’ve got it working the way I want to for the most part. but I’m struggling a bit with the Vector3 axis. I can rotate around something using the global x, y or z, but I want to rotate around an axis on another object.
for example: I want to rotate the cube around the Y axis of the sphere
What API do I use to return the y axis of a game object in Vector3 format? Is that even possible?