public static Quaternion AngleAxis(float angle, Vector3 axis);
float angle
회전량. degree
Vector3 axis
회전 시킬 대상의 로컬로 변환된 벡터
Quaternion 회전량. local 기준
초기 localRotation을 갖고 있으면 좋음
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AngleAxisTest : MonoBehaviour
{
// Start is called before the first frame update
public float angle;
public Transform parent;
public Transform child;
public Quaternion childInitRotation;
public Vector3 axisVector;
public Vector3 axisVectorLocal;
void Awake()
{
childInitRotation = child.localRotation;
}
void Start()
{
axisVectorLocal = child.InverseTransformDirection(axisVector.normalized);
}
// Update is called once per frame
void Update()
{
Debug.DrawRay(child.position, axisVector, Color.red, 0.1f, true);
Quaternion rotation = Quaternion.AngleAxis(angle, axisVectorLocal);
child.localRotation = childInitRotation * rotation;
}
}