“Interpolate Rotation Unity3d” Réponses codées

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

Réponses similaires à “Interpolate Rotation Unity3d”

Questions similaires à “Interpolate Rotation Unity3d”

Plus de réponses similaires à “Interpolate Rotation Unity3d” dans C#

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code