“Interpolate Rotation Unity3D” Respostas de código

Interpolate Rotation Unity3D

//using the cross-product is quite effective 
//Note: This is quite usefull for rigidbodys... 
//but you can also use that for transform with some code adjustments
Vector3 targetDir;
Vector3 currentDir = transform.forward; //whatever your currentDir is

//the cross product returns the axis you want to rotate around
Vector3 crossProduct = Vector3.cross(targetDir, currentDir);
float magnitude = crossProduct.magnitude;
rigidbody.angularVelocity = crossProduct.normalized * speed * magnitude;
Colorful Capuchin

Interpolate Rotation Unity3D


Simple Code:
Vector3 currentCameraEulers;
float rotationDPI = 7f; // I didn't remeber how to call better this thing

void Update(){
float cameraX = Input.GetAxisRaw("Mouse X") * rotationDPI;
if(cameraX != 0f){
currentCameraEulers = new Vector3(0, cameraX, 0);
transform.eulerAngles += currentCameraEulers;
}
}

Uptight Unicorn

Respostas semelhantes a “Interpolate Rotation Unity3D”

Perguntas semelhantes a “Interpolate Rotation Unity3D”

Mais respostas relacionadas para “Interpolate Rotation Unity3D” em C#

Procure respostas de código populares por idioma

Procurar outros idiomas de código