Using slerp outside outside update function makes animation jerky
I am building an application in which I have to animate a character using Euler angles coming from bluetooth sensors in real time. As new data arrives, unitySendMessage() is called which calls a function to extract the values and update player arm movement. The problem is that the movement is jerky. The code is given below. it is called outside the update function. Please help me with this issue.
public void readAndUpdate1(string message)
{
Debug.Log (message);
// Convert the hex to coordinates
splitValues = message.Split('-');
String hexY = splitValues[3] + splitValues[2];
String hexX = splitValues[5] + splitValues[4];
String hexZ = splitValues[7] + splitValues[6];
int y = (short)Int32.Parse(hexY, System.Globalization.NumberStyles.HexNumber);
int x = (short)Int16.Parse(hexX, System.Globalization.NumberStyles.HexNumber);
int z = (short)Int16.Parse(hexZ, System.Globalization.NumberStyles.HexNumber);
EulerX.text = "X: " + x;
EulerY.text = "Y: " + y;
EulerZ.text = "Z: " + z;
lowerArm.rotation = Quaternion.Slerp (lowerArm.rotation, Quaternion.Euler(x, y, z), Time.deltaTime);
}
Comment
Your answer
Follow this Question
Related Questions
Not able to get ball to slerp rotate 180 degrees one way on input 0 Answers
Best Method to Rotate Camera around a GameObject while looking at another? 0 Answers
Move object towards a moving point C# 1 Answer
Lerp going crazy when negative 1 Answer
How to control rocket pathing with Quaternion.Slerp 1 Answer