Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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;
Comment

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;
}
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity render to texture2d 
Csharp :: entity framework core db first 
Csharp :: scale between tow ranges c# 
Csharp :: dataannotations datetime range 
Csharp :: asp.net core 6 autofac 
Csharp :: c# yield 
Csharp :: unity respawn c# 
Csharp :: how to close another app in system with c# 
Csharp :: c# modify dictionary in loop 
Csharp :: c# combobox with text and value 
Csharp :: #ifdef in c 
Csharp :: check file lock c# 
Csharp :: finally c# code 
Csharp :: reverse linked list 
Csharp :: unity list get item at index 
Csharp :: c# max function 
Csharp :: get quaternion from vector unity 
Csharp :: c# object is in object list 
Csharp :: HTTP Error 500.35 - ASP.NET Core does not support multiple apps in the same app pool 
Csharp :: c# add strings 
Csharp :: print c# 
Csharp :: combobox in datagrid wpf 
Csharp :: for statement syntax C sharp 
Csharp :: C# Convert 1 range to another 
Csharp :: c sharp teleporting 
Csharp :: clickable table row asp.net core 
Csharp :: translate int to string with x 0 before c# 
Csharp :: C# order a sorted list by key 
Csharp :: unity subtract class 
Csharp :: c# .net core entity framework one to many 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =