“Interpolate Rotation Unity3D” Kode Jawaban

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

Jawaban yang mirip dengan “Interpolate Rotation Unity3D”

Pertanyaan yang mirip dengan “Interpolate Rotation Unity3D”

Lebih banyak jawaban terkait untuk “Interpolate Rotation Unity3D” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya